1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS Configuration of network devices 4 * FILE: dll/win32/netcfgx/netcfgx.c 5 * PURPOSE: Network devices installer 6 * 7 * PROGRAMMERS: Herv� Poussineau (hpoussin@reactos.org) 8 */ 9 10 #include "precomp.h" 11 12 #include <olectl.h> 13 14 15 HINSTANCE netcfgx_hInstance; 16 const GUID CLSID_TcpipConfigNotifyObject = {0xA907657F, 0x6FDF, 0x11D0, {0x8E, 0xFB, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xB2}}; 17 18 static INTERFACE_TABLE InterfaceTable[] = 19 { 20 { 21 &CLSID_CNetCfg, 22 INetCfg_Constructor 23 }, 24 { 25 &CLSID_TcpipConfigNotifyObject, 26 TcpipConfigNotify_Constructor 27 }, 28 { 29 NULL, 30 NULL 31 } 32 }; 33 34 BOOL 35 WINAPI 36 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) 37 { 38 switch (fdwReason) 39 { 40 case DLL_PROCESS_ATTACH: 41 netcfgx_hInstance = hinstDLL; 42 DisableThreadLibraryCalls(netcfgx_hInstance); 43 InitCommonControls(); 44 break; 45 46 default: 47 break; 48 } 49 50 return TRUE; 51 } 52 53 HRESULT 54 WINAPI 55 DllCanUnloadNow(void) 56 { 57 return S_FALSE; 58 } 59 60 STDAPI 61 DllRegisterServer(void) 62 { 63 HKEY hKey, hSubKey; 64 LPOLESTR pStr; 65 WCHAR szName[MAX_PATH] = L"CLSID\\"; 66 67 if (FAILED(StringFromCLSID(&CLSID_CNetCfg, &pStr))) 68 return SELFREG_E_CLASS; 69 70 wcscpy(&szName[6], pStr); 71 CoTaskMemFree(pStr); 72 73 if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szName, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) 74 return SELFREG_E_CLASS; 75 76 if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) 77 { 78 if (!GetModuleFileNameW(netcfgx_hInstance, szName, sizeof(szName)/sizeof(WCHAR))) 79 { 80 RegCloseKey(hSubKey); 81 RegCloseKey(hKey); 82 return SELFREG_E_CLASS; 83 } 84 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; 85 RegSetValueW(hSubKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR)); 86 RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); 87 RegCloseKey(hSubKey); 88 } 89 90 RegCloseKey(hKey); 91 return S_OK; 92 } 93 94 STDAPI 95 DllUnregisterServer(void) 96 { 97 //FIXME 98 // implement unregistering services 99 // 100 return S_OK; 101 } 102 103 STDAPI 104 DllGetClassObject( 105 REFCLSID rclsid, 106 REFIID riid, 107 LPVOID* ppv) 108 { 109 UINT i; 110 HRESULT hres = E_OUTOFMEMORY; 111 IClassFactory * pcf = NULL; 112 113 if (!ppv) 114 return E_INVALIDARG; 115 116 *ppv = NULL; 117 118 for (i = 0; InterfaceTable[i].riid; i++) 119 { 120 if (IsEqualIID(InterfaceTable[i].riid, rclsid)) 121 { 122 pcf = IClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); 123 break; 124 } 125 } 126 127 if (!pcf) 128 { 129 return CLASS_E_CLASSNOTAVAILABLE; 130 } 131 132 hres = IClassFactory_QueryInterface(pcf, riid, ppv); 133 IClassFactory_Release(pcf); 134 135 return hres; 136 } 137