ReactOS 0.4.16-dev-340-g0540c21
RegEnumKey.c File Reference
#include "precomp.h"
Include dependency graph for RegEnumKey.c:

Go to the source code of this file.

Functions

 START_TEST (RegEnumKey)
 

Function Documentation

◆ START_TEST()

START_TEST ( RegEnumKey  )

Definition at line 10 of file RegEnumKey.c.

11{
13 HKEY TestKey;
14 HKEY hKey;
15 WCHAR nameBuf[4];
16 DWORD nameLen;
17
18 /* Base key for our test */
21
22 /* Create 1 char subkey */
23 ErrorCode = RegCreateKeyExW(hKey, L"1", 0, NULL, 0, READ_CONTROL, NULL, &TestKey, NULL);
25 RegCloseKey(TestKey);
26
27 /* Enumerate first key with space for 1 char */
28 nameLen = 1;
29 FillMemory(nameBuf, sizeof(nameBuf), 0x55);
30 ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
32 ok_hex(nameBuf[0], 0x5555);
33 ok_hex(nameBuf[1], 0x5555);
34 ok_dec(nameLen, 1);
35
36 /* Enumerate first key with space for 2 chars */
37 nameLen = 2;
38 FillMemory(nameBuf, sizeof(nameBuf), 0x55);
39 ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
41 ok_hex(nameBuf[0], L'1');
42 ok_hex(nameBuf[1], 0);
43 ok_hex(nameBuf[2], 0x5555);
44 ok_dec(nameLen, 1);
45
46 /* Delete the subkey */
49
50 /* Create 2 char subkey */
51 ErrorCode = RegCreateKeyExW(hKey, L"12", 0, NULL, 0, READ_CONTROL, NULL, &TestKey, NULL);
53 RegCloseKey(TestKey);
54
55 /* Enumerate first key with space for 2 chars */
56 FillMemory(nameBuf, sizeof(nameBuf), 0x55);
57 nameLen = 2;
58 ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
60 ok_hex(nameBuf[0], 0x5555);
61 ok_hex(nameBuf[1], 0x5555);
62 ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen);
63
64 /* Enumerate first key with space for 3 chars */
65 FillMemory(nameBuf, sizeof(nameBuf), 0x55);
66 nameLen = 3;
67 ErrorCode = RegEnumKeyExW(hKey, 0, nameBuf, &nameLen, NULL, NULL, NULL, NULL);
69 ok_hex(nameBuf[0], L'1');
70 ok_hex(nameBuf[1], L'2');
71 ok_hex(nameBuf[2], 0);
72 ok_hex(nameBuf[3], 0x5555);
73 ok(nameLen == 2, "nameLen = %ld, expected 2\n", nameLen);
74
75 /* Delete the subkey */
78
79 /* Delete our parent key */
83}
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok(value,...)
Definition: atltest.h:57
#define ok_dec(expression, result)
Definition: atltest.h:101
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define READ_CONTROL
Definition: nt_native.h:58
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define HKEY_CURRENT_USER
Definition: winreg.h:11
__wchar_t WCHAR
Definition: xmlstorage.h:180