Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1324 lines
40 KiB

  1. #include "main.h"
  2. #include <initguid.h>
  3. #include "about.h"
  4. #include <gpedit.h>
  5. //
  6. // Global variables for this DLL
  7. //
  8. LONG g_cRefThisDll = 0;
  9. HINSTANCE g_hInstance;
  10. DWORD g_dwNameSpaceItems;
  11. CRITICAL_SECTION g_DCCS;
  12. TCHAR g_szDisplayProperties[150] = {0};
  13. //
  14. // Group Policy Manager's snapin GUID
  15. // {D70A2BEA-A63E-11d1-A7D4-0000F87571E3}
  16. //
  17. DEFINE_GUID(CLSID_GPMSnapIn, 0xd70a2bea, 0xa63e, 0x11d1, 0xa7, 0xd4, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  18. //
  19. // RSOP Context Menu GUID for planning mode
  20. // {63E23168-BFF7-4E87-A246-EF024425E4EC}
  21. //
  22. DEFINE_GUID(CLSID_RSOP_CMenu, 0x63E23168, 0xBFF7, 0x4E87, 0xA2, 0x46, 0xEF, 0x02, 0x44, 0x25, 0xE4, 0xEC);
  23. //
  24. // DS Admin's snapin ID
  25. //
  26. const TCHAR szDSAdmin[] = TEXT("{E355E538-1C2E-11D0-8C37-00C04FD8FE93}");
  27. //
  28. // Nodes the GPM extends in DS Admin
  29. //
  30. const LPTSTR szDSAdminNodes[] =
  31. {
  32. TEXT("{19195a5b-6da0-11d0-afd3-00c04fd930c9}"), // Domain
  33. TEXT("{bf967aa5-0de6-11d0-a285-00aa003049e2}"), // Organizational unit
  34. };
  35. //
  36. // Site Manager's snapin ID
  37. //
  38. const TCHAR szSiteMgr[] = TEXT("{D967F824-9968-11D0-B936-00C04FD8D5B0}");
  39. //
  40. // Nodes the GPM extends in DS Admin
  41. //
  42. const LPTSTR szSiteMgrNodes[] =
  43. {
  44. TEXT("{bf967ab3-0de6-11d0-a285-00aa003049e2}") // Site
  45. };
  46. const LPTSTR szDSTreeSnapinNodes[] =
  47. {
  48. TEXT("{4c06495e-a241-11d0-b09b-00c04fd8dca6}") // Forest
  49. };
  50. const LPTSTR szDSAdminRsopTargetNodes[] =
  51. {
  52. TEXT("{bf967aba-0de6-11d0-a285-00aa003049e2}"), // user
  53. TEXT("{bf967a86-0de6-11d0-a285-00aa003049e2}") // comp
  54. };
  55. //
  56. // Help topic commands
  57. //
  58. const TCHAR g_szGPERoot[] = TEXT("gpedit.chm::/gpe_default.htm");
  59. const TCHAR g_szUser[] = TEXT("gpedit.chm::/user.htm");
  60. const TCHAR g_szMachine[] = TEXT("gpedit.chm::/machine.htm");
  61. const TCHAR g_szWindows[] = TEXT("gpedit.chm::/windows.htm");
  62. const TCHAR g_szSoftware[] = TEXT("gpedit.chm::/software.htm");
  63. //
  64. // Result pane items for the nodes with no result pane items
  65. //
  66. RESULTITEM g_Undefined[] =
  67. {
  68. { 1, 1, 0, 0, {0} }
  69. };
  70. //
  71. // Namespace (scope) items
  72. //
  73. NAMESPACEITEM g_NameSpace[] =
  74. {
  75. { 0, -1, 2, 2, IDS_SNAPIN_NAME, IDS_SNAPIN_DESCRIPT, 2, {0}, 0, g_Undefined, &NODEID_GPERoot, g_szGPERoot }, // GPE Root
  76. { 1, 0, 4, 4, IDS_MACHINE, IDS_MACHINE_DESC, 2, {0}, 0, g_Undefined, &NODEID_MachineRoot, g_szMachine }, // Computer Configuration
  77. { 2, 0, 5, 5, IDS_USER, IDS_USER_DESC, 2, {0}, 0, g_Undefined, &NODEID_UserRoot, g_szUser }, // User Configuration
  78. { 3, 1, 0, 1, IDS_SWSETTINGS, IDS_C_SWSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_MachineSWSettings, g_szSoftware }, // Computer Configuration\Software Settings
  79. { 4, 1, 0, 1, IDS_WINSETTINGS, IDS_C_WINSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_Machine, g_szWindows }, // Computer Configuration\Windows Settings
  80. { 5, 2, 0, 1, IDS_SWSETTINGS, IDS_U_SWSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_UserSWSettings, g_szSoftware }, // User Configuration\Software Settings
  81. { 6, 2, 0, 1, IDS_WINSETTINGS, IDS_U_WINSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_User, g_szWindows }, // User Configuration\Windows Settings
  82. };
  83. NAMESPACEITEM g_RsopNameSpace[] =
  84. {
  85. { 0, -1, 2, 2, IDS_RSOP_SNAPIN_NAME, IDS_RSOP_SNAPIN_DESCRIPT, 2, {0}, 0, g_Undefined, &NODEID_RSOPRoot, g_szGPERoot }, // GPE Root
  86. { 1, 0, 4, 4, IDS_MACHINE, IDS_MACHINE_DESC, 2, {0}, 0, g_Undefined, &NODEID_RSOPMachineRoot, g_szMachine }, // Computer Configuration
  87. { 2, 0, 5, 5, IDS_USER, IDS_USER_DESC, 2, {0}, 0, g_Undefined, &NODEID_RSOPUserRoot, g_szUser }, // User Configuration
  88. { 3, 1, 0, 1, IDS_SWSETTINGS, IDS_C_SWSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_RSOPMachineSWSettings, g_szSoftware }, // Computer Configuration\Software Settings
  89. { 4, 1, 0, 1, IDS_WINSETTINGS, IDS_C_WINSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_RSOPMachine, g_szWindows }, // Computer Configuration\Windows Settings
  90. { 5, 2, 0, 1, IDS_SWSETTINGS, IDS_U_SWSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_RSOPUserSWSettings, g_szSoftware }, // User Configuration\Software Settings
  91. { 6, 2, 0, 1, IDS_WINSETTINGS, IDS_U_WINSETTINGS_DESC, 0, {0}, 0, g_Undefined, &NODEID_RSOPUser, g_szWindows }, // User Configuration\Windows Settings
  92. };
  93. BOOL InitNameSpace()
  94. {
  95. DWORD dwIndex;
  96. g_dwNameSpaceItems = ARRAYSIZE(g_NameSpace);
  97. for (dwIndex = 0; dwIndex < g_dwNameSpaceItems; dwIndex++)
  98. {
  99. if (g_NameSpace[dwIndex].iStringID)
  100. {
  101. LoadString (g_hInstance, g_NameSpace[dwIndex].iStringID,
  102. g_NameSpace[dwIndex].szDisplayName,
  103. MAX_DISPLAYNAME_SIZE);
  104. }
  105. }
  106. for (dwIndex = 0; dwIndex < g_dwNameSpaceItems; dwIndex++)
  107. {
  108. if (g_RsopNameSpace[dwIndex].iStringID)
  109. {
  110. LoadString (g_hInstance, g_RsopNameSpace[dwIndex].iStringID,
  111. g_RsopNameSpace[dwIndex].szDisplayName,
  112. MAX_DISPLAYNAME_SIZE);
  113. }
  114. }
  115. return TRUE;
  116. }
  117. /////////////////////////////////////////////////////////////////////////////
  118. // DLL Entry Point
  119. extern "C"
  120. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  121. {
  122. WORD wVersionRequested;
  123. WSADATA wsaData;
  124. if (dwReason == DLL_PROCESS_ATTACH)
  125. {
  126. g_hInstance = hInstance;
  127. DisableThreadLibraryCalls(hInstance);
  128. InitNameSpace();
  129. InitializeCriticalSection(&g_DCCS);
  130. InitDebugSupport();
  131. LoadString (hInstance, IDS_DISPLAYPROPERTIES, g_szDisplayProperties, ARRAYSIZE(g_szDisplayProperties));
  132. wVersionRequested = MAKEWORD( 2, 2 );
  133. // we need to call WSAStartup to do gethostbyname
  134. // Error is handled gracefully. Safe to ignore the error
  135. WSAStartup( wVersionRequested, &wsaData );
  136. }
  137. else if (dwReason == DLL_PROCESS_DETACH)
  138. {
  139. WSACleanup( );
  140. FreeDCSelections();
  141. DeleteCriticalSection(&g_DCCS);
  142. }
  143. return TRUE; // ok
  144. }
  145. /////////////////////////////////////////////////////////////////////////////
  146. // Used to determine whether the DLL can be unloaded by OLE
  147. STDAPI DllCanUnloadNow(void)
  148. {
  149. return (g_cRefThisDll == 0 ? S_OK : S_FALSE);
  150. }
  151. /////////////////////////////////////////////////////////////////////////////
  152. // Returns a class factory to create an object of the requested type
  153. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  154. {
  155. HRESULT hr;
  156. if (IsEqualCLSID (rclsid, CLSID_GPESnapIn)) {
  157. CComponentDataCF *pComponentDataCF = new CComponentDataCF(); // ref == 1
  158. if (!pComponentDataCF)
  159. return E_OUTOFMEMORY;
  160. hr = pComponentDataCF->QueryInterface(riid, ppv);
  161. pComponentDataCF->Release(); // release initial ref
  162. return hr;
  163. }
  164. if (IsEqualCLSID (rclsid, CLSID_GroupPolicyObject)) {
  165. CGroupPolicyObjectCF *pGroupPolicyObjectCF = new CGroupPolicyObjectCF(); // ref == 1
  166. if (!pGroupPolicyObjectCF)
  167. return E_OUTOFMEMORY;
  168. hr = pGroupPolicyObjectCF->QueryInterface(riid, ppv);
  169. pGroupPolicyObjectCF->Release(); // release initial ref
  170. return hr;
  171. }
  172. if (IsEqualCLSID (rclsid, CLSID_GPMSnapIn)) {
  173. CGroupPolicyMgrCF *pGroupPolicyMgrCF = new CGroupPolicyMgrCF(); // ref == 1
  174. if (!pGroupPolicyMgrCF)
  175. return E_OUTOFMEMORY;
  176. hr = pGroupPolicyMgrCF->QueryInterface(riid, ppv);
  177. pGroupPolicyMgrCF->Release(); // release initial ref
  178. return hr;
  179. }
  180. if (IsEqualCLSID (rclsid, CLSID_RSOPSnapIn)) {
  181. CRSOPComponentDataCF *pRSOPComponentDataCF = new CRSOPComponentDataCF(); // ref == 1
  182. if (!pRSOPComponentDataCF)
  183. return E_OUTOFMEMORY;
  184. hr = pRSOPComponentDataCF->QueryInterface(riid, ppv);
  185. pRSOPComponentDataCF->Release(); // release initial ref
  186. return hr;
  187. }
  188. if (IsEqualCLSID (rclsid, CLSID_AboutGPE)) {
  189. CAboutGPECF *pAboutGPECF = new CAboutGPECF(); // ref == 1
  190. if (!pAboutGPECF)
  191. return E_OUTOFMEMORY;
  192. hr = pAboutGPECF->QueryInterface(riid, ppv);
  193. pAboutGPECF->Release(); // release initial ref
  194. return hr;
  195. }
  196. if (IsEqualCLSID (rclsid, CLSID_RSOPAboutGPE)) {
  197. CAboutGPECF *pAboutGPECF = new CAboutGPECF(TRUE); // ref == 1
  198. if (!pAboutGPECF)
  199. return E_OUTOFMEMORY;
  200. hr = pAboutGPECF->QueryInterface(riid, ppv);
  201. pAboutGPECF->Release(); // release initial ref
  202. return hr;
  203. }
  204. if (IsEqualCLSID (rclsid, CLSID_RSOP_CMenu)) {
  205. CRSOPCMenuCF *pRSOPCMenuCF = new CRSOPCMenuCF(); // ref == 1
  206. if (!pRSOPCMenuCF)
  207. return E_OUTOFMEMORY;
  208. hr = pRSOPCMenuCF->QueryInterface(riid, ppv);
  209. pRSOPCMenuCF->Release(); // release initial ref
  210. return hr;
  211. }
  212. return CLASS_E_CLASSNOTAVAILABLE;
  213. }
  214. /////////////////////////////////////////////////////////////////////////////
  215. // DllRegisterServer - Adds entries to the system registry
  216. const TCHAR szDLLLocation[] = TEXT("%SystemRoot%\\System32\\GPEdit.dll");
  217. const TCHAR szThreadingModel[] = TEXT("Apartment");
  218. const TCHAR szSnapInNameIndirect[] = TEXT("@gpedit.dll,-1");
  219. const TCHAR szRsopSnapInNameIndirect[] = TEXT("@gpedit.dll,-4");
  220. const TCHAR szViewDescript [] = TEXT("MMCViewExt 1.0 Object");
  221. const TCHAR szViewGUID [] = TEXT("{B708457E-DB61-4C55-A92F-0D4B5E9B1224}");
  222. const TCHAR szDefRsopMscLocation [] = TEXT("%systemroot%\\system32\\rsop.msc");
  223. STDAPI DllRegisterServer(void)
  224. {
  225. TCHAR szSubKey[200];
  226. TCHAR szSnapInName[100];
  227. TCHAR szSnapInKey[50];
  228. TCHAR szRsopSnapInKey[50];
  229. TCHAR szRsopSnapInName[100];
  230. TCHAR szRsopName[100];
  231. TCHAR szRsopGUID[50];
  232. TCHAR szName[100];
  233. TCHAR szGUID[50];
  234. DWORD dwDisp, dwIndex;
  235. LONG lResult;
  236. HKEY hKey;
  237. INT i;
  238. //
  239. // Register GPE SnapIn in HKEY_CLASSES_ROOT
  240. //
  241. StringFromGUID2 (CLSID_GPESnapIn, szSnapInKey, 50);
  242. LoadString (g_hInstance, IDS_SNAPIN_NAME, szSnapInName, 100);
  243. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  244. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  245. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  246. &hKey, &dwDisp);
  247. if (lResult != ERROR_SUCCESS) {
  248. return SELFREG_E_CLASS;
  249. }
  250. RegSetValueEx (hKey, NULL, 0, REG_SZ, (LPBYTE)szSnapInName,
  251. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  252. RegCloseKey (hKey);
  253. wsprintf (szSubKey, TEXT("CLSID\\%s\\InProcServer32"), szSnapInKey);
  254. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  255. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  256. &hKey, &dwDisp);
  257. if (lResult != ERROR_SUCCESS) {
  258. return SELFREG_E_CLASS;
  259. }
  260. RegSetValueEx (hKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)szDLLLocation,
  261. (lstrlen(szDLLLocation) + 1) * sizeof(TCHAR));
  262. RegSetValueEx (hKey, TEXT("ThreadingModel"), 0, REG_SZ, (LPBYTE)szThreadingModel,
  263. (lstrlen(szThreadingModel) + 1) * sizeof(TCHAR));
  264. RegCloseKey (hKey);
  265. //
  266. // Register RSOP SnapIn in HKEY_CLASSES_ROOT
  267. //
  268. StringFromGUID2 (CLSID_RSOPSnapIn, szRsopSnapInKey, 50);
  269. LoadString (g_hInstance, IDS_RSOP_SNAPIN_NAME, szRsopSnapInName, 100);
  270. wsprintf (szSubKey, TEXT("CLSID\\%s"), szRsopSnapInKey);
  271. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  272. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  273. &hKey, &dwDisp);
  274. if (lResult != ERROR_SUCCESS) {
  275. return SELFREG_E_CLASS;
  276. }
  277. RegSetValueEx (hKey, NULL, 0, REG_SZ, (LPBYTE)szRsopSnapInName,
  278. (lstrlen(szRsopSnapInName) + 1) * sizeof(TCHAR));
  279. RegCloseKey (hKey);
  280. wsprintf (szSubKey, TEXT("CLSID\\%s\\InProcServer32"), szRsopSnapInKey);
  281. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  282. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  283. &hKey, &dwDisp);
  284. if (lResult != ERROR_SUCCESS) {
  285. return SELFREG_E_CLASS;
  286. }
  287. RegSetValueEx (hKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)szDLLLocation,
  288. (lstrlen(szDLLLocation) + 1) * sizeof(TCHAR));
  289. RegSetValueEx (hKey, TEXT("ThreadingModel"), 0, REG_SZ, (LPBYTE)szThreadingModel,
  290. (lstrlen(szThreadingModel) + 1) * sizeof(TCHAR));
  291. RegCloseKey (hKey);
  292. //
  293. // Register GPO in HKEY_CLASSES_ROOT
  294. //
  295. StringFromGUID2 (CLSID_GroupPolicyObject, szGUID, 50);
  296. LoadString (g_hInstance, IDS_GPO_NAME, szName, 100);
  297. wsprintf (szSubKey, TEXT("CLSID\\%s"), szGUID);
  298. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  299. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  300. &hKey, &dwDisp);
  301. if (lResult != ERROR_SUCCESS) {
  302. return SELFREG_E_CLASS;
  303. }
  304. RegSetValueEx (hKey, NULL, 0, REG_SZ, (LPBYTE)szName,
  305. (lstrlen(szName) + 1) * sizeof(TCHAR));
  306. RegCloseKey (hKey);
  307. wsprintf (szSubKey, TEXT("CLSID\\%s\\InProcServer32"), szGUID);
  308. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  309. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  310. &hKey, &dwDisp);
  311. if (lResult != ERROR_SUCCESS) {
  312. return SELFREG_E_CLASS;
  313. }
  314. RegSetValueEx (hKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)szDLLLocation,
  315. (lstrlen(szDLLLocation) + 1) * sizeof(TCHAR));
  316. RegSetValueEx (hKey, TEXT("ThreadingModel"), 0, REG_SZ, (LPBYTE)szThreadingModel,
  317. (lstrlen(szThreadingModel) + 1) * sizeof(TCHAR));
  318. RegCloseKey (hKey);
  319. //
  320. // Register AboutGPE in HKEY_CLASSES_ROOT
  321. //
  322. StringFromGUID2 (CLSID_AboutGPE, szGUID, 50);
  323. LoadString (g_hInstance, IDS_ABOUT_NAME, szName, 100);
  324. wsprintf (szSubKey, TEXT("CLSID\\%s"), szGUID);
  325. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  326. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  327. &hKey, &dwDisp);
  328. if (lResult != ERROR_SUCCESS) {
  329. return SELFREG_E_CLASS;
  330. }
  331. RegSetValueEx (hKey, NULL, 0, REG_SZ, (LPBYTE)szName,
  332. (lstrlen(szName) + 1) * sizeof(TCHAR));
  333. RegCloseKey (hKey);
  334. wsprintf (szSubKey, TEXT("CLSID\\%s\\InProcServer32"), szGUID);
  335. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  336. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  337. &hKey, &dwDisp);
  338. if (lResult != ERROR_SUCCESS) {
  339. return SELFREG_E_CLASS;
  340. }
  341. RegSetValueEx (hKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)szDLLLocation,
  342. (lstrlen(szDLLLocation) + 1) * sizeof(TCHAR));
  343. RegSetValueEx (hKey, TEXT("ThreadingModel"), 0, REG_SZ, (LPBYTE)szThreadingModel,
  344. (lstrlen(szThreadingModel) + 1) * sizeof(TCHAR));
  345. RegCloseKey (hKey);
  346. //
  347. // Register RSOPAboutGPE in HKEY_CLASSES_ROOT
  348. //
  349. StringFromGUID2 (CLSID_RSOPAboutGPE, szGUID, 50);
  350. LoadString (g_hInstance, IDS_ABOUT_NAME, szName, 100);
  351. wsprintf (szSubKey, TEXT("CLSID\\%s"), szGUID);
  352. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  353. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  354. &hKey, &dwDisp);
  355. if (lResult != ERROR_SUCCESS) {
  356. return SELFREG_E_CLASS;
  357. }
  358. RegSetValueEx (hKey, NULL, 0, REG_SZ, (LPBYTE)szName,
  359. (lstrlen(szName) + 1) * sizeof(TCHAR));
  360. RegCloseKey (hKey);
  361. wsprintf (szSubKey, TEXT("CLSID\\%s\\InProcServer32"), szGUID);
  362. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  363. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  364. &hKey, &dwDisp);
  365. if (lResult != ERROR_SUCCESS) {
  366. return SELFREG_E_CLASS;
  367. }
  368. RegSetValueEx (hKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)szDLLLocation,
  369. (lstrlen(szDLLLocation) + 1) * sizeof(TCHAR));
  370. RegSetValueEx (hKey, TEXT("ThreadingModel"), 0, REG_SZ, (LPBYTE)szThreadingModel,
  371. (lstrlen(szThreadingModel) + 1) * sizeof(TCHAR));
  372. RegCloseKey (hKey);
  373. //
  374. // Register GPE SnapIn with MMC
  375. //
  376. StringFromGUID2 (CLSID_GPESnapIn, szSnapInKey, 50);
  377. LoadString (g_hInstance, IDS_SNAPIN_NAME, szSnapInName, 100);
  378. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szSnapInKey);
  379. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  380. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  381. &hKey, &dwDisp);
  382. if (lResult != ERROR_SUCCESS) {
  383. return SELFREG_E_CLASS;
  384. }
  385. RegSetValueEx (hKey, TEXT("NameString"), 0, REG_SZ, (LPBYTE)szSnapInName,
  386. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  387. RegSetValueEx (hKey, TEXT("NameStringIndirect"), 0, REG_SZ, (LPBYTE)szSnapInNameIndirect,
  388. (lstrlen(szSnapInNameIndirect) + 1) * sizeof(TCHAR));
  389. StringFromGUID2 (CLSID_AboutGPE, szGUID, 50);
  390. RegSetValueEx (hKey, TEXT("About"), 0, REG_SZ, (LPBYTE) szGUID,
  391. (lstrlen(szGUID) + 1) * sizeof(TCHAR));
  392. RegCloseKey (hKey);
  393. for (dwIndex = 0; dwIndex < g_dwNameSpaceItems; dwIndex++)
  394. {
  395. StringFromGUID2 (*g_NameSpace[dwIndex].pNodeID, szGUID, 50);
  396. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"),
  397. szSnapInKey, szGUID);
  398. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  399. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  400. &hKey, &dwDisp);
  401. if (lResult != ERROR_SUCCESS) {
  402. return SELFREG_E_CLASS;
  403. }
  404. RegCloseKey (hKey);
  405. }
  406. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\StandAlone"), szSnapInKey);
  407. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  408. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  409. &hKey, &dwDisp);
  410. if (lResult != ERROR_SUCCESS) {
  411. return SELFREG_E_CLASS;
  412. }
  413. RegCloseKey (hKey);
  414. //
  415. // Register RSOP SnapIn with MMC
  416. //
  417. StringFromGUID2 (CLSID_RSOPSnapIn, szRsopSnapInKey, 50);
  418. LoadString (g_hInstance, IDS_RSOP_SNAPIN_NAME, szRsopSnapInName, 100);
  419. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szRsopSnapInKey);
  420. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  421. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  422. &hKey, &dwDisp);
  423. if (lResult != ERROR_SUCCESS) {
  424. return SELFREG_E_CLASS;
  425. }
  426. RegSetValueEx (hKey, TEXT("NameString"), 0, REG_SZ, (LPBYTE)szRsopSnapInName,
  427. (lstrlen(szRsopSnapInName) + 1) * sizeof(TCHAR));
  428. RegSetValueEx (hKey, TEXT("NameStringIndirect"), 0, REG_SZ, (LPBYTE)szRsopSnapInNameIndirect,
  429. (lstrlen(szRsopSnapInNameIndirect) + 1) * sizeof(TCHAR));
  430. StringFromGUID2 (CLSID_RSOPAboutGPE, szGUID, 50);
  431. RegSetValueEx (hKey, TEXT("About"), 0, REG_SZ, (LPBYTE) szGUID,
  432. (lstrlen(szGUID) + 1) * sizeof(TCHAR));
  433. RegCloseKey (hKey);
  434. for (dwIndex = 0; dwIndex < g_dwNameSpaceItems; dwIndex++)
  435. {
  436. StringFromGUID2 (*g_RsopNameSpace[dwIndex].pNodeID, szGUID, 50);
  437. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"),
  438. szRsopSnapInKey, szGUID);
  439. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  440. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  441. &hKey, &dwDisp);
  442. if (lResult != ERROR_SUCCESS) {
  443. return SELFREG_E_CLASS;
  444. }
  445. RegCloseKey (hKey);
  446. }
  447. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\StandAlone"), szRsopSnapInKey);
  448. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  449. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  450. &hKey, &dwDisp);
  451. if (lResult != ERROR_SUCCESS) {
  452. return SELFREG_E_CLASS;
  453. }
  454. RegCloseKey (hKey);
  455. //
  456. // Register in the NodeTypes key and register for the view extension
  457. //
  458. for (dwIndex = 0; dwIndex < g_dwNameSpaceItems; dwIndex++)
  459. {
  460. StringFromGUID2 (*g_NameSpace[dwIndex].pNodeID, szGUID, 50);
  461. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\View"), szGUID);
  462. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  463. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  464. &hKey, &dwDisp);
  465. if (lResult != ERROR_SUCCESS) {
  466. return SELFREG_E_CLASS;
  467. }
  468. RegSetValueEx (hKey, szViewGUID, 0, REG_SZ, (LPBYTE)szViewDescript,
  469. (lstrlen(szViewDescript) + 1) * sizeof(TCHAR));
  470. RegCloseKey (hKey);
  471. StringFromGUID2 (*g_RsopNameSpace[dwIndex].pNodeID, szGUID, 50);
  472. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\View"), szGUID);
  473. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  474. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  475. &hKey, &dwDisp);
  476. if (lResult != ERROR_SUCCESS) {
  477. return SELFREG_E_CLASS;
  478. }
  479. RegSetValueEx (hKey, szViewGUID, 0, REG_SZ, (LPBYTE)szViewDescript,
  480. (lstrlen(szViewDescript) + 1) * sizeof(TCHAR));
  481. RegCloseKey (hKey);
  482. }
  483. //
  484. // Register GPM SnapIn in HKEY_CLASSES_ROOT
  485. //
  486. StringFromGUID2 (CLSID_GPMSnapIn, szSnapInKey, 50);
  487. LoadString (g_hInstance, IDS_GPM_SNAPIN_NAME, szSnapInName, 100);
  488. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  489. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  490. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  491. &hKey, &dwDisp);
  492. if (lResult != ERROR_SUCCESS) {
  493. return SELFREG_E_CLASS;
  494. }
  495. RegSetValueEx (hKey, NULL, 0, REG_SZ, (LPBYTE)szSnapInName,
  496. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  497. RegCloseKey (hKey);
  498. wsprintf (szSubKey, TEXT("CLSID\\%s\\InProcServer32"), szSnapInKey);
  499. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  500. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  501. &hKey, &dwDisp);
  502. if (lResult != ERROR_SUCCESS) {
  503. return SELFREG_E_CLASS;
  504. }
  505. RegSetValueEx (hKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)szDLLLocation,
  506. (lstrlen(szDLLLocation) + 1) * sizeof(TCHAR));
  507. RegSetValueEx (hKey, TEXT("ThreadingModel"), 0, REG_SZ, (LPBYTE)szThreadingModel,
  508. (lstrlen(szThreadingModel) + 1) * sizeof(TCHAR));
  509. RegCloseKey (hKey);
  510. //
  511. // Register GPMSnapIn with MMC
  512. //
  513. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szSnapInKey);
  514. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  515. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  516. &hKey, &dwDisp);
  517. if (lResult != ERROR_SUCCESS) {
  518. return SELFREG_E_CLASS;
  519. }
  520. RegSetValueEx (hKey, TEXT("NameString"), 0, REG_SZ, (LPBYTE)szSnapInName,
  521. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  522. RegSetValueEx (hKey, TEXT("NameStringIndirect"), 0, REG_SZ, (LPBYTE)szSnapInNameIndirect,
  523. (lstrlen(szSnapInNameIndirect) + 1) * sizeof(TCHAR));
  524. RegCloseKey (hKey);
  525. //
  526. // Register as a DS admin property sheet extension
  527. //
  528. for (i=0; i < ARRAYSIZE(szDSAdminNodes); i++)
  529. {
  530. lstrcpy (szGUID, szDSAdminNodes[i]);
  531. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"), szDSAdmin, szGUID);
  532. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  533. szSubKey,
  534. 0, NULL,
  535. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  536. &hKey, &dwDisp);
  537. if (lResult != ERROR_SUCCESS) {
  538. return SELFREG_E_CLASS;
  539. }
  540. RegCloseKey (hKey);
  541. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\PropertySheet"), szGUID);
  542. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  543. szSubKey,
  544. 0, NULL,
  545. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  546. &hKey, &dwDisp);
  547. if (lResult != ERROR_SUCCESS) {
  548. return SELFREG_E_CLASS;
  549. }
  550. RegSetValueEx (hKey, szSnapInKey, 0, REG_SZ, (LPBYTE)szSnapInName,
  551. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  552. RegCloseKey (hKey);
  553. }
  554. //
  555. // Register as a site mgr property sheet extension
  556. //
  557. for (i=0; i < ARRAYSIZE(szSiteMgrNodes); i++)
  558. {
  559. lstrcpy (szGUID, szSiteMgrNodes[i]);
  560. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"), szSiteMgr, szGUID);
  561. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  562. szSubKey,
  563. 0, NULL,
  564. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  565. &hKey, &dwDisp);
  566. if (lResult != ERROR_SUCCESS) {
  567. return SELFREG_E_CLASS;
  568. }
  569. RegCloseKey (hKey);
  570. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\PropertySheet"), szGUID);
  571. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  572. szSubKey,
  573. 0, NULL,
  574. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  575. &hKey, &dwDisp);
  576. if (lResult != ERROR_SUCCESS) {
  577. return SELFREG_E_CLASS;
  578. }
  579. RegSetValueEx (hKey, szSnapInKey, 0, REG_SZ, (LPBYTE)szSnapInName,
  580. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  581. RegCloseKey (hKey);
  582. }
  583. //
  584. // Register RSOP Context Menu in HKEY_CLASSES_ROOT
  585. //
  586. StringFromGUID2 (CLSID_RSOP_CMenu, szSnapInKey, 50);
  587. LoadString (g_hInstance, IDS_RSOP_CMENU_NAME, szSnapInName, 100);
  588. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  589. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  590. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  591. &hKey, &dwDisp);
  592. if (lResult != ERROR_SUCCESS) {
  593. return SELFREG_E_CLASS;
  594. }
  595. RegSetValueEx (hKey, NULL, 0, REG_SZ, (LPBYTE)szSnapInName,
  596. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  597. RegCloseKey (hKey);
  598. wsprintf (szSubKey, TEXT("CLSID\\%s\\InProcServer32"), szSnapInKey);
  599. lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey, 0, NULL,
  600. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  601. &hKey, &dwDisp);
  602. if (lResult != ERROR_SUCCESS) {
  603. return SELFREG_E_CLASS;
  604. }
  605. RegSetValueEx (hKey, NULL, 0, REG_EXPAND_SZ, (LPBYTE)szDLLLocation,
  606. (lstrlen(szDLLLocation) + 1) * sizeof(TCHAR));
  607. RegSetValueEx (hKey, TEXT("ThreadingModel"), 0, REG_SZ, (LPBYTE)szThreadingModel,
  608. (lstrlen(szThreadingModel) + 1) * sizeof(TCHAR));
  609. RegCloseKey (hKey);
  610. //
  611. // Register RSOP Context Menu with MMC.
  612. // !!!!! Check whether this is necessary
  613. //
  614. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szSnapInKey);
  615. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE, szSubKey, 0, NULL,
  616. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  617. &hKey, &dwDisp);
  618. if (lResult != ERROR_SUCCESS) {
  619. return SELFREG_E_CLASS;
  620. }
  621. RegSetValueEx (hKey, TEXT("NameString"), 0, REG_SZ, (LPBYTE)szSnapInName,
  622. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  623. RegSetValueEx (hKey, TEXT("NameStringIndirect"), 0, REG_SZ, (LPBYTE)szSnapInNameIndirect,
  624. (lstrlen(szSnapInNameIndirect) + 1) * sizeof(TCHAR));
  625. RegCloseKey (hKey);
  626. //
  627. // Register as a DS admin task menu extension
  628. //
  629. for (i=0; i < ARRAYSIZE(szDSAdminNodes); i++)
  630. {
  631. lstrcpy (szGUID, szDSAdminNodes[i]);
  632. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"), szDSAdmin, szGUID);
  633. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  634. szSubKey,
  635. 0, NULL,
  636. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  637. &hKey, &dwDisp);
  638. if (lResult != ERROR_SUCCESS) {
  639. return SELFREG_E_CLASS;
  640. }
  641. RegCloseKey (hKey);
  642. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\ContextMenu"), szGUID);
  643. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  644. szSubKey,
  645. 0, NULL,
  646. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  647. &hKey, &dwDisp);
  648. if (lResult != ERROR_SUCCESS) {
  649. return SELFREG_E_CLASS;
  650. }
  651. RegSetValueEx (hKey, szSnapInKey, 0, REG_SZ, (LPBYTE)szSnapInName,
  652. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  653. RegCloseKey (hKey);
  654. }
  655. //
  656. // Register as a DS admin rsop target task menu extension
  657. //
  658. for (i=0; i < ARRAYSIZE(szDSAdminRsopTargetNodes); i++)
  659. {
  660. lstrcpy (szGUID, szDSAdminRsopTargetNodes[i]);
  661. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"), szDSAdmin, szGUID);
  662. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  663. szSubKey,
  664. 0, NULL,
  665. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  666. &hKey, &dwDisp);
  667. if (lResult != ERROR_SUCCESS) {
  668. return SELFREG_E_CLASS;
  669. }
  670. RegCloseKey (hKey);
  671. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\ContextMenu"), szGUID);
  672. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  673. szSubKey,
  674. 0, NULL,
  675. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  676. &hKey, &dwDisp);
  677. if (lResult != ERROR_SUCCESS) {
  678. return SELFREG_E_CLASS;
  679. }
  680. RegSetValueEx (hKey, szSnapInKey, 0, REG_SZ, (LPBYTE)szSnapInName,
  681. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  682. RegCloseKey (hKey);
  683. }
  684. //
  685. // Register as a site mgr task menu extension
  686. //
  687. for (i=0; i < ARRAYSIZE(szSiteMgrNodes); i++)
  688. {
  689. lstrcpy (szGUID, szSiteMgrNodes[i]);
  690. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"), szSiteMgr, szGUID);
  691. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  692. szSubKey,
  693. 0, NULL,
  694. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  695. &hKey, &dwDisp);
  696. if (lResult != ERROR_SUCCESS) {
  697. return SELFREG_E_CLASS;
  698. }
  699. RegCloseKey (hKey);
  700. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\ContextMenu"), szGUID);
  701. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  702. szSubKey,
  703. 0, NULL,
  704. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  705. &hKey, &dwDisp);
  706. if (lResult != ERROR_SUCCESS) {
  707. return SELFREG_E_CLASS;
  708. }
  709. RegSetValueEx (hKey, szSnapInKey, 0, REG_SZ, (LPBYTE)szSnapInName,
  710. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  711. RegCloseKey (hKey);
  712. }
  713. //
  714. // Mark the authormode rsop.msc as read only
  715. //
  716. TCHAR szRsopMscFileName[MAX_PATH+1];
  717. if (ExpandEnvironmentStrings(szDefRsopMscLocation, szRsopMscFileName, MAX_PATH+1)) {
  718. SetFileAttributes(szRsopMscFileName, FILE_ATTRIBUTE_READONLY);
  719. }
  720. else {
  721. DebugMsg((DM_WARNING, TEXT("DllRegisterServer: ExpandEnvironmentStrings failed with error %d"), GetLastError()));
  722. }
  723. #if FGPO_SUPPORT
  724. // register as a DSTree snapin property sheet extension
  725. for (i=0; i < ARRAYSIZE(szDSTreeSnapinNodes); i++)
  726. {
  727. lstrcpy (szGUID, szDSTreeSnapinNodes[i]);
  728. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s\\NodeTypes\\%s"), szSiteMgr, szGUID);
  729. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  730. szSubKey,
  731. 0, NULL,
  732. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  733. &hKey, &dwDisp);
  734. if (lResult != ERROR_SUCCESS) {
  735. return SELFREG_E_CLASS;
  736. }
  737. RegCloseKey (hKey);
  738. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\PropertySheet"), szGUID);
  739. lResult = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  740. szSubKey,
  741. 0, NULL,
  742. REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
  743. &hKey, &dwDisp);
  744. if (lResult != ERROR_SUCCESS) {
  745. return SELFREG_E_CLASS;
  746. }
  747. RegSetValueEx (hKey, szSnapInKey, 0, REG_SZ, (LPBYTE)szSnapInName,
  748. (lstrlen(szSnapInName) + 1) * sizeof(TCHAR));
  749. RegCloseKey (hKey);
  750. }
  751. #else
  752. for (i=0; i < ARRAYSIZE(szDSTreeSnapinNodes); i++)
  753. {
  754. lstrcpy (szGUID, szDSTreeSnapinNodes[i]);
  755. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\PropertySheet"), szGUID);
  756. lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  757. szSubKey,
  758. 0,
  759. KEY_WRITE, &hKey);
  760. if (lResult == ERROR_SUCCESS) {
  761. RegDeleteValue (hKey, szSnapInKey);
  762. RegCloseKey (hKey);
  763. }
  764. }
  765. #endif
  766. return S_OK;
  767. }
  768. /////////////////////////////////////////////////////////////////////////////
  769. // DllUnregisterServer - Removes entries from the system registry
  770. STDAPI DllUnregisterServer(void)
  771. {
  772. TCHAR szSubKey[200];
  773. TCHAR szGUID[50];
  774. TCHAR szSnapInKey[50];
  775. DWORD dwIndex;
  776. LONG lResult;
  777. INT i;
  778. HKEY hKey;
  779. //
  780. // Unregister GPE
  781. //
  782. StringFromGUID2 (CLSID_GPESnapIn, szSnapInKey, 50);
  783. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  784. RegDelnode (HKEY_CLASSES_ROOT, szSubKey);
  785. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szSnapInKey);
  786. RegDelnode (HKEY_LOCAL_MACHINE, szSubKey);
  787. for (dwIndex = 0; dwIndex < g_dwNameSpaceItems; dwIndex++)
  788. {
  789. StringFromGUID2 (*g_NameSpace[dwIndex].pNodeID, szSnapInKey, 50);
  790. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s"), szSnapInKey);
  791. RegDelnode (HKEY_LOCAL_MACHINE, szSubKey);
  792. }
  793. //
  794. // Unregister RSOP
  795. //
  796. StringFromGUID2 (CLSID_RSOPSnapIn, szSnapInKey, 50);
  797. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  798. RegDelnode (HKEY_CLASSES_ROOT, szSubKey);
  799. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szSnapInKey);
  800. RegDelnode (HKEY_LOCAL_MACHINE, szSubKey);
  801. for (dwIndex = 0; dwIndex < g_dwNameSpaceItems; dwIndex++)
  802. {
  803. StringFromGUID2 (*g_RsopNameSpace[dwIndex].pNodeID, szSnapInKey, 50); // undone
  804. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s"), szSnapInKey);
  805. RegDelnode (HKEY_LOCAL_MACHINE, szSubKey);
  806. }
  807. //
  808. // Unregister GPO
  809. //
  810. StringFromGUID2 (CLSID_GroupPolicyObject, szSnapInKey, 50);
  811. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  812. RegDelnode (HKEY_CLASSES_ROOT, szSubKey);
  813. //
  814. // Unregister AboutGPE
  815. //
  816. StringFromGUID2 (CLSID_AboutGPE, szSnapInKey, 50);
  817. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  818. RegDelnode (HKEY_CLASSES_ROOT, szSubKey);
  819. //
  820. // Unregister RSOPAboutGPE
  821. //
  822. StringFromGUID2 (CLSID_RSOPAboutGPE, szSnapInKey, 50);
  823. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  824. RegDelnode (HKEY_CLASSES_ROOT, szSubKey);
  825. //
  826. // Unregister GPM
  827. //
  828. StringFromGUID2 (CLSID_GPMSnapIn, szSnapInKey, 50);
  829. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  830. RegDelnode (HKEY_CLASSES_ROOT, szSubKey);
  831. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szSnapInKey);
  832. RegDelnode (HKEY_LOCAL_MACHINE, szSubKey);
  833. for (i=0; i < ARRAYSIZE(szDSAdminNodes); i++)
  834. {
  835. lstrcpy (szGUID, szDSAdminNodes[i]);
  836. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\PropertySheet"), szGUID);
  837. lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  838. szSubKey,
  839. 0,
  840. KEY_WRITE, &hKey);
  841. if (lResult == ERROR_SUCCESS) {
  842. RegDeleteValue (hKey, szSnapInKey);
  843. RegCloseKey (hKey);
  844. }
  845. }
  846. for (i=0; i < ARRAYSIZE(szSiteMgrNodes); i++)
  847. {
  848. lstrcpy (szGUID, szSiteMgrNodes[i]);
  849. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\PropertySheet"), szGUID);
  850. lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  851. szSubKey,
  852. 0,
  853. KEY_WRITE, &hKey);
  854. if (lResult == ERROR_SUCCESS) {
  855. RegDeleteValue (hKey, szSnapInKey);
  856. RegCloseKey (hKey);
  857. }
  858. }
  859. //
  860. // Unregister rsop context menu
  861. //
  862. StringFromGUID2 (CLSID_RSOP_CMenu, szSnapInKey, 50);
  863. wsprintf (szSubKey, TEXT("CLSID\\%s"), szSnapInKey);
  864. RegDelnode (HKEY_CLASSES_ROOT, szSubKey);
  865. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\SnapIns\\%s"), szSnapInKey);
  866. RegDelnode (HKEY_LOCAL_MACHINE, szSubKey);
  867. //
  868. // from ds admin nodes
  869. //
  870. for (i=0; i < ARRAYSIZE(szDSAdminNodes); i++)
  871. {
  872. lstrcpy (szGUID, szDSAdminNodes[i]);
  873. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\ContextMenu"), szGUID);
  874. lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  875. szSubKey,
  876. 0,
  877. KEY_WRITE, &hKey);
  878. if (lResult == ERROR_SUCCESS) {
  879. RegDeleteValue (hKey, szSnapInKey);
  880. RegCloseKey (hKey);
  881. }
  882. }
  883. for (i=0; i < ARRAYSIZE(szDSAdminRsopTargetNodes); i++)
  884. {
  885. lstrcpy (szGUID, szDSAdminRsopTargetNodes[i]);
  886. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\ContextMenu"), szGUID);
  887. lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  888. szSubKey,
  889. 0,
  890. KEY_WRITE, &hKey);
  891. if (lResult == ERROR_SUCCESS) {
  892. RegDeleteValue (hKey, szSnapInKey);
  893. RegCloseKey (hKey);
  894. }
  895. }
  896. //
  897. // from sites node
  898. //
  899. for (i=0; i < ARRAYSIZE(szSiteMgrNodes); i++)
  900. {
  901. lstrcpy (szGUID, szSiteMgrNodes[i]);
  902. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\ContextMenu"), szGUID);
  903. lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  904. szSubKey,
  905. 0,
  906. KEY_WRITE, &hKey);
  907. if (lResult == ERROR_SUCCESS) {
  908. RegDeleteValue (hKey, szSnapInKey);
  909. RegCloseKey (hKey);
  910. }
  911. }
  912. for (i=0; i < ARRAYSIZE(szDSTreeSnapinNodes); i++)
  913. {
  914. lstrcpy (szGUID, szDSTreeSnapinNodes[i]);
  915. wsprintf (szSubKey, TEXT("Software\\Microsoft\\MMC\\NodeTypes\\%s\\Extensions\\PropertySheet"), szGUID);
  916. lResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  917. szSubKey,
  918. 0,
  919. KEY_WRITE, &hKey);
  920. if (lResult == ERROR_SUCCESS) {
  921. RegDeleteValue (hKey, szSnapInKey);
  922. RegCloseKey (hKey);
  923. }
  924. }
  925. return S_OK;
  926. }