home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WREGISTR.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  8KB  |  234 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WRegistryKey -- Wrapper for the Windows 95 Registry Key.
  14.  *
  15.  *   Events:
  16.  *
  17.  *************************************************************************/
  18.  
  19. #ifndef _WREGISTR_HPP_INCLUDED
  20. #define _WREGISTR_HPP_INCLUDED
  21.  
  22. #ifndef _WNO_PRAGMA_PUSH
  23. #pragma pack(push,8);
  24. #pragma enum int;
  25. #endif
  26.  
  27. #ifndef _WOBJECT_HPP_INCLUDED
  28. #  include "wobject.hpp"
  29. #endif
  30. #ifndef _WSTRING_HPP_INCLUDED
  31. #  include "wstring.hpp"
  32. #endif
  33. #ifndef _WBUFFER_HPP_INCLUDED
  34. #  include "wbuffer.hpp"
  35. #endif
  36.  
  37. typedef WULong WRegistryKeyHandle;
  38.  
  39. #define WRKeyClassesRoot        ((WRegistryKeyHandle)0x80000000)
  40. #define WRKeyCurrentUser        ((WRegistryKeyHandle)0x80000001)
  41. #define WRKeyLocalMachine       ((WRegistryKeyHandle)0x80000002)
  42. #define WRKeyUsers              ((WRegistryKeyHandle)0x80000003)
  43. #define WRKeyPerformanceData    ((WRegistryKeyHandle)0x80000004)
  44. #define WRKeyCurrentConfig      ((WRegistryKeyHandle)0x80000005)
  45. #define WRKeyDynData            ((WRegistryKeyHandle)0x80000006)
  46.  
  47. enum WRegistryDataType {
  48.     WRegNone = 0,
  49.     WRegDataString,
  50.     WRegDataExpandString,
  51.     WRegDataBinary,
  52.     WRegDataDWord,
  53.     WRegDataDWordBigEndian,
  54.     WRegDataLink,
  55.     WRegDataMultiString,
  56.     WRegDataResourceList,
  57.     WRegDataFullResourceDesc,
  58.     WRegDataResourceReqList
  59. };
  60.  
  61. enum WAccessType {
  62.     WAccessDelete                       = 0x00010000L,
  63.     WAccessReadControl                  = 0x00020000L,
  64.     WAccessWriteDAC                     = 0x00040000L,
  65.     WAccessWriteOwner                   = 0x00080000L,
  66.     WAccessSynchronize                  = 0x00100000L,
  67.     WAccessStandardRightsRequired       = 0x000F0000L,
  68.     WAccessStandardRightsRead           = WAccessReadControl,
  69.     WAccessStandardRightsWrite          = WAccessReadControl,
  70.     WAccessStandardRightsExecute        = WAccessReadControl,
  71.     WAccessStandardRightsAll            = 0x001F0000L,
  72.     WAccessSpecificRightsAll            = 0x0000FFFFL,
  73. };
  74.  
  75. enum WRegistryAccessType {
  76.     WRegAccessQueryValue = 0x0001,
  77.     WRegAccessSetValue = 0x0002,
  78.     WRegAccessCreateSubkey = 0x0004,
  79.     WRegAccessEnumerateSubkeys = 0x0008,
  80.     WRegAccessNotify = 0x0010,
  81.     WRegAccessCreateLink = 0x0020,
  82.     WRegAccessRead      = ((WAccessStandardRightsRead | WRegAccessQueryValue
  83.                             | WRegAccessEnumerateSubkeys | WRegAccessNotify)
  84.                           & (~WAccessSynchronize)),
  85.     WRegAccessWrite     = ((WAccessStandardRightsWrite | WRegAccessSetValue
  86.                             | WRegAccessCreateSubkey)
  87.                           & (~WAccessSynchronize)),
  88.     WRegAccessExecute   = ((WRegAccessRead)
  89.                           & (~WAccessSynchronize)),
  90.     WRegAccessAllAccess = ((WAccessStandardRightsAll | WRegAccessQueryValue
  91.                             | WRegAccessSetValue | WRegAccessCreateSubkey
  92.                             | WRegAccessEnumerateSubkeys
  93.                             | WRegAccessNotify | WRegAccessCreateLink)
  94.                           & (~WAccessSynchronize))
  95. };
  96.  
  97. class WCMCLASS WRegistryKey : public WObject {
  98.     WDeclareSubclass( WRegistryKey, WObject )
  99.  
  100.     public:
  101.     
  102.         /**********************************************************
  103.          * Constructors and Destructors
  104.          *********************************************************/
  105.  
  106.         WRegistryKey();
  107.  
  108.         ~WRegistryKey();
  109.  
  110.         /**********************************************************
  111.          * Properties
  112.          *********************************************************/
  113.  
  114.         // Handle
  115.  
  116.         WRegistryKeyHandle GetHandle() { return _key; }
  117.  
  118.         /**********************************************************
  119.          * Methods
  120.          *********************************************************/
  121.  
  122.         // Create
  123.         //
  124.         //     Note: subkey must NOT begin with the backslash character ('\')
  125.  
  126.         WBool Create( WRegistryKeyHandle key, const WString & subkey );
  127.  
  128.         // Close
  129.  
  130.         WBool Close( WBool writeToDisk=FALSE );
  131.  
  132.         // Delete
  133.  
  134.         WBool Delete( const WString & valueName );
  135.  
  136.         // EnumerateSubkey
  137.  
  138.         WBool EnumerateSubkey( WInt subkeyindex, WString & str );
  139.  
  140.         // EnumerateValue
  141.  
  142.         WBool EnumerateValue( WInt valueIndex, WString & valueName,
  143.                               WString & value );
  144.  
  145.         WBool EnumerateValue( WInt valueindex, WString &valueName,
  146.                               WRegistryDataType &dataType, WBuffer &buffer );
  147.  
  148.         WBool EnumerateValue( WInt valueindex, WString &valueName,
  149.                               WString &value, WRegistryDataType &dataType );
  150.  
  151.         // Flush
  152.  
  153.         WBool Flush();
  154.  
  155.         // Load
  156.  
  157.         WBool Load( const WString & subkey, const WString & fileName );
  158.  
  159.         // Open
  160.         //
  161.         //     Note: subkey must NOT begin with the backslash character ('\')
  162.  
  163.         WBool Open( WRegistryKeyHandle key, const WString & subkey,
  164.                     WULong access=WRegAccessAllAccess );
  165.  
  166.         // Restore
  167.  
  168.         WBool Restore( const WString & fileName, WBool voltile );
  169.  
  170.         // Save
  171.  
  172.         WBool Save( const WString & fileName );
  173.  
  174.         // Unload
  175.  
  176.         WBool Unload( const WString & subkey );
  177.  
  178.         /**********************************************************
  179.          * Item Properties
  180.          *********************************************************/
  181.     
  182.         // StringValue
  183.  
  184.         WBool SetStringValue( const WString & valueName,
  185.                               const WString & value );
  186.         WString GetStringValue( const WString & valueName );
  187.  
  188.         // Value
  189.  
  190.         WBool SetValue( const WString & valueName, WRegistryDataType dataType,
  191.                         const WBuffer & data );
  192.         WBuffer GetValue( const WString & valueName,
  193.                           WRegistryDataType dataType );
  194.  
  195.         // ValueSize
  196.  
  197.         WULong GetValueSize( const WString & valueName,
  198.                              WRegistryDataType dataType );
  199.  
  200.         /**********************************************************
  201.          * Item Methods
  202.          *********************************************************/
  203.     
  204.         // DeleteValue
  205.  
  206.         WBool DeleteValue( const WString & valueName );
  207.  
  208.         // HasStringValue
  209.  
  210.         WBool HasStringValue( const WString & valueName );
  211.  
  212.         // HasValue
  213.  
  214.         WBool HasValue( const WString & valueName,
  215.                         WRegistryDataType dataType );
  216.  
  217.         WBool HasValue( const WString & valueName );
  218.  
  219.         /**********************************************************
  220.          * Data Members
  221.          *********************************************************/
  222.     
  223.     private:
  224.  
  225.         WRegistryKeyHandle              _key;
  226. };
  227.  
  228. #ifndef _WNO_PRAGMA_PUSH
  229. #pragma enum pop;
  230. #pragma pack(pop);
  231. #endif
  232.  
  233. #endif // _WREGISTR_HPP_INCLUDED
  234.