诸暨麻将添加redis
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

104 行
2.4 KiB

  1. #ifndef WH_REG_KEY_HEAD_FILE
  2. #define WH_REG_KEY_HEAD_FILE
  3. #pragma once
  4. #include "ServiceCoreHead.h"
  5. //////////////////////////////////////////////////////////////////////////////////
  6. //键项组手
  7. class SERVICE_CORE_CLASS CWHRegKey
  8. {
  9. //键项变量
  10. protected:
  11. HKEY m_hRegKey; //当前键项
  12. //静态变量
  13. protected:
  14. static TCHAR m_szMainKeyName[64]; //主键名字
  15. //函数定义
  16. public:
  17. //构造函数
  18. CWHRegKey();
  19. //析构函数
  20. virtual ~CWHRegKey();
  21. //配置函数
  22. public:
  23. //设置主键
  24. static VOID SetMainKeyName(LPCTSTR pszMainKeyName);
  25. //获取主键
  26. static LPCTSTR GetMainKeyName() { return m_szMainKeyName; }
  27. //绑定函数
  28. public:
  29. //解除绑定
  30. HKEY Detach();
  31. //绑定键项
  32. HKEY Attach(HKEY hRegKey);
  33. //管理函数
  34. public:
  35. //关闭键项
  36. bool CloseRegKey();
  37. //打开键项
  38. bool OpenRegKey(LPCTSTR pszKeyName, bool bCreate);
  39. //打开键项
  40. bool OpenRegKey(LPCTSTR pszMainKeyName, LPCTSTR pszKeyName, bool bCreate);
  41. //控制函数
  42. public:
  43. //打开键项
  44. HKEY OpenItemKey(LPCTSTR pszSubKeyName);
  45. //创建键项
  46. HKEY CreateItemKey(LPCTSTR pszSubKeyName);
  47. //枚举键项
  48. bool EnumItemString(DWORD dwIndex, LPTSTR pszString, DWORD dwSize);
  49. //写入函数
  50. public:
  51. //写入数值
  52. bool WriteValue(LPCTSTR pszName, DWORD dwValue);
  53. //写入字符
  54. bool WriteString(LPCTSTR pszName, LPCTSTR pszString);
  55. //写入字符
  56. bool WriteEncryptString(LPCTSTR pszName, LPCTSTR pszString);
  57. //写入数据
  58. bool WriteBinary(LPCTSTR pszName, const VOID * pData, DWORD dwSize);
  59. //读取函数
  60. public:
  61. //读取数值
  62. DWORD GetValue(LPCTSTR pszName, DWORD dwDefValue);
  63. //读取数据
  64. DWORD GetBinary(LPCTSTR pszName, VOID * pData, DWORD dwBufferSize);
  65. //读取字符
  66. DWORD GetString(LPCTSTR pszName, LPTSTR pszString, UINT uMaxCount);
  67. //读取字符
  68. DWORD GetEncryptString(LPCTSTR pszName, LPTSTR pszString, UINT uMaxCount);
  69. //删除函数
  70. public:
  71. //删除数值
  72. bool DeleteValue(LPCTSTR pszName);
  73. //删除键项
  74. bool RecurseDeleteKey(LPCTSTR pszSubKeyName);
  75. //辅助函数
  76. public:
  77. //键项重载
  78. operator HKEY() { return m_hRegKey; }
  79. //获取键项
  80. HKEY GetRegKey() { return m_hRegKey; }
  81. //内部函数
  82. private:
  83. //删除键项
  84. LONG RecurseDeleteKey(HKEY hParentKey, LPCTSTR pszSubKeyName);
  85. };
  86. //////////////////////////////////////////////////////////////////////////////////
  87. #endif