5 HINSTANCE netshell_hInstance
;
6 const GUID CLSID_LANConnectUI
= {0x7007ACC5, 0x3202, 0x11D1, {0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E}};
7 const GUID CLSID_NetworkConnections
= {0x7007ACC7, 0x3202, 0x11D1, {0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E}};
8 const GUID CLSID_LanConnectStatusUI
= {0x7007ACCF, 0x3202, 0x11D1, {0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E}};
10 static const WCHAR szNetConnectClass
[] = L
"CLSID\\{7007ACC7-3202-11D1-AAD2-00805FC1270E}";
11 static const WCHAR szLanConnectUI
[] = L
"CLSID\\{7007ACC5-3202-11D1-AAD2-00805FC1270E}";
12 static const WCHAR szLanConnectStatusUI
[] = L
"CLSID\\{7007ACCF-3202-11D1-AAD2-00805FC1270E}";
13 static const WCHAR szNamespaceKey
[] = L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{7007ACC7-3202-11D1-AAD2-00805FC1270E}";
15 static INTERFACE_TABLE InterfaceTable
[] =
18 &CLSID_NetworkConnections
,
19 ISF_NetConnect_Constructor
22 &CLSID_ConnectionManager
,
23 INetConnectionManager_Constructor
27 LanConnectUI_Constructor
30 &CLSID_LanConnectStatusUI
,
31 LanConnectStatusUI_Constructor
42 DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
46 case DLL_PROCESS_ATTACH
:
47 netshell_hInstance
= hinstDLL
;
48 DisableThreadLibraryCalls(netshell_hInstance
);
65 DllRegisterServer(void)
68 WCHAR szName
[MAX_PATH
+20] = {0};
73 if (RegCreateKeyExW(HKEY_CLASSES_ROOT
, szNetConnectClass
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
74 return SELFREG_E_CLASS
;
76 if (LoadStringW(netshell_hInstance
, IDS_NETWORKCONNECTION
, szName
, MAX_PATH
))
78 szName
[MAX_PATH
-1] = L
'\0';
79 RegSetValueW(hKey
, NULL
, REG_SZ
, szName
, (wcslen(szName
)+1) * sizeof(WCHAR
));
82 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
, szNamespaceKey
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
84 RegSetValueW(hSubKey
, NULL
, REG_SZ
, szName
, (wcslen(szName
)+1) * sizeof(WCHAR
));
88 Length
= swprintf(szNet
, L
",-%u", IDS_NETWORKCONNECTION
);
89 Offset
= GetModuleFileNameW(netshell_hInstance
, &szName
[1], (sizeof(szName
)/sizeof(WCHAR
))-1);
90 if (Offset
+ Length
+ 2 < MAX_PATH
)
92 /* set localized name */
94 wcscpy(&szName
[Offset
+1], szNet
);
95 RegSetValueExW(hKey
, L
"LocalizedString", 0, REG_SZ
, (const LPBYTE
)szName
, (wcslen(szName
)+1) * sizeof(WCHAR
));
98 szName
[Offset
+1] = L
'\0';
100 /* store default icon */
101 if (RegCreateKeyExW(hKey
, L
"DefaultIcon", 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
103 RegSetValueW(hSubKey
, NULL
, REG_SZ
, &szName
[1], (Offset
+1) * sizeof(WCHAR
));
104 RegCloseKey(hSubKey
);
106 if (RegCreateKeyExW(hKey
, L
"InProcServer32", 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
108 RegSetValueW(hSubKey
, NULL
, REG_SZ
, &szName
[1], (Offset
+1) * sizeof(WCHAR
));
109 RegSetValueExW(hSubKey
, L
"ThreadingModel", 0, REG_SZ
, (LPBYTE
)L
"Both", 10);
110 RegCloseKey(hSubKey
);
113 if (RegCreateKeyExW(hKey
, L
"ShellFolder", 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
115 DWORD dwAttributes
= SFGAO_FOLDER
;
116 RegSetValueExW(hSubKey
, L
"Attributes",0, REG_BINARY
, (const LPBYTE
)&dwAttributes
, sizeof(DWORD
));
121 if (RegCreateKeyExW(HKEY_CLASSES_ROOT
, szLanConnectUI
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
122 return SELFREG_E_CLASS
;
124 if (RegCreateKeyExW(hKey
, L
"InProcServer32", 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
126 RegSetValueW(hSubKey
, NULL
, REG_SZ
, &szName
[1], (Offset
+1) * sizeof(WCHAR
));
127 RegSetValueExW(hSubKey
, L
"ThreadingModel", 0, REG_SZ
, (LPBYTE
)L
"Both", 10);
128 RegCloseKey(hSubKey
);
133 if (RegCreateKeyExW(HKEY_CLASSES_ROOT
, szLanConnectStatusUI
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
134 return SELFREG_E_CLASS
;
136 if (RegCreateKeyExW(hKey
, L
"InProcServer32", 0, NULL
, 0, KEY_WRITE
, NULL
, &hSubKey
, NULL
) == ERROR_SUCCESS
)
138 RegSetValueW(hSubKey
, NULL
, REG_SZ
, &szName
[1], (Offset
+1) * sizeof(WCHAR
));
139 RegSetValueExW(hSubKey
, L
"ThreadingModel", 0, REG_SZ
, (LPBYTE
)L
"Both", 10);
140 RegCloseKey(hSubKey
);
150 DllUnregisterServer(void)
152 SHDeleteKeyW(HKEY_CLASSES_ROOT
, szNetConnectClass
);
153 SHDeleteKeyW(HKEY_LOCAL_MACHINE
, szNamespaceKey
);
165 HRESULT hres
= E_OUTOFMEMORY
;
166 IClassFactory
* pcf
= NULL
;
173 for (i
= 0; InterfaceTable
[i
].riid
; i
++)
175 if (IsEqualIID(InterfaceTable
[i
].riid
, rclsid
))
177 pcf
= IClassFactory_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
184 return CLASS_E_CLASSNOTAVAILABLE
;
187 hres
= IClassFactory_QueryInterface(pcf
, riid
, ppv
);
188 IClassFactory_Release(pcf
);
195 NcFreeNetconProperties (NETCON_PROPERTIES
* pProps
)
197 CoTaskMemFree(pProps
->pszwName
);
198 CoTaskMemFree(pProps
->pszwDeviceName
);
199 CoTaskMemFree(pProps
);