[NETSHELL]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 13 Jul 2014 07:38:49 +0000 (07:38 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 13 Jul 2014 07:38:49 +0000 (07:38 +0000)
Add code to rename network conections.

svn path=/trunk/; revision=63712

reactos/dll/win32/netshell/connectmanager.cpp
reactos/dll/win32/netshell/shfldr_netconnect.cpp

index c43624e..7d94c38 100644 (file)
@@ -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)
index c7630ee..2b2ef65 100644 (file)
@@ -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)