Leaked source code of windows server 2003
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.

681 lines
19 KiB

  1. /************************************************************************
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name :
  4. registry.cpp
  5. Abstract :
  6. Handles registering and unregistering the snapin.
  7. Author :
  8. Revision History :
  9. ***********************************************************************/
  10. #include "precomp.h"
  11. #include "sddl.h"
  12. // if not standalone comment out next line
  13. //#define STANDALONE
  14. // list all nodes that are extendable here
  15. // List the GUID and then the description
  16. // terminate with a NULL, NULL set.
  17. EXTENSION_NODE _ExtendableNodes[] = {
  18. {NULL, NULL}
  19. };
  20. // list all of the nodes that we extend
  21. EXTENDER_NODE _NodeExtensions[] = {
  22. // IIS instance node
  23. {PropertySheetExtension,
  24. {0xa841b6c7, 0x7577, 0x11d0, {0xbb, 0x1f, 0x00, 0xa0, 0xc9, 0x22, 0xe7, 0x9c}}, //g_IISInstanceNode,
  25. {0x4589a47e, 0x6ec1, 0x4476, {0xba, 0x77, 0xcc, 0x9d, 0xd1, 0x12, 0x59, 0x33}},
  26. _T("BITS server MMC extension")},
  27. // IIS child node
  28. {PropertySheetExtension,
  29. {0xa841b6c8, 0x7577, 0x11d0, {0xbb, 0x1f, 0x00, 0xa0, 0xc9, 0x22, 0xe7, 0x9c}}, // g_IISChildNode,
  30. {0x4589a47e, 0x6ec1, 0x4476, {0xba, 0x77, 0xcc, 0x9d, 0xd1, 0x12, 0x59, 0x33}},
  31. _T("BITS server MMC extension")},
  32. {DummyExtension,
  33. NULL,
  34. NULL,
  35. NULL}
  36. };
  37. ////////////////////////////////////////////////////////
  38. //
  39. // Internal helper functions prototypes
  40. //
  41. // Set the given key and its value.
  42. BOOL setKeyAndValue(const _TCHAR* pszPath,
  43. const _TCHAR* szSubkey,
  44. const _TCHAR* szValue) ;
  45. // Set the given key and its value in the MMC Snapin location
  46. BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
  47. const _TCHAR* szSubkey,
  48. const _TCHAR* szName,
  49. const _TCHAR* szValue);
  50. // Set the given valuename under the key to value
  51. BOOL setValue(const _TCHAR* szKey,
  52. const _TCHAR* szValueName,
  53. const _TCHAR* szValue);
  54. BOOL setBinaryValue(
  55. const _TCHAR* szKey,
  56. const _TCHAR* szValueName,
  57. void * Data,
  58. ULONG DataSize );
  59. BOOL setSnapInExtensionNode(const _TCHAR* szSnapID,
  60. const _TCHAR* szNodeID,
  61. const _TCHAR* szDescription);
  62. // Delete szKeyChild and all of its descendents.
  63. LONG recursiveDeleteKey(HKEY hKeyParent, const _TCHAR* szKeyChild) ;
  64. ////////////////////////////////////////////////////////
  65. //
  66. // Constants
  67. //
  68. // Size of a CLSID as a string
  69. //const int CLSID_STRING_SIZE = 39 ;
  70. #if defined( UNICODE ) || defined( _UNICODE )
  71. const DWORD MAX_GUID_CHARS = 50;
  72. #else
  73. const DWORD MAX_GUID_CHARS = 50 * 8; // worst encoding
  74. #endif
  75. /////////////////////////////////////////////////////////
  76. //
  77. // Public function implementation
  78. //
  79. //
  80. // Register the component in the registry.
  81. //
  82. #if defined ( UNICODE ) || defined( _UNICODE )
  83. HRESULT
  84. StringFromGUIDInternal(
  85. const CLSID& clsid,
  86. _TCHAR * szGuidString
  87. )
  88. {
  89. return StringFromGUID2( clsid, szGuidString, MAX_GUID_CHARS );
  90. }
  91. #else
  92. #error Provide a unicode to DBCS thunk version
  93. #endif
  94. HRESULT RegisterServer(HMODULE hModule, // DLL module handle
  95. const CLSID& clsid, // Class ID
  96. const _TCHAR* szFriendlyName,
  97. const _TCHAR* ThreadingModel,
  98. bool Remoteable,
  99. const _TCHAR* SecurityString ) // IDs
  100. {
  101. // Get server location.
  102. _TCHAR szModule[512];
  103. DWORD dwLen = sizeof(szModule)/sizeof(_TCHAR);
  104. DWORD dwResult = GetModuleFileName(hModule,
  105. szModule,
  106. dwLen - 1) ;
  107. if ( !dwResult )
  108. {
  109. assert(dwResult != 0) ;
  110. return HRESULT_FROM_WIN32( GetLastError() );
  111. }
  112. szModule[dwLen-1] = 0;
  113. // Get CLSID
  114. _TCHAR szCLSID[ MAX_GUID_CHARS ];
  115. HRESULT Hr = StringFromGUIDInternal( clsid, szCLSID );
  116. if ( FAILED( Hr ) )
  117. {
  118. assert( 0 );
  119. return Hr;
  120. }
  121. // Build the key CLSID\\{...}
  122. _TCHAR szKey[64] ;
  123. StringCchCopy(szKey, ARRAY_ELEMENTS( szKey ), _T("CLSID\\")) ;
  124. StringCchCat(szKey, ARRAY_ELEMENTS(szKey), szCLSID) ;
  125. // Add the CLSID to the registry.
  126. setKeyAndValue(szKey, NULL, szFriendlyName) ;
  127. if ( Remoteable )
  128. setValue( szKey, _T("AppID"), szCLSID );
  129. // Add the server filename subkey under the CLSID key.
  130. setKeyAndValue(szKey, _T("InprocServer32"), szModule) ;
  131. // set the threading model
  132. StringCchCat(szKey, ARRAY_ELEMENTS(szKey), _T("\\InprocServer32"));
  133. setValue(szKey, _T("ThreadingModel"), ThreadingModel);
  134. if ( Remoteable )
  135. {
  136. PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
  137. ULONG DescriptorSize;
  138. // build the key name
  139. StringCchCopy(szKey, ARRAY_ELEMENTS(szKey), _T("AppId\\")) ;
  140. StringCchCat(szKey, ARRAY_ELEMENTS(szKey), szCLSID) ;
  141. setKeyAndValue(szKey, NULL, szFriendlyName) ;
  142. setValue(szKey, _T("DllSurrogate"), _T("") );
  143. if ( !ConvertStringSecurityDescriptorToSecurityDescriptor(
  144. SecurityString,
  145. SDDL_REVISION_1,
  146. &SecurityDescriptor,
  147. &DescriptorSize
  148. ) )
  149. return HRESULT_FROM_WIN32( GetLastError() );
  150. setBinaryValue( szKey, _T("LaunchPermission"), SecurityDescriptor, DescriptorSize );
  151. setBinaryValue( szKey, _T("AccessPermission"), SecurityDescriptor, DescriptorSize );
  152. LocalFree( (HLOCAL)SecurityDescriptor );
  153. }
  154. return S_OK ;
  155. }
  156. //
  157. // Remove the component from the registry.
  158. //
  159. LONG UnregisterServer(const CLSID& clsid) // IDs
  160. {
  161. // Get CLSID
  162. _TCHAR szCLSID[ MAX_GUID_CHARS ];
  163. HRESULT Hr = StringFromGUIDInternal( clsid, szCLSID );
  164. if ( FAILED( Hr ) )
  165. {
  166. assert( 0 );
  167. return Hr;
  168. }
  169. // Build the key CLSID\\{...}
  170. _TCHAR szKey[64] ;
  171. StringCchCopy( szKey, ARRAY_ELEMENTS(szKey), _T("CLSID\\") );
  172. StringCchCat( szKey, ARRAY_ELEMENTS(szKey), szCLSID );
  173. // Delete the CLSID Key - CLSID\{...}
  174. LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
  175. assert((lResult == ERROR_SUCCESS) ||
  176. (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
  177. StringCchCopy(szKey, ARRAY_ELEMENTS(szKey), _T("AppId\\"));
  178. StringCchCat(szKey, ARRAY_ELEMENTS(szKey), szCLSID );
  179. lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey);
  180. return S_OK;
  181. }
  182. //
  183. // Register the snap-in in the registry.
  184. //
  185. HRESULT RegisterSnapin(const CLSID& clsid, // Class ID
  186. const _TCHAR* szNameString, // NameString
  187. const CLSID& clsidAbout) // Class Id for About Class
  188. {
  189. // Get CLSID
  190. _TCHAR szCLSID[ MAX_GUID_CHARS ];
  191. _TCHAR szAboutCLSID[ MAX_GUID_CHARS ];
  192. EXTENSION_NODE *pExtensionNode;
  193. EXTENDER_NODE *pNodeExtension;
  194. _TCHAR szKeyBuf[1024] ;
  195. HKEY hKey;
  196. HRESULT Hr = StringFromGUIDInternal(clsid, szCLSID);
  197. if ( FAILED( Hr ) )
  198. {
  199. assert( 0 );
  200. return Hr;
  201. }
  202. if (IID_NULL != clsidAbout)
  203. Hr = StringFromGUIDInternal(clsidAbout, szAboutCLSID);
  204. if ( FAILED( Hr ) )
  205. {
  206. assert( 0 );
  207. return Hr;
  208. }
  209. // Add the CLSID to the registry.
  210. setSnapInKeyAndValue(szCLSID, NULL, _T("NameString"), szNameString) ;
  211. #ifdef STANDALONE
  212. setSnapInKeyAndValue(szCLSID, _T("StandAlone"), NULL, NULL);
  213. #endif
  214. if (IID_NULL != clsidAbout)
  215. setSnapInKeyAndValue(szCLSID, NULL, _T("About"), szAboutCLSID);
  216. // register each of the node types in _ExtendableNodes as an extendable node
  217. for (pExtensionNode = &(_ExtendableNodes[0]);*pExtensionNode->szDescription;pExtensionNode++)
  218. {
  219. _TCHAR szExtendCLSID[ MAX_GUID_CHARS ];
  220. Hr = StringFromGUIDInternal(pExtensionNode->GUID, szExtendCLSID);
  221. if ( FAILED( Hr ) )
  222. {
  223. assert( 0 );
  224. return Hr;
  225. }
  226. setSnapInExtensionNode(szCLSID, szExtendCLSID, pExtensionNode->szDescription);
  227. }
  228. // register each of the node extensions
  229. for (pNodeExtension = &(_NodeExtensions[0]);*pNodeExtension->szDescription;pNodeExtension++)
  230. {
  231. _TCHAR szExtendCLSID[ MAX_GUID_CHARS ];
  232. Hr = StringFromGUIDInternal(pNodeExtension->guidNode, szExtendCLSID);
  233. if ( FAILED( Hr ) )
  234. {
  235. assert(0);
  236. return Hr;
  237. }
  238. StringCchCopy(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("SOFTWARE\\Microsoft\\MMC\\NodeTypes\\"));
  239. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf), szExtendCLSID);
  240. switch (pNodeExtension->eType) {
  241. case NameSpaceExtension:
  242. StringCchCat( szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\Extensions\\NameSpace") );
  243. break;
  244. case ContextMenuExtension:
  245. StringCchCat( szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\Extensions\\ContextMenu") );
  246. break;
  247. case ToolBarExtension:
  248. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\Extensions\\ToolBar"));
  249. break;
  250. case PropertySheetExtension:
  251. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\Extensions\\PropertySheet"));
  252. break;
  253. case TaskExtension:
  254. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\Extensions\\Task"));
  255. break;
  256. case DynamicExtension:
  257. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\Dynamic Extensions"));
  258. default:
  259. break;
  260. }
  261. // Create and open key and subkey.
  262. long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
  263. szKeyBuf,
  264. 0, NULL, REG_OPTION_NON_VOLATILE,
  265. KEY_ALL_ACCESS, NULL,
  266. &hKey, NULL) ;
  267. if (lResult != ERROR_SUCCESS)
  268. {
  269. return FALSE ;
  270. }
  271. _TCHAR szNodeCLSID[ MAX_GUID_CHARS ];
  272. Hr = StringFromGUIDInternal(pNodeExtension->guidExtension, szNodeCLSID);
  273. if ( FAILED(Hr) )
  274. {
  275. assert( 0 );
  276. return Hr;
  277. }
  278. // Set the Value.
  279. if (pNodeExtension->szDescription != NULL)
  280. {
  281. RegSetValueEx(hKey, szNodeCLSID, 0, REG_SZ,
  282. (BYTE *)pNodeExtension->szDescription,
  283. (_tcslen(pNodeExtension->szDescription)+1)*sizeof(_TCHAR)) ;
  284. }
  285. RegCloseKey(hKey);
  286. }
  287. return S_OK;
  288. }
  289. //
  290. // Unregister the snap-in in the registry.
  291. //
  292. HRESULT UnregisterSnapin(const CLSID& clsid) // Class ID
  293. {
  294. _TCHAR szKeyBuf[1024];
  295. _TCHAR szCLSID[ MAX_GUID_CHARS ];
  296. // Get CLSID
  297. HRESULT Hr = StringFromGUIDInternal(clsid, szCLSID);
  298. if ( FAILED( Hr ) )
  299. {
  300. assert( 0 );
  301. return Hr;
  302. }
  303. // Load the buffer with the Snap-In Location
  304. StringCchCopy(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
  305. // Copy keyname into buffer.
  306. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\"));
  307. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), szCLSID);
  308. // Delete the CLSID Key - CLSID\{...}
  309. LONG lResult = recursiveDeleteKey(HKEY_LOCAL_MACHINE, szKeyBuf);
  310. assert((lResult == ERROR_SUCCESS) ||
  311. (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
  312. return S_OK;
  313. }
  314. //
  315. // Delete a key and all of its descendents.
  316. //
  317. LONG recursiveDeleteKey(HKEY hKeyParent, // Parent of key to delete
  318. const _TCHAR* lpszKeyChild) // Key to delete
  319. {
  320. // Open the child.
  321. HKEY hKeyChild ;
  322. LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
  323. KEY_ALL_ACCESS, &hKeyChild) ;
  324. if (lRes != ERROR_SUCCESS)
  325. {
  326. return lRes ;
  327. }
  328. // Enumerate all of the decendents of this child.
  329. FILETIME time ;
  330. _TCHAR szBuffer[256] ;
  331. DWORD dwSize = 256 ;
  332. while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
  333. NULL, NULL, &time) == S_OK)
  334. {
  335. // Delete the decendents of this child.
  336. lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
  337. if (lRes != ERROR_SUCCESS)
  338. {
  339. // Cleanup before exiting.
  340. RegCloseKey(hKeyChild) ;
  341. return lRes;
  342. }
  343. dwSize = 256 ;
  344. }
  345. // Close the child.
  346. RegCloseKey(hKeyChild) ;
  347. // Delete this child.
  348. return RegDeleteKey(hKeyParent, lpszKeyChild) ;
  349. }
  350. //
  351. // Create a key and set its value.
  352. // - This helper function was borrowed and modifed from
  353. // Kraig Brockschmidt's book Inside OLE.
  354. //
  355. BOOL setKeyAndValue(const _TCHAR* szKey,
  356. const _TCHAR* szSubkey,
  357. const _TCHAR* szValue)
  358. {
  359. HKEY hKey;
  360. _TCHAR szKeyBuf[1024] ;
  361. // Copy keyname into buffer.
  362. StringCchCopy(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), szKey) ;
  363. // Add subkey name to buffer.
  364. if (szSubkey != NULL)
  365. {
  366. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\")) ;
  367. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), szSubkey ) ;
  368. }
  369. // Create and open key and subkey.
  370. long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
  371. szKeyBuf,
  372. 0, NULL, REG_OPTION_NON_VOLATILE,
  373. KEY_ALL_ACCESS, NULL,
  374. &hKey, NULL) ;
  375. if (lResult != ERROR_SUCCESS)
  376. {
  377. return FALSE ;
  378. }
  379. // Set the Value.
  380. if (szValue != NULL)
  381. {
  382. RegSetValueEx(hKey, NULL, 0, REG_SZ,
  383. (BYTE *)szValue,
  384. (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
  385. }
  386. RegCloseKey(hKey) ;
  387. return TRUE ;
  388. }
  389. //
  390. // Open a key value and set it
  391. //
  392. BOOL setValue(const _TCHAR* szKey,
  393. const _TCHAR* szValueName,
  394. const _TCHAR* szValue)
  395. {
  396. HKEY hKey;
  397. _TCHAR szKeyBuf[1024] ;
  398. // Copy keyname into buffer.
  399. StringCchCopy(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), szKey) ;
  400. // Create and open key and subkey.
  401. long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
  402. szKeyBuf,
  403. 0, NULL, REG_OPTION_NON_VOLATILE,
  404. KEY_ALL_ACCESS, NULL,
  405. &hKey, NULL) ;
  406. if (lResult != ERROR_SUCCESS)
  407. {
  408. return FALSE ;
  409. }
  410. // Set the Value.
  411. if (szValue != NULL)
  412. {
  413. RegSetValueEx(hKey, szValueName, 0, REG_SZ,
  414. (BYTE *)szValue,
  415. (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
  416. }
  417. RegCloseKey(hKey) ;
  418. return TRUE ;
  419. }
  420. //
  421. // Open a key value and set it
  422. //
  423. BOOL setBinaryValue(
  424. const _TCHAR* szKey,
  425. const _TCHAR* szValueName,
  426. void * Data,
  427. ULONG DataSize )
  428. {
  429. HKEY hKey;
  430. _TCHAR szKeyBuf[1024] ;
  431. // Copy keyname into buffer.
  432. StringCchCopy(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), szKey) ;
  433. // Create and open key and subkey.
  434. long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
  435. szKeyBuf,
  436. 0, NULL, REG_OPTION_NON_VOLATILE,
  437. KEY_ALL_ACCESS, NULL,
  438. &hKey, NULL) ;
  439. if (lResult != ERROR_SUCCESS)
  440. {
  441. return FALSE ;
  442. }
  443. // Set the Value.
  444. RegSetValueEx(hKey, szValueName, 0, REG_BINARY,
  445. (BYTE *)Data,
  446. DataSize ) ;
  447. RegCloseKey(hKey) ;
  448. return TRUE ;
  449. }
  450. //
  451. // Create a key and set its value.
  452. // - This helper function was borrowed and modifed from
  453. // Kraig Brockschmidt's book Inside OLE.
  454. //
  455. BOOL setSnapInKeyAndValue(const _TCHAR* szKey,
  456. const _TCHAR* szSubkey,
  457. const _TCHAR* szName,
  458. const _TCHAR* szValue)
  459. {
  460. HKEY hKey;
  461. _TCHAR szKeyBuf[1024] ;
  462. // Load the buffer with the Snap-In Location
  463. StringCchCopy(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("SOFTWARE\\Microsoft\\MMC\\SnapIns"));
  464. // Copy keyname into buffer.
  465. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\")) ;
  466. StringCchCat(szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), szKey) ;
  467. // Add subkey name to buffer.
  468. if (szSubkey != NULL)
  469. {
  470. StringCchCat( szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), _T("\\") ) ;
  471. StringCchCat( szKeyBuf, ARRAY_ELEMENTS( szKeyBuf ), szSubkey ) ;
  472. }
  473. // Create and open key and subkey.
  474. long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
  475. szKeyBuf,
  476. 0, NULL, REG_OPTION_NON_VOLATILE,
  477. KEY_ALL_ACCESS, NULL,
  478. &hKey, NULL) ;
  479. if (lResult != ERROR_SUCCESS)
  480. {
  481. return FALSE ;
  482. }
  483. // Set the Value.
  484. if (szValue != NULL)
  485. {
  486. RegSetValueEx(hKey, szName, 0, REG_SZ,
  487. (BYTE *)szValue,
  488. (_tcslen(szValue)+1)*sizeof(_TCHAR)) ;
  489. }
  490. RegCloseKey(hKey) ;
  491. return TRUE ;
  492. }
  493. BOOL setSnapInExtensionNode(const _TCHAR* szSnapID,
  494. const _TCHAR* szNodeID,
  495. const _TCHAR* szDescription)
  496. {
  497. HKEY hKey;
  498. _TCHAR szSnapNodeKeyBuf[1024] ;
  499. _TCHAR szMMCNodeKeyBuf[1024];
  500. // Load the buffer with the Snap-In Location
  501. StringCchCopy(szSnapNodeKeyBuf, ARRAY_ELEMENTS(szSnapNodeKeyBuf),
  502. _T("SOFTWARE\\Microsoft\\MMC\\SnapIns\\"));
  503. // add in the clisid into buffer.
  504. StringCchCat(szSnapNodeKeyBuf, ARRAY_ELEMENTS(szSnapNodeKeyBuf), szSnapID) ;
  505. StringCchCat(szSnapNodeKeyBuf, ARRAY_ELEMENTS(szSnapNodeKeyBuf), _T("\\NodeTypes\\"));
  506. StringCchCat(szSnapNodeKeyBuf, ARRAY_ELEMENTS(szSnapNodeKeyBuf), szNodeID) ;
  507. // Load the buffer with the NodeTypes Location
  508. StringCchCopy(szMMCNodeKeyBuf, ARRAY_ELEMENTS( szMMCNodeKeyBuf ),
  509. _T("SOFTWARE\\Microsoft\\MMC\\NodeTypes\\"));
  510. StringCchCat(szMMCNodeKeyBuf, ARRAY_ELEMENTS( szMMCNodeKeyBuf ), szNodeID) ;
  511. // Create and open the Snapin Key.
  512. long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
  513. szSnapNodeKeyBuf,
  514. 0, NULL, REG_OPTION_NON_VOLATILE,
  515. KEY_ALL_ACCESS, NULL,
  516. &hKey, NULL) ;
  517. if (lResult != ERROR_SUCCESS)
  518. {
  519. return FALSE ;
  520. }
  521. // Set the Value.
  522. if (szDescription != NULL)
  523. {
  524. RegSetValueEx(hKey, NULL, 0, REG_SZ,
  525. (BYTE *)szDescription,
  526. (_tcslen(szDescription)+1)*sizeof(_TCHAR)) ;
  527. }
  528. RegCloseKey(hKey) ;
  529. // Create and open the NodeTypes Key.
  530. lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
  531. szMMCNodeKeyBuf,
  532. 0, NULL, REG_OPTION_NON_VOLATILE,
  533. KEY_ALL_ACCESS, NULL,
  534. &hKey, NULL) ;
  535. if (lResult != ERROR_SUCCESS)
  536. {
  537. return FALSE ;
  538. }
  539. // Set the Value.
  540. if (szDescription != NULL)
  541. {
  542. RegSetValueEx(hKey, NULL, 0, REG_SZ,
  543. (BYTE *)szDescription,
  544. (_tcslen(szDescription)+1)*sizeof(_TCHAR)) ;
  545. }
  546. RegCloseKey(hKey) ;
  547. return TRUE ;
  548. }