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.

332 lines
7.7 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. } REGENUMINFOFLAGS;
  45. typedef enum {
  46. RNS_ENUM_INIT,
  47. RNS_VALUE_FIRST,
  48. RNS_VALUE_NEXT,
  49. RNS_VALUE_DONE,
  50. RNS_SUBKEY_FIRST,
  51. RNS_SUBKEY_NEXT,
  52. RNS_SUBKEY_DONE,
  53. RNS_ENUM_DONE
  54. } RNS_ENUM_STATE;
  55. typedef enum {
  56. RES_ROOT_FIRST,
  57. RES_ROOT_NEXT,
  58. RES_ROOT_DONE
  59. } RES_ROOT_STATE;
  60. typedef enum {
  61. RNF_RETURN_KEYS = 0x0001,
  62. RNF_KEYNAME_MATCHES = 0x0002,
  63. RNF_VALUENAME_INVALID = 0x0004,
  64. RNF_VALUEDATA_INVALID = 0x0008,
  65. } REGNODE_FLAGS;
  66. typedef struct {
  67. PCSTR KeyName;
  68. HKEY KeyHandle;
  69. DWORD ValueCount;
  70. PSTR ValueName;
  71. DWORD ValueLengthMax;
  72. DWORD ValueType;
  73. PBYTE ValueData;
  74. DWORD ValueDataSize;
  75. DWORD ValueDataSizeMax;
  76. DWORD SubKeyCount;
  77. PSTR SubKeyName;
  78. DWORD SubKeyLengthMax;
  79. DWORD SubKeyIndex;
  80. DWORD ValueIndex;
  81. DWORD EnumState;
  82. DWORD Flags;
  83. DWORD SubLevel;
  84. } REGNODEA, *PREGNODEA;
  85. typedef struct {
  86. PCWSTR KeyName;
  87. HKEY KeyHandle;
  88. DWORD ValueCount;
  89. PWSTR ValueName;
  90. DWORD ValueLengthMax;
  91. DWORD ValueType;
  92. PBYTE ValueData;
  93. DWORD ValueDataSize;
  94. DWORD ValueDataSizeMax;
  95. DWORD SubKeyCount;
  96. PWSTR SubKeyName;
  97. DWORD SubKeyLengthMax;
  98. DWORD SubKeyIndex;
  99. DWORD ValueIndex;
  100. DWORD EnumState;
  101. DWORD Flags;
  102. DWORD SubLevel;
  103. } REGNODEW, *PREGNODEW;
  104. typedef BOOL (*RPE_ERROR_CALLBACKA)(PREGNODEA);
  105. typedef struct {
  106. POBSPARSEDPATTERNA RegPattern;
  107. DWORD Flags;
  108. DWORD RootLevel;
  109. DWORD MaxSubLevel;
  110. RPE_ERROR_CALLBACKA CallbackOnError;
  111. } REGENUMINFOA, *PREGENUMINFOA;
  112. typedef BOOL (*RPE_ERROR_CALLBACKW)(PREGNODEW);
  113. typedef struct {
  114. POBSPARSEDPATTERNW RegPattern;
  115. DWORD Flags;
  116. DWORD RootLevel;
  117. DWORD MaxSubLevel;
  118. RPE_ERROR_CALLBACKW CallbackOnError;
  119. } REGENUMINFOW, *PREGENUMINFOW;
  120. typedef struct {
  121. PCSTR EncodedFullName;
  122. PCSTR Name;
  123. PCSTR Location;
  124. CHAR NativeFullName[MAX_MBCHAR_PATH];
  125. PBYTE CurrentValueData;
  126. DWORD CurrentValueType;
  127. HKEY CurrentKeyHandle;
  128. DWORD CurrentLevel;
  129. DWORD Attributes;
  130. //
  131. // Private members
  132. //
  133. DWORD ControlFlags;
  134. REGENUMINFOA RegEnumInfo;
  135. GROWBUFFER RegNodes;
  136. DWORD RootState;
  137. PREGROOT_ENUMA RootEnum;
  138. PREGNODEA LastNode;
  139. PSTR RegNameAppendPos;
  140. PSTR LastWackPtr;
  141. } REGTREE_ENUMA, *PREGTREE_ENUMA;
  142. typedef struct {
  143. PCWSTR EncodedFullName;
  144. PCWSTR Name;
  145. PCWSTR Location;
  146. WCHAR NativeFullName[MAX_WCHAR_PATH];
  147. PBYTE CurrentValueData;
  148. DWORD CurrentValueType;
  149. HKEY CurrentKeyHandle;
  150. DWORD CurrentLevel;
  151. DWORD Attributes;
  152. //
  153. // Private members
  154. //
  155. DWORD ControlFlags;
  156. REGENUMINFOW RegEnumInfo;
  157. GROWBUFFER RegNodes;
  158. DWORD RootState;
  159. PREGROOT_ENUMW RootEnum;
  160. PREGNODEW LastNode;
  161. PWSTR RegNameAppendPos;
  162. PWSTR LastWackPtr;
  163. } REGTREE_ENUMW, *PREGTREE_ENUMW;
  164. //
  165. // API
  166. //
  167. BOOL
  168. RegEnumInitialize (
  169. VOID
  170. );
  171. VOID
  172. RegEnumTerminate (
  173. VOID
  174. );
  175. BOOL
  176. RegEnumDefaultCallbackA (
  177. IN PREGNODEA RegNode OPTIONAL
  178. );
  179. BOOL
  180. RegEnumDefaultCallbackW (
  181. IN PREGNODEW RegNode OPTIONAL
  182. );
  183. BOOL
  184. EnumFirstRegRootA (
  185. OUT PREGROOT_ENUMA EnumPtr
  186. );
  187. BOOL
  188. EnumFirstRegRootW (
  189. OUT PREGROOT_ENUMW EnumPtr
  190. );
  191. BOOL
  192. EnumNextRegRootA (
  193. IN OUT PREGROOT_ENUMA EnumPtr
  194. );
  195. BOOL
  196. EnumNextRegRootW (
  197. IN OUT PREGROOT_ENUMW EnumPtr
  198. );
  199. BOOL
  200. EnumFirstRegObjectInTreeExA (
  201. OUT PREGTREE_ENUMA RegEnum,
  202. IN PCSTR EncodedRegPattern,
  203. IN BOOL EnumKeyNames,
  204. IN BOOL ValuesFirst,
  205. IN BOOL DepthFirst,
  206. IN DWORD MaxSubLevel,
  207. IN BOOL UseExclusions,
  208. IN RPE_ERROR_CALLBACKA CallbackOnError OPTIONAL
  209. );
  210. #define EnumFirstRegObjectInTreeA(e,p) EnumFirstRegObjectInTreeExA(e,p,TRUE,TRUE,TRUE,REGENUM_ALL_SUBLEVELS,FALSE,RegEnumDefaultCallbackA)
  211. BOOL
  212. EnumFirstRegObjectInTreeExW (
  213. OUT PREGTREE_ENUMW RegEnum,
  214. IN PCWSTR EncodedKeyPattern,
  215. IN BOOL EnumKeyNames,
  216. IN BOOL ValuesFirst,
  217. IN BOOL DepthFirst,
  218. IN DWORD MaxSubLevel,
  219. IN BOOL UseExclusions,
  220. IN RPE_ERROR_CALLBACKW CallbackOnError OPTIONAL
  221. );
  222. #define EnumFirstRegObjectInTreeW(e,p) EnumFirstRegObjectInTreeExW(e,p,TRUE,TRUE,TRUE,REGENUM_ALL_SUBLEVELS,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. AbortEnumRegObjectInTreeA (
  233. IN OUT PREGTREE_ENUMA RegEnum
  234. );
  235. VOID
  236. AbortEnumRegObjectInTreeW (
  237. IN OUT PREGTREE_ENUMW RegEnum
  238. );
  239. //
  240. // Macros
  241. //
  242. #ifdef UNICODE
  243. #define RegEnumDefaultCallback RegEnumDefaultCallbackW
  244. #define REGROOT_ENUM REGROOT_ENUMW
  245. #define EnumFirstRegRoot EnumFirstRegRootW
  246. #define EnumNextRegRoot EnumNextRegRootW
  247. #define REGNODE REGNODEW
  248. #define PREGNODE PREGNODEW
  249. #define RPE_ERROR_CALLBACK RPE_ERROR_CALLBACKW
  250. #define REGENUMINFO REGENUMINFOW
  251. #define PREGENUMINFO PREGENUMINFOW
  252. #define REGTREE_ENUM REGTREE_ENUMW
  253. #define PREGTREE_ENUM PREGTREE_ENUMW
  254. #define EnumFirstRegObjectInTree EnumFirstRegObjectInTreeW
  255. #define EnumFirstRegObjectInTreeEx EnumFirstRegObjectInTreeExW
  256. #define EnumNextRegObjectInTree EnumNextRegObjectInTreeW
  257. #define AbortEnumRegObjectInTree AbortEnumRegObjectInTreeW
  258. #else
  259. #define RegEnumDefaultCallback RegEnumDefaultCallbackA
  260. #define REGROOT_ENUM REGROOT_ENUMA
  261. #define EnumFirstRegRoot EnumFirstRegRootA
  262. #define EnumNextRegRoot EnumNextRegRootA
  263. #define REGNODE REGNODEA
  264. #define PREGNODE PREGNODEA
  265. #define RPE_ERROR_CALLBACK RPE_ERROR_CALLBACKA
  266. #define REGENUMINFO REGENUMINFOA
  267. #define PREGENUMINFO PREGENUMINFOA
  268. #define REGTREE_ENUM REGTREE_ENUMA
  269. #define PREGTREE_ENUM PREGTREE_ENUMA
  270. #define EnumFirstRegObjectInTree EnumFirstRegObjectInTreeA
  271. #define EnumFirstRegObjectInTreeEx EnumFirstRegObjectInTreeExA
  272. #define EnumNextRegObjectInTree EnumNextRegObjectInTreeA
  273. #define AbortEnumRegObjectInTree AbortEnumRegObjectInTreeA
  274. #endif