mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[NETSHELL]
Add code to rename network conections. svn path=/trunk/; revision=63712
This commit is contained in:
parent
970a537191
commit
f6cabeaa54
2 changed files with 49 additions and 2 deletions
|
@ -329,7 +329,45 @@ HRESULT
|
|||
WINAPI
|
||||
CNetConnection::Rename(LPCWSTR pszwDuplicateName)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
WCHAR szName[140];
|
||||
LPOLESTR pStr;
|
||||
DWORD dwSize;
|
||||
HKEY hKey;
|
||||
HRESULT hr;
|
||||
|
||||
if (pszwDuplicateName == NULL || wcslen(pszwDuplicateName) == 0)
|
||||
return S_OK;
|
||||
|
||||
if (Props.pszwName)
|
||||
{
|
||||
CoTaskMemFree(Props.pszwName);
|
||||
Props.pszwName = NULL;
|
||||
}
|
||||
|
||||
dwSize = (wcslen(pszwDuplicateName) + 1) * sizeof(WCHAR);
|
||||
Props.pszwName = (LPWSTR)CoTaskMemAlloc(dwSize);
|
||||
if (Props.pszwName == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
wcscpy(Props.pszwName, pszwDuplicateName);
|
||||
|
||||
hr = StringFromCLSID((CLSID)Props.guidId, &pStr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
wcscpy(szName, L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\");
|
||||
wcscat(szName, pStr);
|
||||
wcscat(szName, L"\\Connection");
|
||||
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szName, 0, KEY_WRITE, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueExW(hKey, L"Name", NULL, REG_SZ, (LPBYTE)Props.pszwName, dwSize);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
CoTaskMemFree(pStr);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IConnection_Constructor(INetConnection **ppv, PINetConnectionItem pItem)
|
||||
|
|
|
@ -522,7 +522,16 @@ HRESULT WINAPI CNetworkConnections::SetNameOf (
|
|||
HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
|
||||
LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
VALUEStruct * val;
|
||||
|
||||
val = _ILGetValueStruct(pidl);
|
||||
if (!val)
|
||||
return E_FAIL;
|
||||
|
||||
if (!val->pItem)
|
||||
return E_FAIL;
|
||||
|
||||
return val->pItem->Rename(lpName);
|
||||
}
|
||||
|
||||
HRESULT WINAPI CNetworkConnections::GetDefaultSearchGUID(GUID * pguid)
|
||||
|
|
Loading…
Reference in a new issue