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.

78 lines
2.2 KiB

  1. /*++
  2. Copyright (C) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. REG.H
  5. Abstract:
  6. Utility Registry classes
  7. History:
  8. a-raymcc 30-May-96 Created.
  9. --*/
  10. #ifndef _REG_H_
  11. #define _REG_H_
  12. #include "corepol.h"
  13. #define WBEM_REG_WBEM __TEXT("Software\\Microsoft\\WBEM")
  14. #define WBEM_REG_WINMGMT __TEXT("Software\\Microsoft\\WBEM\\CIMOM")
  15. class POLARITY Registry
  16. {
  17. HKEY hPrimaryKey;
  18. HKEY hSubkey;
  19. int nStatus;
  20. LONG m_nLastError;
  21. public:
  22. enum { no_error, failed };
  23. int Open(HKEY hStart, TCHAR *pszStartKey);
  24. Registry(TCHAR *pszLocalMachineStartKey);
  25. // This create a special read only version which is usefull for marshalling
  26. // clients which are running with a lower priviledge set.
  27. Registry();
  28. Registry(HKEY hRoot, REGSAM flags, TCHAR *pszStartKey);
  29. Registry(HKEY hRoot, DWORD dwOptions, REGSAM flags, TCHAR *pszStartKey);
  30. ~Registry();
  31. int MoveToSubkey(TCHAR *pszNewSubkey);
  32. int GetDWORD(TCHAR *pszValueName, DWORD *pdwValue);
  33. int GetDWORDStr(TCHAR *pszValueName, DWORD *pdwValue);
  34. int GetStr(TCHAR *pszValue, TCHAR **pValue);
  35. // It is the callers responsibility to delete pData
  36. int GetBinary(TCHAR *pszValue, byte ** pData, DWORD * pdwSize);
  37. int SetBinary(TCHAR *pszValue, byte * pData, DWORD dwSize);
  38. //Returns a pointer to a string buffer containing the null-terminated string.
  39. //The last entry is a double null terminator (i.e. the registry format for
  40. //a REG_MULTI_SZ). Caller has do "delete []" the returned pointer.
  41. //dwSize is the size of the buffer returned.
  42. TCHAR* GetMultiStr(TCHAR *pszValueName, DWORD &dwSize);
  43. int SetDWORD(TCHAR *pszValueName, DWORD dwValue);
  44. int SetDWORDStr(TCHAR *pszValueName, DWORD dwValue);
  45. int SetStr(TCHAR *pszValueName, TCHAR *psvValue);
  46. int SetExpandStr(TCHAR *pszValueName, TCHAR *psvValue);
  47. //pData should be passed in with the last entry double null terminated.
  48. //(i.e. the registry format for a REG_MULTI_SZ).
  49. int SetMultiStr(TCHAR *pszValueName, TCHAR* pData, DWORD dwSize);
  50. LONG GetLastError() { return m_nLastError; }
  51. int DeleteValue(TCHAR *pszValueName);
  52. int GetType(TCHAR *pszValueName, DWORD *pdwType);
  53. };
  54. #endif