2 * PROJECT: ReactOS API tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for the RegEnumKey API
5 * PROGRAMMER: Thomas Faber & Doug Lyons
10 START_TEST(RegEnumKey
)
18 /* Base key for our test */
19 ErrorCode
= RegCreateKeyExW(HKEY_CURRENT_USER
, L
"Software\\ReactOS_apitest", 0, NULL
, 0, KEY_CREATE_SUB_KEY
| KEY_ENUMERATE_SUB_KEYS
, NULL
, &hKey
, NULL
);
20 ok_dec(ErrorCode
, ERROR_SUCCESS
);
22 /* Create 1 char subkey */
23 ErrorCode
= RegCreateKeyExW(hKey
, L
"1", 0, NULL
, 0, READ_CONTROL
, NULL
, &TestKey
, NULL
);
24 ok_dec(ErrorCode
, ERROR_SUCCESS
);
27 /* Enumerate first key with space for 1 char */
29 FillMemory(nameBuf
, sizeof(nameBuf
), 0x55);
30 ErrorCode
= RegEnumKeyExW(hKey
, 0, nameBuf
, &nameLen
, NULL
, NULL
, NULL
, NULL
);
31 ok_dec(ErrorCode
, ERROR_MORE_DATA
);
32 ok_hex(nameBuf
[0], 0x5555);
33 ok_hex(nameBuf
[1], 0x5555);
36 /* Enumerate first key with space for 2 chars */
38 FillMemory(nameBuf
, sizeof(nameBuf
), 0x55);
39 ErrorCode
= RegEnumKeyExW(hKey
, 0, nameBuf
, &nameLen
, NULL
, NULL
, NULL
, NULL
);
40 ok_dec(ErrorCode
, ERROR_SUCCESS
);
41 ok_hex(nameBuf
[0], L
'1');
42 ok_hex(nameBuf
[1], 0);
43 ok_hex(nameBuf
[2], 0x5555);
46 /* Delete the subkey */
47 ErrorCode
= RegDeleteKeyW(hKey
, L
"1");
48 ok_dec(ErrorCode
, ERROR_SUCCESS
);
50 /* Create 2 char subkey */
51 ErrorCode
= RegCreateKeyExW(hKey
, L
"12", 0, NULL
, 0, READ_CONTROL
, NULL
, &TestKey
, NULL
);
52 ok_dec(ErrorCode
, ERROR_SUCCESS
);
55 /* Enumerate first key with space for 2 chars */
56 FillMemory(nameBuf
, sizeof(nameBuf
), 0x55);
58 ErrorCode
= RegEnumKeyExW(hKey
, 0, nameBuf
, &nameLen
, NULL
, NULL
, NULL
, NULL
);
59 ok_dec(ErrorCode
, ERROR_MORE_DATA
);
60 ok_hex(nameBuf
[0], 0x5555);
61 ok_hex(nameBuf
[1], 0x5555);
62 ok(nameLen
== 2, "nameLen = %ld, expected 2\n", nameLen
);
64 /* Enumerate first key with space for 3 chars */
65 FillMemory(nameBuf
, sizeof(nameBuf
), 0x55);
67 ErrorCode
= RegEnumKeyExW(hKey
, 0, nameBuf
, &nameLen
, NULL
, NULL
, NULL
, NULL
);
68 ok_dec(ErrorCode
, ERROR_SUCCESS
);
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
);
75 /* Delete the subkey */
76 ErrorCode
= RegDeleteKeyW(hKey
, L
"12");
77 ok_dec(ErrorCode
, ERROR_SUCCESS
);
79 /* Delete our parent key */
80 ErrorCode
= RegDeleteKeyW(hKey
, L
"");
81 ok_dec(ErrorCode
, ERROR_SUCCESS
);