Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygennetshell.cpp
Go to the documentation of this file.
00001 #include "precomp.h" 00002 00003 WINE_DEFAULT_DEBUG_CHANNEL (shell); 00004 00005 HINSTANCE netshell_hInstance; 00006 const GUID CLSID_LANConnectUI = {0x7007ACC5, 0x3202, 0x11D1, {0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E}}; 00007 const GUID CLSID_NetworkConnections = {0x7007ACC7, 0x3202, 0x11D1, {0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E}}; 00008 const GUID CLSID_LanConnectStatusUI = {0x7007ACCF, 0x3202, 0x11D1, {0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E}}; 00009 00010 static const WCHAR szNetConnectClass[] = L"CLSID\\{7007ACC7-3202-11D1-AAD2-00805FC1270E}"; 00011 static const WCHAR szLanConnectUI[] = L"CLSID\\{7007ACC5-3202-11D1-AAD2-00805FC1270E}"; 00012 static const WCHAR szLanConnectStatusUI[] = L"CLSID\\{7007ACCF-3202-11D1-AAD2-00805FC1270E}"; 00013 static const WCHAR szNamespaceKey[] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{7007ACC7-3202-11D1-AAD2-00805FC1270E}"; 00014 00015 extern "C" 00016 { 00017 00018 BOOL 00019 WINAPI 00020 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) 00021 { 00022 switch (fdwReason) 00023 { 00024 case DLL_PROCESS_ATTACH: 00025 netshell_hInstance = hinstDLL; 00026 DisableThreadLibraryCalls(netshell_hInstance); 00027 break; 00028 default: 00029 break; 00030 } 00031 00032 return TRUE; 00033 } 00034 00035 HRESULT 00036 WINAPI 00037 DllCanUnloadNow(void) 00038 { 00039 return S_FALSE; 00040 } 00041 00042 STDAPI 00043 DllRegisterServer(void) 00044 { 00045 HKEY hKey, hSubKey; 00046 WCHAR szName[MAX_PATH+20] = {0}; 00047 WCHAR szNet[20]; 00048 UINT Length, Offset; 00049 00050 00051 if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szNetConnectClass, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) 00052 return SELFREG_E_CLASS; 00053 00054 if (LoadStringW(netshell_hInstance, IDS_NETWORKCONNECTION, szName, MAX_PATH)) 00055 { 00056 szName[MAX_PATH-1] = L'\0'; 00057 RegSetValueW(hKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR)); 00058 } 00059 00060 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, szNamespaceKey, 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) 00061 { 00062 RegSetValueW(hSubKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR)); 00063 RegCloseKey(hSubKey); 00064 } 00065 00066 Length = swprintf(szNet, L",-%u", IDS_NETWORKCONNECTION); 00067 Offset = GetModuleFileNameW(netshell_hInstance, &szName[1], (sizeof(szName)/sizeof(WCHAR))-1); 00068 if (Offset + Length + 2 < MAX_PATH) 00069 { 00070 /* set localized name */ 00071 szName[0] = L'@'; 00072 wcscpy(&szName[Offset+1], szNet); 00073 RegSetValueExW(hKey, L"LocalizedString", 0, REG_SZ, (const LPBYTE)szName, (wcslen(szName)+1) * sizeof(WCHAR)); 00074 } 00075 00076 szName[Offset+1] = L'\0'; 00077 00078 /* store default icon */ 00079 if (RegCreateKeyExW(hKey, L"DefaultIcon", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) 00080 { 00081 RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); 00082 RegCloseKey(hSubKey); 00083 } 00084 if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) 00085 { 00086 RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); 00087 RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); 00088 RegCloseKey(hSubKey); 00089 } 00090 00091 if (RegCreateKeyExW(hKey, L"ShellFolder", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) 00092 { 00093 DWORD dwAttributes = SFGAO_FOLDER; 00094 RegSetValueExW(hSubKey, L"Attributes",0, REG_BINARY, (const LPBYTE)&dwAttributes, sizeof(DWORD)); 00095 } 00096 00097 RegCloseKey(hKey); 00098 00099 if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szLanConnectUI, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) 00100 return SELFREG_E_CLASS; 00101 00102 if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) 00103 { 00104 RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); 00105 RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); 00106 RegCloseKey(hSubKey); 00107 } 00108 00109 RegCloseKey(hKey); 00110 00111 if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szLanConnectStatusUI, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) 00112 return SELFREG_E_CLASS; 00113 00114 if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) 00115 { 00116 RegSetValueW(hSubKey, NULL, REG_SZ, &szName[1], (Offset+1) * sizeof(WCHAR)); 00117 RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); 00118 RegCloseKey(hSubKey); 00119 } 00120 00121 RegCloseKey(hKey); 00122 00123 00124 return S_OK; 00125 } 00126 00127 STDAPI 00128 DllUnregisterServer(void) 00129 { 00130 SHDeleteKeyW(HKEY_CLASSES_ROOT, szNetConnectClass); 00131 SHDeleteKeyW(HKEY_LOCAL_MACHINE, szNamespaceKey); 00132 return S_OK; 00133 } 00134 00135 STDAPI 00136 DllGetClassObject( 00137 REFCLSID rclsid, 00138 REFIID riid, 00139 LPVOID *ppv) 00140 { 00141 if (!ppv) 00142 return E_INVALIDARG; 00143 00144 *ppv = NULL; 00145 00146 return IClassFactory_fnConstructor(rclsid, riid, ppv); 00147 } 00148 00149 VOID 00150 WINAPI 00151 NcFreeNetconProperties(NETCON_PROPERTIES *pProps) 00152 { 00153 CoTaskMemFree(pProps->pszwName); 00154 CoTaskMemFree(pProps->pszwDeviceName); 00155 CoTaskMemFree(pProps); 00156 } 00157 00158 } // extern "C" Generated on Sun May 27 2012 04:25:30 for ReactOS by
1.7.6.1
|