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.

758 lines
25 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: dsysreg.hxx
  6. //
  7. // Contents: Definitions of classes for manipulating registry entries.
  8. //
  9. // Classes: CRegKey - class for registry key objects
  10. // CRegValue - base class for registry value objects
  11. // CRegSZ - derived class for registry string values
  12. // CRegDWORD - derived class for registry dword values
  13. // CRegBINARY - derived class for registry binary values
  14. // CRegMSZ - derived class for registry multi-string values
  15. //
  16. // History: 09/30/92 Rickhi Created
  17. // 09/22/93 AlokS Took out exception throwing code
  18. // and added proper return code for
  19. // each method.
  20. //
  21. // 07/26/94 AlokS Made it lightweight for normal set/get
  22. // operations. Threw out all exception code
  23. //
  24. // Notes: CRegKey can use another CRegKey as a parent, so you can
  25. // build a tree of keys. To kick things off, you can give one
  26. // of the default registry keys like HKEY_CURRENT_USER. When
  27. // you do this, the GetParent method returns NULL. Currently
  28. // however, no ptrs are kept to child and sibling keys.
  29. //
  30. // CRegValue is a base class for dealing with registry values.
  31. // The other classes (except CRegKey) are for dealing with a
  32. // specific type of registry value in the native data format.
  33. // For example, CRegDWORD lets you call methods just providing
  34. // a dword. The methods take care of figuring out the size and
  35. // casting the dword to a ptr to bytes, etc for use in the Win32
  36. // registry APIs.
  37. //
  38. // For any registry type not defined here, you can always resort
  39. // to using the CRegValue base class directly, though you then
  40. // must call GetValue or SetValue methods explicitly.
  41. //
  42. // Sample Usage:
  43. //
  44. // The following reads the username in the ValueID UserName
  45. // within the key HKEY_CURRENT_USER\LogonInfo. It then changes
  46. // it to Rickhi. It also sets the password valueid in the
  47. // the same key to foobar.
  48. //
  49. // #include <dsysreg.hxx>
  50. //
  51. // // open the registry key
  52. // CRegKey rkLogInfo(HKEY_CURRENT_USER, L"LogonInfo");
  53. //
  54. // // read the user name
  55. // LPWSTR pwszUserName;
  56. // CRegSZ rszUserName(&rkLogInfo, L"UserName", pwszUserName);
  57. // rszUserName.SetString(L"Rickhi");
  58. //
  59. // // set the password
  60. // CRegSZ rszPassWord(&rkLogInfo, L"PassWord", L"foobar");
  61. //
  62. //----------------------------------------------------------------------------
  63. #ifndef __DSYSREG_HXX__
  64. #define __DSYSREG_HXX__
  65. #include "wcbuffer.hxx"
  66. // to simplify error creation
  67. #define Creg_ERROR(x) (x)
  68. // forward declarations for use in the following structures
  69. class CRegValue;
  70. class CRegKey;
  71. // structure for enumerating subkeys of a key
  72. typedef struct _SRegKeySet
  73. {
  74. ULONG cKeys;
  75. CRegKey *aprkKey[1];
  76. } SRegKeySet;
  77. // structure for enumerating values within a key
  78. typedef struct _SRegValueSet
  79. {
  80. ULONG cValues;
  81. CRegValue *aprvValue[1];
  82. } SRegValueSet;
  83. // structure for dealing with multi-string values
  84. typedef struct _SMultiStringSet
  85. {
  86. ULONG cStrings;
  87. LPWSTR apwszString[1];
  88. } SMultiStringSet;
  89. //+-------------------------------------------------------------------------
  90. //
  91. // Class: CRegKey
  92. //
  93. // Purpose: class for abstracting Registry Keys
  94. //
  95. // Interface: CRegKey - constructor for a registry key object
  96. // ~CRegKey - destructor for a registry key object
  97. // GetParentHandle - returns parent key's handle
  98. // GetHandle - returns this key's handle
  99. // GetName - returns key path
  100. // Delete - deletes the key from the registry
  101. // EnumValues - enumerate values stored in the key
  102. // EnumKeys - enumerates subkeys of the key
  103. // NotifyChange - sets up change notification for the key
  104. // QueryErrorStatus - Should be used to determine if constructor
  105. // completed successfully or not
  106. // History: 09/30/92 Rickhi Created
  107. //
  108. // Notes:
  109. //
  110. //--------------------------------------------------------------------------
  111. class CRegKey
  112. {
  113. public:
  114. // constructor using HKEY for parent
  115. // Mode: Create key if not present
  116. CRegKey( HKEY hkParent,
  117. const LPWSTR pwszPath,
  118. // remaining parameters are optional
  119. REGSAM samDesiredAccess = KEY_ALL_ACCESS,
  120. const LPWSTR pwszClass = NULL,
  121. DWORD dwOptions = REG_OPTION_NON_VOLATILE,
  122. DWORD *pdwDisposition = NULL,
  123. const LPSECURITY_ATTRIBUTES pSecurityAttributes = NULL
  124. );
  125. // constructor using CRegKey as parent
  126. // Mode: Create key if not present
  127. CRegKey(const CRegKey& crkParent,
  128. const LPWSTR pwszPath,
  129. // remaining parameters are optional
  130. REGSAM samDesiredAccess = KEY_ALL_ACCESS,
  131. const LPWSTR pwszClass = NULL,
  132. DWORD dwOptions = REG_OPTION_NON_VOLATILE,
  133. DWORD *pdwDisposition = NULL,
  134. const LPSECURITY_ATTRIBUTES pSecurityAttributes = NULL
  135. );
  136. // Constructor using HKEY for parent
  137. // Mode: Simply Open the key, if exists
  138. CRegKey (
  139. HKEY hkParent,
  140. DWORD *pdwErr,
  141. const LPWSTR pwszPath,
  142. REGSAM samDesiredAccess = KEY_ALL_ACCESS
  143. );
  144. // Constructor using CRegKey as parent
  145. // Mode: Simply open the key, if exists
  146. CRegKey (const CRegKey& crkParent,
  147. DWORD *pdwErr,
  148. const LPWSTR pwszPath,
  149. REGSAM samDesiredAccess = KEY_ALL_ACCESS
  150. );
  151. // Destructor - Closes registry key
  152. ~CRegKey(void);
  153. HKEY GetHandle(void) const;
  154. const LPWSTR GetName(void) const;
  155. DWORD Delete(void);
  156. DWORD DeleteChildren(void);
  157. DWORD EnumValues(SRegValueSet **pprvs);
  158. DWORD EnumKeys(SRegKeySet **pprks);
  159. // This method can be called to determine if
  160. // Object is in sane state or not
  161. DWORD QueryErrorStatus () const { return _dwErr ; }
  162. // Static routine which frees memory allocated during EnumValues/Keys
  163. static void MemFree ( void * pv )
  164. {
  165. delete [] (BYTE*)pv;
  166. }
  167. private:
  168. DWORD CreateKey( HKEY hkParent,
  169. const LPWSTR pwszPath,
  170. REGSAM samDesiredAccess,
  171. const LPWSTR pwszClass,
  172. DWORD dwOptions,
  173. DWORD *pdwDisposition,
  174. const LPSECURITY_ATTRIBUTES pSecurityAttributes
  175. );
  176. DWORD OpenKey ( HKEY hkParent,
  177. const LPWSTR pwszPath,
  178. REGSAM samDesiredAccess
  179. );
  180. HKEY _hkParent; // Handle to parent
  181. HKEY _hkThis; // handle for this key
  182. CWCHARBuffer _cwszName; // Buffer containing the registry path
  183. // path from parent key to this key
  184. DWORD _dwErr; // Internal error status
  185. };
  186. inline HKEY CRegKey::GetHandle(void) const
  187. {
  188. return _hkThis;
  189. }
  190. inline const LPWSTR CRegKey::GetName(void) const
  191. {
  192. return (const LPWSTR) (LPWSTR)_cwszName;
  193. }
  194. //+-------------------------------------------------------------------------
  195. //
  196. // Class: CRegValue
  197. //
  198. // Purpose: base class for abstracting Registry Values
  199. //
  200. // Interface: CRegValue - constructor for value
  201. // ~CRegValue - destructor for value
  202. // GetKeyHandle - returns handle for parent key
  203. // GetValueID - returns the ValueID name
  204. // GetTypeCode - returns the TypeCode of the data
  205. // GetValue - returns the data associated with the value
  206. // SetValue - sets the data associated with the value
  207. // Delete - deletes the value from the registry
  208. // QueryErrorStatus - Should be used to determine if constructor
  209. // completed successfully or not
  210. //
  211. // History: 09/30/92 Rickhi Created
  212. //
  213. // Notes: This is a base class from which more specific classes are
  214. // derived for each of the different registry value types.
  215. //
  216. //--------------------------------------------------------------------------
  217. class CRegValue
  218. {
  219. public:
  220. CRegValue(const CRegKey& crkParentKey,
  221. const LPWSTR pwszValueID);
  222. ~CRegValue(void){;};
  223. HKEY GetParentHandle(void) const;
  224. const LPWSTR GetValueID(void) const;
  225. VOID Delete(void);
  226. // Caller supplies buffer
  227. DWORD GetValue(LPBYTE pbData, ULONG *pcbData, DWORD *pdwTypeCode);
  228. DWORD SetValue(const LPBYTE pbData, ULONG cbData, DWORD dwTypeCode);
  229. virtual DWORD QueryErrorStatus (void) const { return _dwErr ; }
  230. private:
  231. CWCHARBuffer _cwszValueID;
  232. HKEY _hkParent;
  233. DWORD _dwErr ;
  234. };
  235. //+-------------------------------------------------------------------------
  236. //
  237. // Member: CRegValue::CRegValue
  238. //
  239. // Purpose: constructor for base registry value
  240. //
  241. // Arguments: [prkParent] - ptr to parent CRegKey for the key
  242. // [pwszValueID] - the valueID name for the value
  243. //
  244. // Signals: nothing
  245. //
  246. // Returns: nothing
  247. //
  248. // History: 09/30/92 Rickhi Created
  249. //
  250. // Notes:
  251. //
  252. //--------------------------------------------------------------------------
  253. inline CRegValue::CRegValue(const CRegKey& crkParent,
  254. const LPWSTR pwszValueID)
  255. : _hkParent (crkParent.GetHandle()),
  256. _dwErr(crkParent.QueryErrorStatus())
  257. {
  258. _cwszValueID.Set(pwszValueID);
  259. }
  260. inline HKEY CRegValue::GetParentHandle(void) const
  261. {
  262. return _hkParent;
  263. }
  264. inline const LPWSTR CRegValue::GetValueID(void) const
  265. {
  266. return (const LPWSTR) (LPWSTR) _cwszValueID;
  267. }
  268. inline VOID CRegValue::Delete(void)
  269. {
  270. _dwErr = RegDeleteValue( _hkParent, _cwszValueID );
  271. }
  272. //+-------------------------------------------------------------------------
  273. //
  274. // Class: CRegSZ
  275. //
  276. // Purpose: Derived class for abstracting Registry string Values
  277. //
  278. // Interface: CRegSZ - constructor for registry value using string
  279. // ~CRegSZ - destructor for registry string object
  280. // GetString - returns the string
  281. // SetString - sets a new string value
  282. // QueryErrorStatus - Should be used to determine if constructor
  283. // completed successfully or not
  284. //
  285. // History: 09/30/92 Rickhi Created
  286. //
  287. // Notes: Derived from CRegValue.
  288. //
  289. // There are three constructors. The first is used if you want
  290. // to create a new value or overwrite the existing value data.
  291. // The second is used if you want to open an existing value
  292. // and read it's data. The third is used if you just want to
  293. // make an object without doing any read/write of the data yet.
  294. // In all three cases, you can always use any of the Get/Set
  295. // operations on the object at a later time.
  296. //
  297. //--------------------------------------------------------------------------
  298. class CRegSZ : public CRegValue
  299. {
  300. public:
  301. // create/write value constructor
  302. CRegSZ(const CRegKey &crkParent,
  303. const LPWSTR pwszValueID,
  304. const LPWSTR pwszData
  305. );
  306. // io-less constructor - used by enumerator
  307. CRegSZ(const CRegKey &crkParent,
  308. const LPWSTR pwszValueID
  309. );
  310. ~CRegSZ(void){;};
  311. DWORD SetString(const LPWSTR pwszData);
  312. // Caller supplies buffer (supply the buffer size in bytes)
  313. DWORD GetString( LPWSTR pwszData, ULONG *pcbData);
  314. DWORD GetTypeCode(void);
  315. DWORD QueryErrorStatus(void) const { return _dwErr ; }
  316. private:
  317. DWORD _dwErr;
  318. };
  319. //+-------------------------------------------------------------------------
  320. //
  321. // Member: CRegSZ::CRegSZ
  322. //
  323. // Purpose: Constructor for registry string value
  324. //
  325. // History: 09/30/92 Rickhi Created
  326. //
  327. // Notes:
  328. //
  329. //--------------------------------------------------------------------------
  330. inline CRegSZ::CRegSZ(const CRegKey &crkParent,
  331. const LPWSTR pwszValueID,
  332. const LPWSTR pwszData)
  333. : CRegValue(crkParent, pwszValueID)
  334. {
  335. if (ERROR_SUCCESS == (_dwErr = CRegValue::QueryErrorStatus()))
  336. _dwErr = SetString(pwszData);
  337. }
  338. inline CRegSZ::CRegSZ(const CRegKey &crkParent,
  339. const LPWSTR pwszValueID)
  340. : CRegValue(crkParent, pwszValueID)
  341. {
  342. // automatic actions in header are sufficient
  343. _dwErr = CRegValue::QueryErrorStatus();
  344. }
  345. inline DWORD CRegSZ::SetString(const LPWSTR pwszData)
  346. {
  347. return SetValue((LPBYTE)pwszData, (wcslen(pwszData)+1)*sizeof(WCHAR), REG_SZ);
  348. }
  349. inline DWORD CRegSZ::GetString(LPWSTR pwszData, ULONG* pcbData)
  350. {
  351. DWORD dwTypeCode;
  352. return GetValue((LPBYTE)pwszData, pcbData, &dwTypeCode);
  353. }
  354. inline DWORD CRegSZ::GetTypeCode(void)
  355. {
  356. return REG_SZ;
  357. }
  358. //+-------------------------------------------------------------------------
  359. //
  360. // Class: CRegMSZ
  361. //
  362. // Purpose: Derived class for abstracting Registry multi-string Values
  363. //
  364. // Interface: CRegMSZ - constructor for registry value using string
  365. // ~CRegMSZ - destructor for registry string object
  366. // GetString - returns the string
  367. // SetString - sets a new string value
  368. // QueryErrorStatus - Should be used to determine if constructor
  369. // completed successfully or not
  370. //
  371. // History: 09/30/92 Rickhi Created
  372. //
  373. // Notes: Derived from CRegValue.
  374. //
  375. // There are three constructors. The first is used if you want
  376. // to create a new value or overwrite the existing value data.
  377. // The second is used if you want to open an existing value
  378. // and read it's data. The third is used if you just want to
  379. // make an object without doing any read/write of the data yet.
  380. // In all three cases, you can always use any of the Get/Set
  381. // operations on the object at a later time.
  382. //
  383. //--------------------------------------------------------------------------
  384. class CRegMSZ : public CRegValue
  385. {
  386. public:
  387. // create/write value constructor
  388. CRegMSZ(const CRegKey &crkParent,
  389. const LPWSTR pwszValueID,
  390. const LPWSTR pwszData
  391. );
  392. // io-less constructor - used by enumerator
  393. CRegMSZ(const CRegKey &crkParent,
  394. const LPWSTR pwszValueID
  395. );
  396. ~CRegMSZ(void){;};
  397. DWORD SetString(const LPWSTR pwszData);
  398. // Caller supplies buffer (supply the buffer size in bytes)
  399. DWORD GetString( LPWSTR pwszData, ULONG *pcbData);
  400. DWORD GetTypeCode(void);
  401. DWORD QueryErrorStatus(void) const { return _dwErr ; }
  402. private:
  403. DWORD _dwErr;
  404. };
  405. //+-------------------------------------------------------------------------
  406. //
  407. // Member: CRegMSZ::CRegMSZ
  408. //
  409. // Purpose: Constructor for registry string value
  410. //
  411. // History: 09/30/92 Rickhi Created
  412. //
  413. // Notes:
  414. //
  415. //--------------------------------------------------------------------------
  416. inline CRegMSZ::CRegMSZ(const CRegKey &crkParent,
  417. const LPWSTR pwszValueID,
  418. const LPWSTR pwszData)
  419. : CRegValue(crkParent, pwszValueID)
  420. {
  421. if (ERROR_SUCCESS == (_dwErr = CRegValue::QueryErrorStatus()))
  422. _dwErr = SetString(pwszData);
  423. }
  424. inline CRegMSZ::CRegMSZ(const CRegKey &crkParent,
  425. const LPWSTR pwszValueID)
  426. : CRegValue(crkParent, pwszValueID)
  427. {
  428. // automatic actions in header are sufficient
  429. _dwErr = CRegValue::QueryErrorStatus();
  430. }
  431. inline DWORD CRegMSZ::SetString(const LPWSTR pwszData)
  432. {
  433. DWORD cwLen, cbData;
  434. LPWSTR pwszNextString;
  435. for (pwszNextString = pwszData, cbData = 0;
  436. *pwszNextString != UNICODE_NULL;
  437. pwszNextString += cwLen) {
  438. cwLen = wcslen(pwszNextString) + 1;
  439. cbData += (cwLen * sizeof(WCHAR));
  440. }
  441. cbData += sizeof(UNICODE_NULL);
  442. return SetValue((LPBYTE)pwszData, cbData, REG_MULTI_SZ);
  443. }
  444. inline DWORD CRegMSZ::GetString(LPWSTR pwszData, ULONG* pcbData)
  445. {
  446. DWORD dwTypeCode;
  447. return GetValue((LPBYTE)pwszData, pcbData, &dwTypeCode);
  448. }
  449. inline DWORD CRegMSZ::GetTypeCode(void)
  450. {
  451. return REG_MULTI_SZ;
  452. }
  453. //+-------------------------------------------------------------------------
  454. //
  455. // Class: CRegDWORD
  456. //
  457. // Purpose: Derived class for abstracting Registry dword Values
  458. //
  459. // Interface: CRegDWORD - constructor for registry value using dword
  460. // ~CRegDWORD - destructor for registry dword object
  461. // GetDword - returns the dword
  462. // SetDword - sets a new dword value
  463. // QueryErrorStatus - Should be used to determine if constructor
  464. // completed successfully or not
  465. //
  466. // History: 09/30/92 Rickhi Created
  467. //
  468. // Notes: Derived from CRegValue.
  469. //
  470. // There are three constructors. The first is used if you want
  471. // to create a new value or overwrite the existing value data.
  472. // The second is used if you want to open an existing value
  473. // and read it's data. The third is used if you just want to
  474. // make an object without doing any read/write of the data yet.
  475. // In all three cases, you can always use any of the Get/Set
  476. // operations on the object at a later time.
  477. //
  478. //--------------------------------------------------------------------------
  479. class CRegDWORD : public CRegValue
  480. {
  481. public:
  482. // create/write value constructor
  483. CRegDWORD(const CRegKey &crkParent,
  484. const LPWSTR pwszValueID,
  485. DWORD dwData);
  486. // open/read value constructor
  487. CRegDWORD(const CRegKey &crkParent,
  488. const LPWSTR pwszValueID,
  489. DWORD *pdwData);
  490. // io-less constructor - used by enumerator
  491. CRegDWORD( const CRegKey &crkParent,
  492. const LPWSTR pwszValueID);
  493. ~CRegDWORD(void){;};
  494. DWORD SetDword(DWORD dwData);
  495. DWORD GetDword(DWORD *pdwData);
  496. DWORD GetTypeCode(void) ;
  497. DWORD QueryErrorStatus(void) const { return _dwErr ; }
  498. private:
  499. DWORD _dwErr;
  500. };
  501. //+-------------------------------------------------------------------------
  502. //
  503. // Member: CRegDWORD::CRegDWORD
  504. //
  505. // Purpose: Constructor for registry dword value
  506. //
  507. // History: 09/30/92 Rickhi Created
  508. //
  509. // Notes:
  510. //
  511. //--------------------------------------------------------------------------
  512. inline CRegDWORD::CRegDWORD(const CRegKey &crkParent,
  513. const LPWSTR pwszValueID,
  514. DWORD dwData)
  515. : CRegValue(crkParent, pwszValueID)
  516. {
  517. if (ERROR_SUCCESS == (_dwErr = CRegValue::QueryErrorStatus()))
  518. _dwErr = SetDword(dwData);
  519. }
  520. inline CRegDWORD::CRegDWORD(const CRegKey &crkParent,
  521. const LPWSTR pwszValueID,
  522. DWORD *pdwData)
  523. : CRegValue(crkParent, pwszValueID)
  524. {
  525. if (ERROR_SUCCESS == (_dwErr = CRegValue::QueryErrorStatus()))
  526. _dwErr = GetDword(pdwData);
  527. }
  528. inline CRegDWORD::CRegDWORD(const CRegKey &crkParent,
  529. const LPWSTR pwszValueID)
  530. : CRegValue(crkParent, pwszValueID)
  531. {
  532. // automatic actions in header are sufficient
  533. _dwErr = CRegValue::QueryErrorStatus();
  534. }
  535. inline DWORD CRegDWORD::GetDword(DWORD *pdwData)
  536. {
  537. DWORD dwTypeCode;
  538. DWORD dwErr;
  539. ULONG cbData= sizeof(DWORD);
  540. dwErr = GetValue((LPBYTE)pdwData, &cbData, &dwTypeCode);
  541. return (dwErr);
  542. }
  543. inline DWORD CRegDWORD::SetDword(DWORD dwData)
  544. {
  545. return SetValue((LPBYTE)&dwData, sizeof(DWORD), REG_DWORD);
  546. }
  547. inline DWORD CRegDWORD::GetTypeCode(void)
  548. {
  549. return REG_DWORD;
  550. }
  551. //+-------------------------------------------------------------------------
  552. //
  553. // Class: CRegBINARY
  554. //
  555. // Purpose: Derived class for abstracting Registry binary Values
  556. //
  557. // Interface: CRegBINARY - constructor for registry value using binary data
  558. // ~CRegBINARY - destructor for registry binary data object
  559. // GetBinary - returns the binary data
  560. // SetBinary - sets a new binary data value
  561. // QueryErrorStatus - Should be used to determine if constructor
  562. // completed successfully or not
  563. //
  564. // History: 09/30/92 Rickhi Created
  565. //
  566. // Notes: Derived from CRegValue.
  567. //
  568. // There are three constructors. The first is used if you want
  569. // to create a new value or overwrite the existing value data.
  570. // The second is used if you want to open an existing value
  571. // and read it's data. The third is used if you just want to
  572. // make an object without doing any read/write of the data yet.
  573. // In all three cases, you can always use any of the Get/Set
  574. // operations on the object at a later time.
  575. //
  576. //--------------------------------------------------------------------------
  577. class CRegBINARY : public CRegValue
  578. {
  579. public:
  580. // create/write value constructor
  581. CRegBINARY(const CRegKey &crkParent,
  582. const LPWSTR pwszValueID,
  583. const LPBYTE pbData,
  584. ULONG cbData);
  585. // io-less constructor - used by enumerator
  586. CRegBINARY(const CRegKey &crkParent,
  587. const LPWSTR pwszValueID);
  588. ~CRegBINARY(void){;};
  589. DWORD SetBinary(const LPBYTE pbData, ULONG cbData);
  590. // Caller supplies buffer (supply the buffer size in bytes)
  591. DWORD GetBinary(LPBYTE pbData, ULONG *pcbData);
  592. DWORD GetTypeCode(void);
  593. DWORD QueryErrorStatus(void) { return _dwErr ; }
  594. private:
  595. DWORD _dwErr;
  596. };
  597. //+-------------------------------------------------------------------------
  598. //
  599. // Member: CRegBINARY::CRegBINARY
  600. //
  601. // Purpose: Constructor for registry binary value
  602. //
  603. // History: 09/30/92 Rickhi Created
  604. //
  605. // Notes:
  606. //
  607. //--------------------------------------------------------------------------
  608. inline CRegBINARY::CRegBINARY(const CRegKey &crkParent,
  609. const LPWSTR pwszValueID,
  610. const LPBYTE pbData,
  611. ULONG cbData)
  612. : CRegValue(crkParent, pwszValueID)
  613. {
  614. if (ERROR_SUCCESS == (_dwErr = CRegValue::QueryErrorStatus()))
  615. _dwErr = SetBinary(pbData, cbData);
  616. }
  617. inline CRegBINARY::CRegBINARY(const CRegKey &crkParent,
  618. const LPWSTR pwszValueID)
  619. : CRegValue(crkParent, pwszValueID)
  620. {
  621. // automatic actions in header are sufficient
  622. _dwErr = CRegValue::QueryErrorStatus();
  623. }
  624. inline DWORD CRegBINARY::SetBinary(const LPBYTE pbData, ULONG cbData)
  625. {
  626. return SetValue(pbData, cbData, REG_BINARY);
  627. }
  628. inline DWORD CRegBINARY::GetBinary(LPBYTE pbData, ULONG* pcbData)
  629. {
  630. DWORD dwTypeCode;
  631. return GetValue(pbData, pcbData, &dwTypeCode);
  632. }
  633. inline DWORD CRegBINARY::GetTypeCode(void)
  634. {
  635. return REG_BINARY;
  636. }
  637. //+-------------------------------------------------------------------------
  638. //
  639. // Function: DelRegKeyTree
  640. //
  641. // Purpose: This function can be used to deleting a key and all it's
  642. // children.
  643. //
  644. // History: 09/30/93 AlokS Created
  645. //
  646. // Notes: We assume that caller has proper access priviledge
  647. // and the key is non-volatile.
  648. //
  649. //--------------------------------------------------------------------------
  650. DWORD DelRegKeyTree ( HKEY hParent, LPWSTR lpwszKeyPath);
  651. #endif // __DSYSREG_HXX__