home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / hpp.z / WREGISTR.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-10  |  7.0 KB  |  218 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,4);
  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.     WRegDataString              = 1,
  49.     WRegDataBinary              = 3,
  50.     WRegDataDWord               = 4,
  51. };
  52.  
  53. enum WAccessType {
  54.     WAccessDelete                       = 0x00010000L,
  55.     WAccessReadControl                  = 0x00020000L,
  56.     WAccessWriteDAC                     = 0x00040000L,
  57.     WAccessWriteOwner                   = 0x00080000L,
  58.     WAccessSynchronize                  = 0x00100000L,
  59.     WAccessStandardRightsRequired       = 0x000F0000L,
  60.     WAccessStandardRightsRead           = WAccessReadControl,
  61.     WAccessStandardRightsWrite          = WAccessReadControl,
  62.     WAccessStandardRightsExecute        = WAccessReadControl,
  63.     WAccessStandardRightsAll            = 0x001F0000L,
  64.     WAccessSpecificRightsAll            = 0x0000FFFFL,
  65. };
  66.  
  67. enum WRegistryAccessType {
  68.     WRegAccessQueryValue = 0x0001,
  69.     WRegAccessSetValue = 0x0002,
  70.     WRegAccessCreateSubkey = 0x0004,
  71.     WRegAccessEnumerateSubkeys = 0x0008,
  72.     WRegAccessNotify = 0x0010,
  73.     WRegAccessCreateLink = 0x0020,
  74.     WRegAccessRead      = ((WAccessStandardRightsRead | WRegAccessQueryValue
  75.                             | WRegAccessEnumerateSubkeys | WRegAccessNotify)
  76.                           & (~WAccessSynchronize)),
  77.     WRegAccessWrite     = ((WAccessStandardRightsWrite | WRegAccessSetValue
  78.                             | WRegAccessCreateSubkey)
  79.                           & (~WAccessSynchronize)),
  80.     WRegAccessExecute   = ((WRegAccessRead)
  81.                           & (~WAccessSynchronize)),
  82.     WRegAccessAllAccess = ((WAccessStandardRightsAll | WRegAccessQueryValue
  83.                             | WRegAccessSetValue | WRegAccessCreateSubkey
  84.                             | WRegAccessEnumerateSubkeys
  85.                             | WRegAccessNotify | WRegAccessCreateLink)
  86.                           & (~WAccessSynchronize))
  87. };
  88.  
  89. class WCMCLASS WRegistryKey : public WObject {
  90.     WDeclareSubclass( WRegistryKey, WObject )
  91.  
  92.     public:
  93.     
  94.         /**********************************************************
  95.          * Constructors and Destructors
  96.          *********************************************************/
  97.  
  98.         WRegistryKey();
  99.  
  100.         ~WRegistryKey();
  101.  
  102.         /**********************************************************
  103.          * Properties
  104.          *********************************************************/
  105.  
  106.         // Handle
  107.  
  108.         WRegistryKeyHandle GetHandle() { return _key; }
  109.  
  110.         /**********************************************************
  111.          * Methods
  112.          *********************************************************/
  113.  
  114.         // Create
  115.         //
  116.         //     Note: subkey must NOT begin with the backslash character ('\')
  117.  
  118.         WBool Create( WRegistryKeyHandle key, const WString & subkey );
  119.  
  120.         // Close
  121.  
  122.         WBool Close( WBool writeToDisk=FALSE );
  123.  
  124.         // Delete
  125.  
  126.         WBool Delete( const WString & valueName );
  127.  
  128.         // EnumerateSubkey
  129.  
  130.         WBool EnumerateSubkey( WInt subkeyindex, WString & str );
  131.  
  132.         // EnumerateValue
  133.  
  134.         WBool EnumerateValue( WInt valueIndex, WString & valueName,
  135.                               WString & value );
  136.  
  137.         // Flush
  138.  
  139.         WBool Flush();
  140.  
  141.         // Load
  142.  
  143.         WBool Load( const WString & subkey, const WString & fileName );
  144.  
  145.         // Open
  146.         //
  147.         //     Note: subkey must NOT begin with the backslash character ('\')
  148.  
  149.         WBool Open( WRegistryKeyHandle key, const WString & subkey,
  150.                     WULong access=WRegAccessAllAccess );
  151.  
  152.         // Restore
  153.  
  154.         WBool Restore( const WString & fileName, WBool voltile );
  155.  
  156.         // Save
  157.  
  158.         WBool Save( const WString & fileName );
  159.  
  160.         // Unload
  161.  
  162.         WBool Unload( const WString & subkey );
  163.  
  164.         /**********************************************************
  165.          * Item Properties
  166.          *********************************************************/
  167.     
  168.         // StringValue
  169.  
  170.         WBool SetStringValue( const WString & valueName,
  171.                               const WString & value );
  172.         WString GetStringValue( const WString & valueName );
  173.  
  174.         // Value
  175.  
  176.         WBool SetValue( const WString & valueName, WRegistryDataType dataType,
  177.                         const WBuffer & data );
  178.         WBuffer GetValue( const WString & valueName,
  179.                           WRegistryDataType dataType );
  180.  
  181.         // ValueSize
  182.  
  183.         WULong GetValueSize( const WString & valueName,
  184.                              WRegistryDataType dataType );
  185.  
  186.         /**********************************************************
  187.          * Item Methods
  188.          *********************************************************/
  189.     
  190.         // DeleteValue
  191.  
  192.         WBool DeleteValue( const WString & valueName );
  193.  
  194.         // HasStringValue
  195.  
  196.         WBool HasStringValue( const WString & valueName );
  197.  
  198.         // HasValue
  199.  
  200.         WBool HasValue( const WString & valueName,
  201.                         WRegistryDataType dataType );
  202.  
  203.         /**********************************************************
  204.          * Data Members
  205.          *********************************************************/
  206.     
  207.     private:
  208.  
  209.         WRegistryKeyHandle              _key;
  210. };
  211.  
  212. #ifndef _WNO_PRAGMA_PUSH
  213. #pragma enum pop;
  214. #pragma pack(pop);
  215. #endif
  216.  
  217. #endif // _WREGISTR_HPP_INCLUDED
  218.