Author: ekohl Date: Sun Jul 13 07:38:49 2014 New Revision: 63712
URL: http://svn.reactos.org/svn/reactos?rev=63712&view=rev Log: [NETSHELL] Add code to rename network conections.
Modified: trunk/reactos/dll/win32/netshell/connectmanager.cpp trunk/reactos/dll/win32/netshell/shfldr_netconnect.cpp
Modified: trunk/reactos/dll/win32/netshell/connectmanager.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/connectm... ============================================================================== --- trunk/reactos/dll/win32/netshell/connectmanager.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netshell/connectmanager.cpp [iso-8859-1] Sun Jul 13 07:38:49 2014 @@ -329,7 +329,45 @@ 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)
Modified: trunk/reactos/dll/win32/netshell/shfldr_netconnect.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/shfldr_n... ============================================================================== --- trunk/reactos/dll/win32/netshell/shfldr_netconnect.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netshell/shfldr_netconnect.cpp [iso-8859-1] Sun Jul 13 07:38:49 2014 @@ -522,7 +522,16 @@ 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)