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.

353 lines
8.4 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. regenum.h
  5. Abstract:
  6. Set of APIs to enumerate the local registry using Win32 APIs.
  7. Author:
  8. 20-Oct-1999 Ovidiu Temereanca (ovidiut) - File creation.
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. //
  13. // Types
  14. //
  15. #define REGENUM_ALL_SUBLEVELS 0xFFFFFFFF
  16. #define REG_ATTRIBUTE_KEY 0x00000001
  17. #define REG_ATTRIBUTE_VALUE 0x00000002
  18. //
  19. // Root enumeration structures
  20. //
  21. typedef struct {
  22. PCSTR RegRootName;
  23. HKEY RegRootHandle;
  24. UINT Index;
  25. } REGROOT_ENUMA, *PREGROOT_ENUMA;
  26. typedef struct {
  27. PCWSTR RegRootName;
  28. HKEY RegRootHandle;
  29. UINT Index;
  30. } REGROOT_ENUMW, *PREGROOT_ENUMW;
  31. //
  32. // Key/Values enumeration structures
  33. //
  34. typedef enum {
  35. RECF_SKIPKEY = 0x0001,
  36. RECF_SKIPSUBKEYS = 0x0002,
  37. RECF_SKIPVALUES = 0x0004,
  38. } REGENUM_CONTROLFLAGS;
  39. typedef enum {
  40. REIF_RETURN_KEYS = 0x0001,
  41. REIF_VALUES_FIRST = 0x0002,
  42. REIF_DEPTH_FIRST = 0x0004,
  43. REIF_USE_EXCLUSIONS = 0x0008,
  44. REIF_CONTAINERS_FIRST = 0x0010,
  45. REIF_READ_VALUE_DATA = 0x0020,
  46. } REGENUMINFOFLAGS;
  47. typedef enum {
  48. RNS_ENUM_INIT,
  49. RNS_VALUE_FIRST,
  50. RNS_VALUE_NEXT,
  51. RNS_VALUE_DONE,
  52. RNS_SUBKEY_FIRST,
  53. RNS_SUBKEY_NEXT,
  54. RNS_SUBKEY_DONE,
  55. RNS_ENUM_DONE
  56. } RNS_ENUM_STATE;
  57. typedef enum {
  58. RES_ROOT_FIRST,
  59. RES_ROOT_NEXT,
  60. RES_ROOT_DONE
  61. } RES_ROOT_STATE;
  62. typedef enum {
  63. RNF_RETURN_KEYS = 0x0001,
  64. RNF_KEYNAME_MATCHES = 0x0002,
  65. RNF_VALUENAME_INVALID = 0x0004,
  66. RNF_VALUEDATA_INVALID = 0x0008,
  67. } REGNODE_FLAGS;
  68. typedef struct {
  69. PCSTR KeyName;
  70. HKEY KeyHandle;
  71. DWORD ValueCount;
  72. PSTR ValueName;
  73. DWORD ValueLengthMax;
  74. DWORD ValueType;
  75. PBYTE ValueData;
  76. DWORD ValueDataSize;
  77. DWORD ValueDataSizeMax;
  78. DWORD SubKeyCount;
  79. PSTR SubKeyName;
  80. DWORD SubKeyLengthMax;
  81. DWORD SubKeyIndex;
  82. DWORD ValueIndex;
  83. DWORD EnumState;
  84. DWORD Flags;
  85. DWORD SubLevel;
  86. } REGNODEA, *PREGNODEA;
  87. typedef struct {
  88. PCWSTR KeyName;
  89. HKEY KeyHandle;
  90. DWORD ValueCount;
  91. PWSTR ValueName;
  92. DWORD ValueLengthMax;
  93. DWORD ValueType;
  94. PBYTE ValueData;
  95. DWORD ValueDataSize;
  96. DWORD ValueDataSizeMax;
  97. DWORD SubKeyCount;
  98. PWSTR SubKeyName;
  99. DWORD SubKeyLengthMax;
  100. DWORD SubKeyIndex;
  101. DWORD ValueIndex;
  102. DWORD EnumState;
  103. DWORD Flags;
  104. DWORD SubLevel;
  105. } REGNODEW, *PREGNODEW;
  106. typedef BOOL (*RPE_ERROR_CALLBACKA)(PREGNODEA);
  107. typedef struct {
  108. POBSPARSEDPATTERNA RegPattern;
  109. DWORD Flags;
  110. DWORD RootLevel;
  111. DWORD MaxSubLevel;
  112. RPE_ERROR_CALLBACKA CallbackOnError;
  113. } REGENUMINFOA, *PREGENUMINFOA;
  114. typedef BOOL (*RPE_ERROR_CALLBACKW)(PREGNODEW);
  115. typedef struct {
  116. POBSPARSEDPATTERNW RegPattern;
  117. DWORD Flags;
  118. DWORD RootLevel;
  119. DWORD MaxSubLevel;
  120. RPE_ERROR_CALLBACKW CallbackOnError;
  121. } REGENUMINFOW, *PREGENUMINFOW;
  122. typedef struct {
  123. PCSTR EncodedFullName;
  124. PCSTR Name;
  125. PCSTR Location;
  126. CHAR NativeFullName[2 * MAX_MBCHAR_PATH];
  127. PBYTE CurrentValueData;
  128. UINT CurrentValueDataSize;
  129. DWORD CurrentValueType;
  130. HKEY CurrentKeyHandle;
  131. DWORD CurrentLevel;
  132. DWORD Attributes;
  133. //
  134. // Private members
  135. //
  136. DWORD ControlFlags;
  137. REGENUMINFOA RegEnumInfo;
  138. GROWBUFFER RegNodes;
  139. DWORD RootState;
  140. PREGROOT_ENUMA RootEnum;
  141. PREGNODEA LastNode;
  142. PSTR RegNameAppendPos;
  143. PSTR LastWackPtr;
  144. } REGTREE_ENUMA, *PREGTREE_ENUMA;
  145. typedef struct {
  146. PCWSTR EncodedFullName;
  147. PCWSTR Name;
  148. PCWSTR Location;
  149. WCHAR NativeFullName[2 * MAX_WCHAR_PATH];
  150. PBYTE CurrentValueData;
  151. UINT CurrentValueDataSize;
  152. DWORD CurrentValueType;
  153. HKEY CurrentKeyHandle;
  154. DWORD CurrentLevel;
  155. DWORD Attributes;
  156. //
  157. // Private members
  158. //
  159. DWORD ControlFlags;
  160. REGENUMINFOW RegEnumInfo;
  161. GROWBUFFER RegNodes;
  162. DWORD RootState;
  163. PREGROOT_ENUMW RootEnum;
  164. PREGNODEW LastNode;
  165. PWSTR RegNameAppendPos;
  166. PWSTR LastWackPtr;
  167. } REGTREE_ENUMW, *PREGTREE_ENUMW;
  168. //
  169. // API
  170. //
  171. BOOL
  172. RegEnumDefaultCallbackA (
  173. IN PREGNODEA RegNode OPTIONAL
  174. );
  175. BOOL
  176. RegEnumDefaultCallbackW (
  177. IN PREGNODEW RegNode OPTIONAL
  178. );
  179. BOOL
  180. EnumFirstRegRootA (
  181. OUT PREGROOT_ENUMA EnumPtr
  182. );
  183. BOOL
  184. EnumFirstRegRootW (
  185. OUT PREGROOT_ENUMW EnumPtr
  186. );
  187. BOOL
  188. EnumNextRegRootA (
  189. IN OUT PREGROOT_ENUMA EnumPtr
  190. );
  191. BOOL
  192. EnumNextRegRootW (
  193. IN OUT PREGROOT_ENUMW EnumPtr
  194. );
  195. BOOL
  196. EnumFirstRegObjectInTreeExA (
  197. OUT PREGTREE_ENUMA RegEnum,
  198. IN PCSTR EncodedRegPattern,
  199. IN BOOL EnumKeyNames,
  200. IN BOOL ContainersFirst,
  201. IN BOOL ValuesFirst,
  202. IN BOOL DepthFirst,
  203. IN DWORD MaxSubLevel,
  204. IN BOOL UseExclusions,
  205. IN BOOL ReadValueData,
  206. IN RPE_ERROR_CALLBACKA CallbackOnError OPTIONAL
  207. );
  208. #define EnumFirstRegObjectInTreeA(e,p) EnumFirstRegObjectInTreeExA(e,p,TRUE,TRUE,TRUE,TRUE,REGENUM_ALL_SUBLEVELS,FALSE,FALSE,RegEnumDefaultCallbackA)
  209. BOOL
  210. EnumFirstRegObjectInTreeExW (
  211. OUT PREGTREE_ENUMW RegEnum,
  212. IN PCWSTR EncodedKeyPattern,
  213. IN BOOL EnumKeyNames,
  214. IN BOOL ContainersFirst,
  215. IN BOOL ValuesFirst,
  216. IN BOOL DepthFirst,
  217. IN DWORD MaxSubLevel,
  218. IN BOOL UseExclusions,
  219. IN BOOL ReadValueData,
  220. IN RPE_ERROR_CALLBACKW CallbackOnError OPTIONAL
  221. );
  222. #define EnumFirstRegObjectInTreeW(e,p) EnumFirstRegObjectInTreeExW(e,p,TRUE,TRUE,TRUE,TRUE,REGENUM_ALL_SUBLEVELS,FALSE,FALSE,RegEnumDefaultCallbackW)
  223. BOOL
  224. EnumNextRegObjectInTreeA (
  225. IN OUT PREGTREE_ENUMA RegEnum
  226. );
  227. BOOL
  228. EnumNextRegObjectInTreeW (
  229. IN OUT PREGTREE_ENUMW RegEnum
  230. );
  231. VOID
  232. AbortRegObjectInTreeEnumA (
  233. IN OUT PREGTREE_ENUMA RegEnum
  234. );
  235. VOID
  236. AbortRegObjectInTreeEnumW (
  237. IN OUT PREGTREE_ENUMW RegEnum
  238. );
  239. BOOL
  240. RgRemoveAllValuesInKeyA (
  241. IN PCSTR KeyToRemove
  242. );
  243. BOOL
  244. RgRemoveAllValuesInKeyW (
  245. IN PCWSTR KeyToRemove
  246. );
  247. BOOL
  248. RgRemoveKeyA (
  249. IN PCSTR KeyToRemove
  250. );
  251. BOOL
  252. RgRemoveKeyW (
  253. IN PCWSTR KeyToRemove
  254. );
  255. //
  256. // Macros
  257. //
  258. #ifdef UNICODE
  259. #define RegEnumDefaultCallback RegEnumDefaultCallbackW
  260. #define REGROOT_ENUM REGROOT_ENUMW
  261. #define EnumFirstRegRoot EnumFirstRegRootW
  262. #define EnumNextRegRoot EnumNextRegRootW
  263. #define REGNODE REGNODEW
  264. #define PREGNODE PREGNODEW
  265. #define RPE_ERROR_CALLBACK RPE_ERROR_CALLBACKW
  266. #define REGENUMINFO REGENUMINFOW
  267. #define PREGENUMINFO PREGENUMINFOW
  268. #define REGTREE_ENUM REGTREE_ENUMW
  269. #define PREGTREE_ENUM PREGTREE_ENUMW
  270. #define EnumFirstRegObjectInTree EnumFirstRegObjectInTreeW
  271. #define EnumFirstRegObjectInTreeEx EnumFirstRegObjectInTreeExW
  272. #define EnumNextRegObjectInTree EnumNextRegObjectInTreeW
  273. #define AbortRegObjectInTreeEnum AbortRegObjectInTreeEnumW
  274. #define RgRemoveAllValuesInKey RgRemoveAllValuesInKeyW
  275. #define RgRemoveKey RgRemoveKeyW
  276. #else
  277. #define RegEnumDefaultCallback RegEnumDefaultCallbackA
  278. #define REGROOT_ENUM REGROOT_ENUMA
  279. #define EnumFirstRegRoot EnumFirstRegRootA
  280. #define EnumNextRegRoot EnumNextRegRootA
  281. #define REGNODE REGNODEA
  282. #define PREGNODE PREGNODEA
  283. #define RPE_ERROR_CALLBACK RPE_ERROR_CALLBACKA
  284. #define REGENUMINFO REGENUMINFOA
  285. #define PREGENUMINFO PREGENUMINFOA
  286. #define REGTREE_ENUM REGTREE_ENUMA
  287. #define PREGTREE_ENUM PREGTREE_ENUMA
  288. #define EnumFirstRegObjectInTree EnumFirstRegObjectInTreeA
  289. #define EnumFirstRegObjectInTreeEx EnumFirstRegObjectInTreeExA
  290. #define EnumNextRegObjectInTree EnumNextRegObjectInTreeA
  291. #define AbortRegObjectInTreeEnum AbortRegObjectInTreeEnumA
  292. #define RgRemoveAllValuesInKey RgRemoveAllValuesInKeyA
  293. #define RgRemoveKey RgRemoveKeyA
  294. #endif