From 7eb3fcf1d5923b74aebf073b69860fcc63a621bc Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 28 Feb 2015 10:11:51 +0000 Subject: [PATCH] [NETSHELL] Simplify registration by using an rgs file. Brought to you by Giannis Adamopoulos. CORE-9276 svn path=/trunk/; revision=66485 --- reactos/dll/shellext/netshell/netshell.cpp | 94 ++----------------- reactos/dll/shellext/netshell/netshell.rc | 2 + .../dll/shellext/netshell/res/netshell.rgs | 60 ++++++++++++ reactos/dll/shellext/netshell/resource.h | 2 + 4 files changed, 70 insertions(+), 88 deletions(-) create mode 100644 reactos/dll/shellext/netshell/res/netshell.rgs diff --git a/reactos/dll/shellext/netshell/netshell.cpp b/reactos/dll/shellext/netshell/netshell.cpp index 5bf31a37350..5c3aa330e01 100644 --- a/reactos/dll/shellext/netshell/netshell.cpp +++ b/reactos/dll/shellext/netshell/netshell.cpp @@ -4,14 +4,13 @@ HINSTANCE netshell_hInstance; -static const WCHAR szNetConnectClass[] = L"CLSID\\{7007ACC7-3202-11D1-AAD2-00805FC1270E}"; -static const WCHAR szLanConnectUI[] = L"CLSID\\{7007ACC5-3202-11D1-AAD2-00805FC1270E}"; -static const WCHAR szLanConnectStatusUI[] = L"CLSID\\{7007ACCF-3202-11D1-AAD2-00805FC1270E}"; -static const WCHAR szNamespaceKey[] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{7007ACC7-3202-11D1-AAD2-00805FC1270E}"; - extern "C" { +/* FIXME: rpcproxy.h */ +HRESULT __wine_register_resources(HMODULE module); +HRESULT __wine_unregister_resources(HMODULE module); + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) @@ -39,94 +38,13 @@ DllCanUnloadNow(void) STDAPI DllRegisterServer(void) { - HKEY hKey, hSubKey; - WCHAR szName[MAX_PATH+20] = {0}; - WCHAR szNet[20]; - UINT Length, Offset; - - - if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szNetConnectClass, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) - return SELFREG_E_CLASS; - - if (LoadStringW(netshell_hInstance, IDS_NETWORKCONNECTION, szName, MAX_PATH)) - { - szName[MAX_PATH-1] = L'\0'; - RegSetValueW(hKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR)); - } - - if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, szNamespaceKey, 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - RegSetValueW(hSubKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR)); - RegCloseKey(hSubKey); - } - - Length = swprintf(szNet, L",-%u", IDS_NETWORKCONNECTION); - Offset = GetModuleFileNameW(netshell_hInstance, &szName[1], (sizeof(szName)/sizeof(WCHAR))-1); - if (Offset + Length + 2 < MAX_PATH) - { - /* set localized name */ - szName[0] = L'@'; - wcscpy(&szName[Offset+1], szNet); - RegSetValueExW(hKey, L"LocalizedString", 0, REG_SZ, (const LPBYTE)szName, (wcslen(szName)+1) * sizeof(WCHAR)); - } - - szName[Offset+1] = L'\0'; - - /* store default icon */ - if (RegCreateKeyExW(hKey, L"DefaultIcon", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); - RegCloseKey(hSubKey); - } - if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); - RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); - RegCloseKey(hSubKey); - } - - if (RegCreateKeyExW(hKey, L"ShellFolder", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - DWORD dwAttributes = SFGAO_FOLDER; - RegSetValueExW(hSubKey, L"Attributes",0, REG_BINARY, (const LPBYTE)&dwAttributes, sizeof(DWORD)); - } - - RegCloseKey(hKey); - - if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szLanConnectUI, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) - return SELFREG_E_CLASS; - - if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); - RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); - RegCloseKey(hSubKey); - } - - RegCloseKey(hKey); - - if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szLanConnectStatusUI, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) - return SELFREG_E_CLASS; - - if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); - RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); - RegCloseKey(hSubKey); - } - - RegCloseKey(hKey); - - - return S_OK; + return __wine_register_resources(netshell_hInstance); } STDAPI DllUnregisterServer(void) { - SHDeleteKeyW(HKEY_CLASSES_ROOT, szNetConnectClass); - SHDeleteKeyW(HKEY_LOCAL_MACHINE, szNamespaceKey); - return S_OK; + return __wine_unregister_resources(netshell_hInstance); } STDAPI diff --git a/reactos/dll/shellext/netshell/netshell.rc b/reactos/dll/shellext/netshell/netshell.rc index ff1c9e32d1b..5595bfb0a82 100644 --- a/reactos/dll/shellext/netshell/netshell.rc +++ b/reactos/dll/shellext/netshell/netshell.rc @@ -22,6 +22,8 @@ IDI_NET_REC ICON "res/netrec.ico" IDI_NET_TRANS ICON "res/nettrans.ico" IDI_NET_TRANSREC ICON "res/nettrrec.ico" +IDR_NETSHELL REGISTRY "res/netshell.rgs" + /* UTF-8 */ #pragma code_page(65001) diff --git a/reactos/dll/shellext/netshell/res/netshell.rgs b/reactos/dll/shellext/netshell/res/netshell.rgs new file mode 100644 index 00000000000..c2bc3467f54 --- /dev/null +++ b/reactos/dll/shellext/netshell/res/netshell.rgs @@ -0,0 +1,60 @@ +HKCR +{ + NoRemove CLSID + { + ForceRemove {7007ACC7-3202-11D1-AAD2-00805FC1270E} = s 'Network Connections' + { + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Both' + } + DefaultIcon = s '%MODULE%' + ShellFolder + { + val Attributes = d '0x00000020' + } + val LocalizedString = s '@%MODULE%,-10000' + } + ForceRemove {7007ACC5-3202-11D1-AAD2-00805FC1270E} = s 'Network Connections' + { + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Both' + } + } + ForceRemove {7007ACCF-3202-11D1-AAD2-00805FC1270E} = s 'Network Connections' + { + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Both' + } + } + } +} +HKLM +{ + NoRemove Software + { + NoRemove Microsoft + { + NoRemove Windows + { + NoRemove CurrentVersion + { + NoRemove Explorer + { + NoRemove MyComputer + { + NoRemove NameSpace + { + ForceRemove {7007ACC7-3202-11D1-AAD2-00805FC1270E} = s 'Network Connections' + { + } + } + } + } + } + } + } + } +} diff --git a/reactos/dll/shellext/netshell/resource.h b/reactos/dll/shellext/netshell/resource.h index 754f3401d7e..f437483fd57 100644 --- a/reactos/dll/shellext/netshell/resource.h +++ b/reactos/dll/shellext/netshell/resource.h @@ -94,3 +94,5 @@ #define IDS_WINS_SERVERS 10308 #define IDS_PROPERTY 10309 #define IDS_VALUE 10310 + +#define IDR_NETSHELL 20000