2 * Unit tests for registry functions
4 * Copyright (c) 2002 Alexandre Julliard
5 * Copyright (c) 2010 André Hentschel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
23 #define WIN32_LEAN_AND_MEAN
28 #include "wine/test.h"
31 #include "wine/winternl.h"
37 #define IS_HKCR(hk) ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == 2)
39 static HKEY hkey_main
;
42 static const char * sTestpath1
= "%LONGSYSTEMVAR%\\subdir1";
43 static const char * sTestpath2
= "%FOO%\\subdir1";
44 static const DWORD ptr_size
= 8 * sizeof(void*);
46 static DWORD (WINAPI
*pRegGetValueA
)(HKEY
,LPCSTR
,LPCSTR
,DWORD
,LPDWORD
,PVOID
,LPDWORD
);
47 static DWORD (WINAPI
*pRegDeleteTreeA
)(HKEY
,LPCSTR
);
48 static DWORD (WINAPI
*pRegDeleteKeyExA
)(HKEY
,LPCSTR
,REGSAM
,DWORD
);
49 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
,PBOOL
);
50 static NTSTATUS (WINAPI
* pNtDeleteKey
)(HANDLE
);
51 static NTSTATUS (WINAPI
* pRtlFormatCurrentUserKeyPath
)(UNICODE_STRING
*);
52 static NTSTATUS (WINAPI
* pRtlFreeUnicodeString
)(PUNICODE_STRING
);
53 static LONG (WINAPI
*pRegDeleteKeyValueA
)(HKEY
,LPCSTR
,LPCSTR
);
54 static LONG (WINAPI
*pRegSetKeyValueW
)(HKEY
,LPCWSTR
,LPCWSTR
,DWORD
,const void*,DWORD
);
56 static BOOL limited_user
;
59 /* Debugging functions from wine/libs/wine/debug.c */
61 /* allocate some tmp string space */
62 /* FIXME: this is not 100% thread-safe */
63 static char *get_temp_buffer( int size
)
65 static char *list
[32];
70 idx
= ++pos
% (sizeof(list
)/sizeof(list
[0]));
72 ret
= HeapReAlloc( GetProcessHeap(), 0, list
[idx
], size
);
74 ret
= HeapAlloc( GetProcessHeap(), 0, size
);
75 if (ret
) list
[idx
] = ret
;
79 static const char *wine_debugstr_an( const char *str
, int n
)
81 static const char hex
[16] = "0123456789abcdef";
85 if (!((ULONG_PTR
)str
>> 16))
87 if (!str
) return "(null)";
88 res
= get_temp_buffer( 6 );
89 sprintf( res
, "#%04x", LOWORD(str
) );
92 if (n
== -1) n
= strlen(str
);
94 size
= 10 + min( 300, n
* 4 );
95 dst
= res
= get_temp_buffer( size
);
97 while (n
-- > 0 && dst
<= res
+ size
- 9)
99 unsigned char c
= *str
++;
102 case '\n': *dst
++ = '\\'; *dst
++ = 'n'; break;
103 case '\r': *dst
++ = '\\'; *dst
++ = 'r'; break;
104 case '\t': *dst
++ = '\\'; *dst
++ = 't'; break;
105 case '"': *dst
++ = '\\'; *dst
++ = '"'; break;
106 case '\\': *dst
++ = '\\'; *dst
++ = '\\'; break;
108 if (c
>= ' ' && c
<= 126)
114 *dst
++ = hex
[(c
>> 4) & 0x0f];
115 *dst
++ = hex
[c
& 0x0f];
130 #define ADVAPI32_GET_PROC(func) \
131 p ## func = (void*)GetProcAddress(hadvapi32, #func)
133 static void InitFunctionPtrs(void)
135 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
136 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
137 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
139 /* This function was introduced with Windows 2003 SP1 */
140 ADVAPI32_GET_PROC(RegGetValueA
);
141 ADVAPI32_GET_PROC(RegDeleteTreeA
);
142 ADVAPI32_GET_PROC(RegDeleteKeyExA
);
143 ADVAPI32_GET_PROC(RegDeleteKeyValueA
);
144 ADVAPI32_GET_PROC(RegSetKeyValueW
);
146 pIsWow64Process
= (void *)GetProcAddress( hkernel32
, "IsWow64Process" );
147 pRtlFormatCurrentUserKeyPath
= (void *)GetProcAddress( hntdll
, "RtlFormatCurrentUserKeyPath" );
148 pRtlFreeUnicodeString
= (void *)GetProcAddress(hntdll
, "RtlFreeUnicodeString");
149 pNtDeleteKey
= (void *)GetProcAddress( hntdll
, "NtDeleteKey" );
152 /* delete key and all its subkeys */
153 static DWORD
delete_key( HKEY hkey
)
158 if ((ret
= RegOpenKeyExA( hkey
, "", 0, KEY_ENUMERATE_SUB_KEYS
, &hkey
))) return ret
;
159 while (!(ret
= RegEnumKeyA(hkey
, 0, name
, sizeof(name
))))
162 if (!(ret
= RegOpenKeyExA( hkey
, name
, 0, KEY_ENUMERATE_SUB_KEYS
, &tmp
)))
164 ret
= delete_key( tmp
);
169 if (ret
!= ERROR_NO_MORE_ITEMS
) return ret
;
170 RegDeleteKeyA( hkey
, "" );
175 static void setup_main_key(void)
177 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
)) delete_key( hkey_main
);
179 assert (!RegCreateKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
));
182 static void check_user_privs(void)
185 HKEY hkey
= (HKEY
)0xdeadbeef;
187 ret
= RegOpenKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, KEY_READ
|KEY_WRITE
, &hkey
);
188 ok(ret
== ERROR_SUCCESS
|| ret
== ERROR_ACCESS_DENIED
, "expected success or access denied, got %i\n", ret
);
189 if (ret
== ERROR_SUCCESS
)
191 ok(hkey
!= NULL
, "RegOpenKeyExA succeeded but returned NULL hkey\n");
196 ok(hkey
== NULL
, "RegOpenKeyExA failed but returned hkey %p\n", hkey
);
198 trace("running as limited user\n");
202 #define lok ok_(__FILE__, line)
203 #define test_hkey_main_Value_A(name, string, full_byte_len) _test_hkey_main_Value_A(__LINE__, name, string, full_byte_len)
204 static void _test_hkey_main_Value_A(int line
, LPCSTR name
, LPCSTR string
,
207 DWORD ret
, type
, cbData
;
213 /* When successful RegQueryValueExA() leaves GLE as is,
214 * so we must reset it to detect unimplemented functions.
216 SetLastError(0xdeadbeef);
217 ret
= RegQueryValueExA(hkey_main
, name
, NULL
, &type
, NULL
, &cbData
);
218 GLE
= GetLastError();
219 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExA/1 failed: %d, GLE=%d\n", ret
, GLE
);
220 /* It is wrong for the Ansi version to not be implemented */
221 ok(GLE
== 0xdeadbeef, "RegQueryValueExA set GLE = %u\n", GLE
);
222 if(GLE
== ERROR_CALL_NOT_IMPLEMENTED
) return;
224 str_byte_len
= (string
? lstrlenA(string
) : 0) + 1;
225 lok(type
== REG_SZ
, "RegQueryValueExA/1 returned type %d\n", type
);
226 lok(cbData
== full_byte_len
, "cbData=%d instead of %d or %d\n", cbData
, full_byte_len
, str_byte_len
);
228 value
= HeapAlloc(GetProcessHeap(), 0, cbData
+1);
229 memset(value
, 0xbd, cbData
+1);
231 ret
= RegQueryValueExA(hkey_main
, name
, NULL
, &type
, value
, &cbData
);
232 GLE
= GetLastError();
233 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExA/2 failed: %d, GLE=%d\n", ret
, GLE
);
236 /* When cbData == 0, RegQueryValueExA() should not modify the buffer */
237 lok(*value
== 0xbd, "RegQueryValueExA overflowed: cbData=%u *value=%02x\n", cbData
, *value
);
241 lok(memcmp(value
, string
, cbData
) == 0, "RegQueryValueExA/2 failed: %s/%d != %s/%d\n",
242 wine_debugstr_an((char*)value
, cbData
), cbData
,
243 wine_debugstr_an(string
, full_byte_len
), full_byte_len
);
244 lok(*(value
+cbData
) == 0xbd, "RegQueryValueExA/2 overflowed at offset %u: %02x != bd\n", cbData
, *(value
+cbData
));
246 HeapFree(GetProcessHeap(), 0, value
);
249 #define test_hkey_main_Value_W(name, string, full_byte_len) _test_hkey_main_Value_W(__LINE__, name, string, full_byte_len)
250 static void _test_hkey_main_Value_W(int line
, LPCWSTR name
, LPCWSTR string
,
253 DWORD ret
, type
, cbData
;
258 /* When successful RegQueryValueExW() leaves GLE as is,
259 * so we must reset it to detect unimplemented functions.
261 SetLastError(0xdeadbeef);
262 ret
= RegQueryValueExW(hkey_main
, name
, NULL
, &type
, NULL
, &cbData
);
263 GLE
= GetLastError();
264 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExW/1 failed: %d, GLE=%d\n", ret
, GLE
);
265 if(GLE
== ERROR_CALL_NOT_IMPLEMENTED
)
267 win_skip("RegQueryValueExW() is not implemented\n");
271 lok(type
== REG_SZ
, "RegQueryValueExW/1 returned type %d\n", type
);
272 lok(cbData
== full_byte_len
,
273 "cbData=%d instead of %d\n", cbData
, full_byte_len
);
275 /* Give enough space to overflow by one WCHAR */
276 value
= HeapAlloc(GetProcessHeap(), 0, cbData
+2);
277 memset(value
, 0xbd, cbData
+2);
279 ret
= RegQueryValueExW(hkey_main
, name
, NULL
, &type
, value
, &cbData
);
280 GLE
= GetLastError();
281 lok(ret
== ERROR_SUCCESS
, "RegQueryValueExW/2 failed: %d, GLE=%d\n", ret
, GLE
);
284 lok(memcmp(value
, string
, cbData
) == 0, "RegQueryValueExW failed: %s/%d != %s/%d\n",
285 wine_dbgstr_wn((WCHAR
*)value
, cbData
/ sizeof(WCHAR
)), cbData
,
286 wine_dbgstr_wn(string
, full_byte_len
/ sizeof(WCHAR
)), full_byte_len
);
288 /* This implies that when cbData == 0, RegQueryValueExW() should not modify the buffer */
289 lok(*(value
+cbData
) == 0xbd, "RegQueryValueExW/2 overflowed at %u: %02x != bd\n", cbData
, *(value
+cbData
));
290 lok(*(value
+cbData
+1) == 0xbd, "RegQueryValueExW/2 overflowed at %u+1: %02x != bd\n", cbData
, *(value
+cbData
+1));
291 HeapFree(GetProcessHeap(), 0, value
);
294 static void test_set_value(void)
298 static const WCHAR name1W
[] = {'C','l','e','a','n','S','i','n','g','l','e','S','t','r','i','n','g', 0};
299 static const WCHAR name2W
[] = {'S','o','m','e','I','n','t','r','a','Z','e','r','o','e','d','S','t','r','i','n','g', 0};
300 static const WCHAR emptyW
[] = {0};
301 static const WCHAR string1W
[] = {'T','h','i','s','N','e','v','e','r','B','r','e','a','k','s', 0};
302 static const WCHAR string2W
[] = {'T','h','i','s', 0 ,'B','r','e','a','k','s', 0 , 0 ,'A', 0 , 0 , 0 , 'L','o','t', 0 , 0 , 0 , 0, 0};
303 static const WCHAR substring2W
[] = {'T','h','i','s',0};
305 static const char name1A
[] = "CleanSingleString";
306 static const char name2A
[] = "SomeIntraZeroedString";
307 static const char emptyA
[] = "";
308 static const char string1A
[] = "ThisNeverBreaks";
309 static const char string2A
[] = "This\0Breaks\0\0A\0\0\0Lot\0\0\0\0";
310 static const char substring2A
[] = "This";
314 /* Crashes on NT4, Windows 2000 and XP SP1 */
315 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, NULL
, 0);
316 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueA should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret
);
319 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string1A
, sizeof(string1A
));
320 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
321 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
322 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
324 /* RegSetValueA ignores the size passed in */
325 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string1A
, 4);
326 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
327 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
328 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
330 /* stops at first null */
331 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string2A
, sizeof(string2A
));
332 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
333 test_hkey_main_Value_A(NULL
, substring2A
, sizeof(substring2A
));
334 test_hkey_main_Value_W(NULL
, substring2W
, sizeof(substring2W
));
336 /* only REG_SZ is supported on NT*/
337 ret
= RegSetValueA(hkey_main
, NULL
, REG_BINARY
, string2A
, sizeof(string2A
));
338 ok(ret
== ERROR_INVALID_PARAMETER
, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret
);
340 ret
= RegSetValueA(hkey_main
, NULL
, REG_EXPAND_SZ
, string2A
, sizeof(string2A
));
341 ok(ret
== ERROR_INVALID_PARAMETER
, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret
);
343 ret
= RegSetValueA(hkey_main
, NULL
, REG_MULTI_SZ
, string2A
, sizeof(string2A
));
344 ok(ret
== ERROR_INVALID_PARAMETER
, "got %d (expected ERROR_INVALID_PARAMETER)\n", ret
);
346 /* Test RegSetValueExA with a 'zero-byte' string (as Office 2003 does).
347 * Surprisingly enough we're supposed to get zero bytes out of it.
349 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)emptyA
, 0);
350 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
351 test_hkey_main_Value_A(name1A
, NULL
, 0);
352 test_hkey_main_Value_W(name1W
, NULL
, 0);
354 /* test RegSetValueExA with an empty string */
355 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)emptyA
, sizeof(emptyA
));
356 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
357 test_hkey_main_Value_A(name1A
, emptyA
, sizeof(emptyA
));
358 test_hkey_main_Value_W(name1W
, emptyW
, sizeof(emptyW
));
360 /* test RegSetValueExA with off-by-one size */
361 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)string1A
, sizeof(string1A
)-sizeof(string1A
[0]));
362 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
363 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
364 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
366 /* test RegSetValueExA with normal string */
367 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)string1A
, sizeof(string1A
));
368 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
369 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
370 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
372 /* test RegSetValueExA with intrazeroed string */
373 ret
= RegSetValueExA(hkey_main
, name2A
, 0, REG_SZ
, (const BYTE
*)string2A
, sizeof(string2A
));
374 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
375 test_hkey_main_Value_A(name2A
, string2A
, sizeof(string2A
));
376 test_hkey_main_Value_W(name2W
, string2W
, sizeof(string2W
));
380 /* Crashes on NT4, Windows 2000 and XP SP1 */
381 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, NULL
, 0);
382 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret
);
384 RegSetValueExA(hkey_main
, name2A
, 0, REG_SZ
, (const BYTE
*)1, 1);
385 RegSetValueExA(hkey_main
, name2A
, 0, REG_DWORD
, (const BYTE
*)1, 1);
388 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string1W
, sizeof(string1W
));
389 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
390 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
391 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
393 ret
= RegSetValueW(hkey_main
, name1W
, REG_SZ
, string1W
, sizeof(string1W
));
394 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
395 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
396 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
398 /* RegSetValueW ignores the size passed in */
399 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string1W
, 4 * sizeof(string1W
[0]));
400 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
401 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
402 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
404 /* stops at first null */
405 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string2W
, sizeof(string2W
));
406 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
407 test_hkey_main_Value_A(NULL
, substring2A
, sizeof(substring2A
));
408 test_hkey_main_Value_W(NULL
, substring2W
, sizeof(substring2W
));
410 /* only REG_SZ is supported */
411 ret
= RegSetValueW(hkey_main
, NULL
, REG_BINARY
, string2W
, sizeof(string2W
));
412 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
413 ret
= RegSetValueW(hkey_main
, NULL
, REG_EXPAND_SZ
, string2W
, sizeof(string2W
));
414 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
415 ret
= RegSetValueW(hkey_main
, NULL
, REG_MULTI_SZ
, string2W
, sizeof(string2W
));
416 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
418 /* test RegSetValueExW with off-by-one size */
419 ret
= RegSetValueExW(hkey_main
, name1W
, 0, REG_SZ
, (const BYTE
*)string1W
, sizeof(string1W
)-sizeof(string1W
[0]));
420 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
421 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
422 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
424 /* test RegSetValueExW with normal string */
425 ret
= RegSetValueExW(hkey_main
, name1W
, 0, REG_SZ
, (const BYTE
*)string1W
, sizeof(string1W
));
426 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
427 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
428 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
430 /* test RegSetValueExW with intrazeroed string */
431 ret
= RegSetValueExW(hkey_main
, name2W
, 0, REG_SZ
, (const BYTE
*)string2W
, sizeof(string2W
));
432 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
433 test_hkey_main_Value_A(name2A
, string2A
, sizeof(string2A
));
434 test_hkey_main_Value_W(name2W
, string2W
, sizeof(string2W
));
436 /* test RegSetValueExW with data = 1 */
437 ret
= RegSetValueExW(hkey_main
, name2W
, 0, REG_SZ
, (const BYTE
*)1, 1);
438 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
439 ret
= RegSetValueExW(hkey_main
, name2W
, 0, REG_DWORD
, (const BYTE
*)1, 1);
440 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
442 if (pRegGetValueA
) /* avoid a crash on Windows 2000 */
444 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_SZ
, NULL
, 4);
445 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
447 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_SZ
, NULL
, 0);
448 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
450 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_DWORD
, NULL
, 4);
451 ok(ret
== ERROR_NOACCESS
, "RegSetValueExW should have failed with ERROR_NOACCESS: %d, GLE=%d\n", ret
, GetLastError());
453 ret
= RegSetValueExW(hkey_main
, NULL
, 0, REG_DWORD
, NULL
, 0);
454 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
458 if (!pRegSetKeyValueW
)
459 win_skip("RegSetKeyValue() is not supported.\n");
462 static const WCHAR subkeyW
[] = {'s','u','b','k','e','y',0};
466 ret
= pRegSetKeyValueW(hkey_main
, NULL
, name1W
, REG_SZ
, (const BYTE
*)string2W
, sizeof(string2W
));
467 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
468 test_hkey_main_Value_A(name1A
, string2A
, sizeof(string2A
));
469 test_hkey_main_Value_W(name1W
, string2W
, sizeof(string2W
));
471 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_SZ
, string1W
, sizeof(string1W
));
472 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
474 ret
= RegOpenKeyExW(hkey_main
, subkeyW
, 0, KEY_QUERY_VALUE
, &subkey
);
475 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
477 ret
= RegQueryValueExW(subkey
, name1W
, 0, &type
, NULL
, &len
);
478 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
479 ok(len
== sizeof(string1W
), "got %d\n", len
);
480 ok(type
== REG_SZ
, "got type %d\n", type
);
482 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_SZ
, NULL
, 0);
483 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
485 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_SZ
, NULL
, 4);
486 ok(ret
== ERROR_NOACCESS
, "got %d\n", ret
);
488 ret
= pRegSetKeyValueW(hkey_main
, subkeyW
, name1W
, REG_DWORD
, NULL
, 4);
489 ok(ret
== ERROR_NOACCESS
, "got %d\n", ret
);
495 static void create_test_entries(void)
497 static const DWORD qw
[2] = { 0x12345678, 0x87654321 };
499 SetEnvironmentVariableA("LONGSYSTEMVAR", "bar");
500 SetEnvironmentVariableA("FOO", "ImARatherLongButIndeedNeededString");
502 ok(!RegSetValueExA(hkey_main
,"TP1_EXP_SZ",0,REG_EXPAND_SZ
, (const BYTE
*)sTestpath1
, strlen(sTestpath1
)+1),
503 "RegSetValueExA failed\n");
504 ok(!RegSetValueExA(hkey_main
,"TP1_SZ",0,REG_SZ
, (const BYTE
*)sTestpath1
, strlen(sTestpath1
)+1),
505 "RegSetValueExA failed\n");
506 ok(!RegSetValueExA(hkey_main
,"TP1_ZB_SZ",0,REG_SZ
, (const BYTE
*)"", 0),
507 "RegSetValueExA failed\n");
508 ok(!RegSetValueExA(hkey_main
,"TP2_EXP_SZ",0,REG_EXPAND_SZ
, (const BYTE
*)sTestpath2
, strlen(sTestpath2
)+1),
509 "RegSetValueExA failed\n");
510 ok(!RegSetValueExA(hkey_main
,"DWORD",0,REG_DWORD
, (const BYTE
*)qw
, 4),
511 "RegSetValueExA failed\n");
512 ok(!RegSetValueExA(hkey_main
,"BIN32",0,REG_BINARY
, (const BYTE
*)qw
, 4),
513 "RegSetValueExA failed\n");
514 ok(!RegSetValueExA(hkey_main
,"BIN64",0,REG_BINARY
, (const BYTE
*)qw
, 8),
515 "RegSetValueExA failed\n");
518 static void test_enum_value(void)
522 char value
[20], data
[20];
523 WCHAR valueW
[20], dataW
[20];
524 DWORD val_count
, data_count
, type
;
525 static const WCHAR foobarW
[] = {'f','o','o','b','a','r',0};
526 static const WCHAR testW
[] = {'T','e','s','t',0};
527 static const WCHAR xxxW
[] = {'x','x','x','x','x','x','x','x',0};
529 /* create the working key for new 'Test' value */
530 res
= RegCreateKeyA( hkey_main
, "TestKey", &test_key
);
531 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
533 /* check NULL data with zero length */
534 res
= RegSetValueExA( test_key
, "Test", 0, REG_SZ
, NULL
, 0 );
535 if (GetVersion() & 0x80000000)
536 ok( res
== ERROR_INVALID_PARAMETER
, "RegSetValueExA returned %d\n", res
);
538 ok( !res
, "RegSetValueExA returned %d\n", res
);
539 res
= RegSetValueExA( test_key
, "Test", 0, REG_EXPAND_SZ
, NULL
, 0 );
540 ok( ERROR_SUCCESS
== res
|| ERROR_INVALID_PARAMETER
== res
, "RegSetValueExA returned %d\n", res
);
541 res
= RegSetValueExA( test_key
, "Test", 0, REG_BINARY
, NULL
, 0 );
542 ok( ERROR_SUCCESS
== res
|| ERROR_INVALID_PARAMETER
== res
, "RegSetValueExA returned %d\n", res
);
544 /* test reading the value and data without setting them */
548 strcpy( value
, "xxxxxxxxxx" );
549 strcpy( data
, "xxxxxxxxxx" );
550 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
551 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
552 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
553 ok( data_count
== 0, "data_count set to %d instead of 0\n", data_count
);
554 ok( type
== REG_BINARY
, "type %d is not REG_BINARY\n", type
);
555 ok( !strcmp( value
, "Test" ), "value is '%s' instead of Test\n", value
);
556 ok( !strcmp( data
, "xxxxxxxxxx" ), "data is '%s' instead of xxxxxxxxxx\n", data
);
561 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
562 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
563 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
564 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
565 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
566 ok( data_count
== 0, "data_count set to %d instead of 0\n", data_count
);
567 ok( type
== REG_BINARY
, "type %d is not REG_BINARY\n", type
);
568 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
569 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data is not 'xxxxxxxxxx'\n" );
571 res
= RegSetValueExA( test_key
, "Test", 0, REG_SZ
, (const BYTE
*)"foobar", 7 );
572 ok( res
== 0, "RegSetValueExA failed error %d\n", res
);
574 /* overflow both name and data */
578 strcpy( value
, "xxxxxxxxxx" );
579 strcpy( data
, "xxxxxxxxxx" );
580 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
581 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
582 ok( val_count
== 2, "val_count set to %d\n", val_count
);
583 ok( data_count
== 7 || broken( data_count
== 8 ), "data_count set to %d instead of 7\n", data_count
);
584 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
585 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
586 ok( !strcmp( data
, "xxxxxxxxxx" ), "data set to '%s'\n", data
);
592 strcpy( value
, "xxxxxxxxxx" );
593 strcpy( data
, "xxxxxxxxxx" );
594 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
595 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
596 ok( val_count
== 3, "val_count set to %d\n", val_count
);
597 ok( data_count
== 7 || broken( data_count
== 8 ), "data_count set to %d instead of 7\n", data_count
);
598 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
599 /* v5.1.2600.0 (XP Home and Professional) does not touch value or data in this case */
600 ok( !strcmp( value
, "Te" ) || !strcmp( value
, "xxxxxxxxxx" ),
601 "value set to '%s' instead of 'Te' or 'xxxxxxxxxx'\n", value
);
602 ok( !strcmp( data
, "foobar" ) || !strcmp( data
, "xxxxxxx" ) || broken( !strcmp( data
, "xxxxxxxx" ) && data_count
== 8 ),
603 "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data
);
605 /* overflow empty name */
609 strcpy( value
, "xxxxxxxxxx" );
610 strcpy( data
, "xxxxxxxxxx" );
611 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
612 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
613 ok( val_count
== 0, "val_count set to %d\n", val_count
);
614 ok( data_count
== 7 || broken( data_count
== 8 ), "data_count set to %d instead of 7\n", data_count
);
615 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
616 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
617 /* v5.1.2600.0 (XP Home and Professional) does not touch data in this case */
618 ok( !strcmp( data
, "foobar" ) || !strcmp( data
, "xxxxxxx" ) || broken( !strcmp( data
, "xxxxxxxx" ) && data_count
== 8 ),
619 "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data
);
625 strcpy( value
, "xxxxxxxxxx" );
626 strcpy( data
, "xxxxxxxxxx" );
627 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
628 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
629 ok( val_count
== 20, "val_count set to %d\n", val_count
);
630 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
631 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
632 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
633 ok( !strcmp( data
, "xxxxxxxxxx" ), "data set to '%s'\n", data
);
639 strcpy( value
, "xxxxxxxxxx" );
640 strcpy( data
, "xxxxxxxxxx" );
641 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
642 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
643 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
644 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
645 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
646 ok( !strcmp( value
, "Test" ), "value is '%s' instead of Test\n", value
);
647 ok( !strcmp( data
, "foobar" ), "data is '%s' instead of foobar\n", data
);
651 SetLastError(0xdeadbeef);
652 res
= RegSetValueExW( test_key
, testW
, 0, REG_SZ
, (const BYTE
*)foobarW
, 7*sizeof(WCHAR
) );
653 if (res
==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
655 win_skip("RegSetValueExW is not implemented\n");
658 ok( res
== 0, "RegSetValueExW failed error %d\n", res
);
660 /* overflow both name and data */
664 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
665 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
666 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
667 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
668 ok( val_count
== 2, "val_count set to %d\n", val_count
);
669 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
670 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
671 ok( !memcmp( valueW
, xxxW
, sizeof(xxxW
) ), "value modified\n" );
672 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
678 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
679 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
680 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
681 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
682 ok( val_count
== 3, "val_count set to %d\n", val_count
);
683 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
684 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
685 ok( !memcmp( valueW
, xxxW
, sizeof(xxxW
) ), "value modified\n" );
686 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
692 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
693 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
694 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
695 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
696 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
697 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
698 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
699 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
700 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
706 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
707 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
708 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
709 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
710 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
711 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
712 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
713 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
714 ok( !memcmp( dataW
, foobarW
, sizeof(foobarW
) ), "data is not 'foobar'\n" );
717 RegDeleteKeyA(test_key
, "");
718 RegCloseKey(test_key
);
721 static void test_query_value_ex(void)
728 ret
= RegQueryValueExA(hkey_main
, "TP1_SZ", NULL
, &type
, NULL
, &size
);
729 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
730 ok(size
== strlen(sTestpath1
) + 1, "(%d,%d)\n", (DWORD
)strlen(sTestpath1
) + 1, size
);
731 ok(type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
735 ret
= RegQueryValueExA(HKEY_CLASSES_ROOT
, "Nonexistent Value", NULL
, &type
, NULL
, &size
);
736 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
737 ok(size
== 0, "size should have been set to 0 instead of %d\n", size
);
739 size
= sizeof(buffer
);
740 ret
= RegQueryValueExA(HKEY_CLASSES_ROOT
, "Nonexistent Value", NULL
, &type
, buffer
, &size
);
741 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
742 ok(size
== sizeof(buffer
), "size shouldn't have been changed to %d\n", size
);
745 ret
= RegQueryValueExA(hkey_main
, "BIN32", NULL
, &size
, buffer
, &size
);
746 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
749 static void test_get_value(void)
756 CHAR expanded
[] = "bar\\subdir1";
757 CHAR expanded2
[] = "ImARatherLongButIndeedNeededString\\subdir1";
761 win_skip("RegGetValue not available on this platform\n");
765 /* Invalid parameter */
766 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_DWORD
, &type
, &dw
, NULL
);
767 ok(ret
== ERROR_INVALID_PARAMETER
, "ret=%d\n", ret
);
769 /* Query REG_DWORD using RRF_RT_REG_DWORD (ok) */
770 size
= type
= dw
= 0xdeadbeef;
771 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_DWORD
, &type
, &dw
, &size
);
772 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
773 ok(size
== 4, "size=%d\n", size
);
774 ok(type
== REG_DWORD
, "type=%d\n", type
);
775 ok(dw
== 0x12345678, "dw=%d\n", dw
);
777 /* Query by subkey-name */
778 ret
= pRegGetValueA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", "DWORD", RRF_RT_REG_DWORD
, NULL
, NULL
, NULL
);
779 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
781 /* Query REG_DWORD using RRF_RT_REG_BINARY (restricted) */
782 size
= type
= dw
= 0xdeadbeef;
783 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_BINARY
, &type
, &dw
, &size
);
784 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
785 /* Although the function failed all values are retrieved */
786 ok(size
== 4, "size=%d\n", size
);
787 ok(type
== REG_DWORD
, "type=%d\n", type
);
788 ok(dw
== 0x12345678, "dw=%d\n", dw
);
790 /* Test RRF_ZEROONFAILURE */
791 type
= dw
= 0xdeadbeef; size
= 4;
792 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_SZ
|RRF_ZEROONFAILURE
, &type
, &dw
, &size
);
793 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
794 /* Again all values are retrieved ... */
795 ok(size
== 4, "size=%d\n", size
);
796 ok(type
== REG_DWORD
, "type=%d\n", type
);
797 /* ... except the buffer, which is zeroed out */
798 ok(dw
== 0, "dw=%d\n", dw
);
800 /* Test RRF_ZEROONFAILURE with a NULL buffer... */
801 type
= size
= 0xbadbeef;
802 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_SZ
|RRF_ZEROONFAILURE
, &type
, NULL
, &size
);
803 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
804 ok(size
== 4, "size=%d\n", size
);
805 ok(type
== REG_DWORD
, "type=%d\n", type
);
807 /* Query REG_DWORD using RRF_RT_DWORD (ok) */
808 size
= type
= dw
= 0xdeadbeef;
809 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_DWORD
, &type
, &dw
, &size
);
810 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
811 ok(size
== 4, "size=%d\n", size
);
812 ok(type
== REG_DWORD
, "type=%d\n", type
);
813 ok(dw
== 0x12345678, "dw=%d\n", dw
);
815 /* Query 32-bit REG_BINARY using RRF_RT_DWORD (ok) */
816 size
= type
= dw
= 0xdeadbeef;
817 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN32", RRF_RT_DWORD
, &type
, &dw
, &size
);
818 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
819 ok(size
== 4, "size=%d\n", size
);
820 ok(type
== REG_BINARY
, "type=%d\n", type
);
821 ok(dw
== 0x12345678, "dw=%d\n", dw
);
823 /* Query 64-bit REG_BINARY using RRF_RT_DWORD (type mismatch) */
824 qw
[0] = qw
[1] = size
= type
= 0xdeadbeef;
825 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_DWORD
, &type
, qw
, &size
);
826 ok(ret
== ERROR_DATATYPE_MISMATCH
, "ret=%d\n", ret
);
827 ok(size
== 8, "size=%d\n", size
);
828 ok(type
== REG_BINARY
, "type=%d\n", type
);
829 ok(qw
[0] == 0x12345678 &&
830 qw
[1] == 0x87654321, "qw={%d,%d}\n", qw
[0], qw
[1]);
832 /* Query 64-bit REG_BINARY using 32-bit buffer (buffer too small) */
833 type
= dw
= 0xdeadbeef; size
= 4;
834 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_REG_BINARY
, &type
, &dw
, &size
);
835 ok(ret
== ERROR_MORE_DATA
, "ret=%d\n", ret
);
836 ok(dw
== 0xdeadbeef, "dw=%d\n", dw
);
837 ok(size
== 8, "size=%d\n", size
);
839 /* Query 64-bit REG_BINARY using RRF_RT_QWORD (ok) */
840 qw
[0] = qw
[1] = size
= type
= 0xdeadbeef;
841 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_QWORD
, &type
, qw
, &size
);
842 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
843 ok(size
== 8, "size=%d\n", size
);
844 ok(type
== REG_BINARY
, "type=%d\n", type
);
845 ok(qw
[0] == 0x12345678 &&
846 qw
[1] == 0x87654321, "qw={%d,%d}\n", qw
[0], qw
[1]);
848 /* Query REG_SZ using RRF_RT_REG_SZ (ok) */
849 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
850 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
851 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
852 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
853 ok(type
== REG_SZ
, "type=%d\n", type
);
854 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
856 /* Query REG_SZ using RRF_RT_REG_SZ and no buffer (ok) */
857 type
= 0xdeadbeef; size
= 0;
858 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
, &type
, NULL
, &size
);
859 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
860 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
861 ok(size
== strlen(sTestpath1
)+1 || broken(size
== strlen(sTestpath1
)+2),
862 "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
863 ok(type
== REG_SZ
, "type=%d\n", type
);
865 /* Query REG_SZ using RRF_RT_REG_SZ on a zero-byte value (ok) */
866 strcpy(buf
, sTestpath1
);
869 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_ZB_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
870 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
871 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
873 size
== 1, /* win2k3 */
875 ok(type
== REG_SZ
, "type=%d\n", type
);
876 ok(!strcmp(sTestpath1
, buf
) ||
878 "Expected \"%s\" or \"\", got \"%s\"\n", sTestpath1
, buf
);
880 /* Query REG_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (ok) */
881 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
882 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
|RRF_NOEXPAND
, &type
, buf
, &size
);
883 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
884 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
885 ok(type
== REG_SZ
, "type=%d\n", type
);
886 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
888 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ and no buffer (ok, expands) */
890 ret
= pRegGetValueA(hkey_main
, NULL
, "TP2_EXP_SZ", RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
891 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
892 ok((size
== strlen(expanded2
)+1) || /* win2k3 SP1 */
893 (size
== strlen(expanded2
)+2) || /* win2k3 SP2 */
894 (size
== strlen(sTestpath2
)+1),
895 "strlen(expanded2)=%d, strlen(sTestpath2)=%d, size=%d\n", lstrlenA(expanded2
), lstrlenA(sTestpath2
), size
);
897 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands) */
898 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
899 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
900 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
901 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
902 ok(size
== strlen(expanded
)+1 || broken(size
== strlen(sTestpath1
)+1),
903 "strlen(expanded)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded
), lstrlenA(sTestpath1
), size
);
904 ok(type
== REG_SZ
, "type=%d\n", type
);
905 ok(!strcmp(expanded
, buf
), "expanded=\"%s\" buf=\"%s\"\n", expanded
, buf
);
907 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands a lot) */
908 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
909 ret
= pRegGetValueA(hkey_main
, NULL
, "TP2_EXP_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
910 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
911 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath2 length + 1 here. */
912 ok(size
== strlen(expanded2
)+1 || broken(size
== strlen(sTestpath2
)+1),
913 "strlen(expanded2)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded2
), lstrlenA(sTestpath2
), size
);
914 ok(type
== REG_SZ
, "type=%d\n", type
);
915 ok(!strcmp(expanded2
, buf
), "expanded2=\"%s\" buf=\"%s\"\n", expanded2
, buf
);
917 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND (ok, doesn't expand) */
918 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
919 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
|RRF_NOEXPAND
, &type
, buf
, &size
);
920 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
921 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
922 ok(type
== REG_EXPAND_SZ
, "type=%d\n", type
);
923 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
925 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND and no buffer (ok, doesn't expand) */
927 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
|RRF_NOEXPAND
, NULL
, NULL
, &size
);
928 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
929 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
930 ok(size
== strlen(sTestpath1
)+1 || broken(size
== strlen(sTestpath1
)+2),
931 "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
933 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (type mismatch) */
934 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
, NULL
, NULL
);
935 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
937 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ (not allowed without RRF_NOEXPAND) */
938 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
, NULL
, NULL
, NULL
);
939 /* before win8: ERROR_INVALID_PARAMETER, win8: ERROR_UNSUPPORTED_TYPE */
940 ok(ret
== ERROR_INVALID_PARAMETER
|| ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
942 /* Query REG_EXPAND_SZ using RRF_RT_ANY */
943 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
944 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_ANY
, &type
, buf
, &size
);
945 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
946 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
947 ok(size
== strlen(expanded
)+1 || broken(size
== strlen(sTestpath1
)+1),
948 "strlen(expanded)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded
), lstrlenA(sTestpath1
), size
);
949 ok(type
== REG_SZ
, "type=%d\n", type
);
950 ok(!strcmp(expanded
, buf
), "expanded=\"%s\" buf=\"%s\"\n", expanded
, buf
);
953 static void test_reg_open_key(void)
956 HKEY hkResult
= NULL
;
957 HKEY hkPreserve
= NULL
;
958 HKEY hkRoot64
= NULL
;
959 HKEY hkRoot32
= NULL
;
961 SID_IDENTIFIER_AUTHORITY sid_authority
= {SECURITY_WORLD_SID_AUTHORITY
};
963 EXPLICIT_ACCESSA access
;
965 SECURITY_DESCRIPTOR
*sd
;
967 /* successful open */
968 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkResult
);
969 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
970 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
971 hkPreserve
= hkResult
;
973 /* open same key twice */
974 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkResult
);
975 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
976 ok(hkResult
!= hkPreserve
, "expected hkResult != hkPreserve\n");
977 ok(hkResult
!= NULL
, "hkResult != NULL\n");
978 RegCloseKey(hkResult
);
980 /* trailing slashes */
981 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test\\\\", &hkResult
);
982 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
983 RegCloseKey(hkResult
);
985 /* open nonexistent key
986 * check that hkResult is set to NULL
988 hkResult
= hkPreserve
;
989 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Nonexistent", &hkResult
);
990 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
991 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
993 /* open the same nonexistent key again to make sure the key wasn't created */
994 hkResult
= hkPreserve
;
995 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Nonexistent", &hkResult
);
996 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
997 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
999 /* send in NULL lpSubKey
1000 * check that hkResult receives the value of hKey
1002 hkResult
= hkPreserve
;
1003 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, NULL
, &hkResult
);
1004 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1005 ok(hkResult
== HKEY_CURRENT_USER
, "expected hkResult == HKEY_CURRENT_USER\n");
1007 /* send empty-string in lpSubKey */
1008 hkResult
= hkPreserve
;
1009 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "", &hkResult
);
1010 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1011 ok(hkResult
== HKEY_CURRENT_USER
, "expected hkResult == HKEY_CURRENT_USER\n");
1013 /* send in NULL lpSubKey and NULL hKey
1014 * hkResult is set to NULL
1016 hkResult
= hkPreserve
;
1017 ret
= RegOpenKeyA(NULL
, NULL
, &hkResult
);
1018 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1019 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
1021 /* only send NULL hKey
1022 * the value of hkResult remains unchanged
1024 hkResult
= hkPreserve
;
1025 ret
= RegOpenKeyA(NULL
, "Software\\Wine\\Test", &hkResult
);
1026 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 95 returns BADKEY */
1027 "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1028 ok(hkResult
== hkPreserve
, "expected hkResult == hkPreserve\n");
1029 RegCloseKey(hkResult
);
1031 /* send in NULL hkResult */
1032 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", NULL
);
1033 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1035 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, NULL
, NULL
);
1036 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1038 ret
= RegOpenKeyA(NULL
, NULL
, NULL
);
1039 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1041 /* beginning backslash character */
1042 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "\\Software\\Wine\\Test", &hkResult
);
1043 ok(ret
== ERROR_BAD_PATHNAME
|| /* NT/2k/XP */
1044 broken(ret
== ERROR_SUCCESS
), /* wow64 */
1045 "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret
);
1046 if (!ret
) RegCloseKey(hkResult
);
1049 ret
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "\\clsid", 0, KEY_QUERY_VALUE
, &hkResult
);
1050 ok(ret
== ERROR_SUCCESS
|| /* 2k/XP */
1051 ret
== ERROR_BAD_PATHNAME
, /* NT */
1052 "expected ERROR_SUCCESS, ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret
);
1053 RegCloseKey(hkResult
);
1057 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, KEY_READ
|KEY_WOW64_32KEY
, &hkResult
);
1058 ok((ret
== ERROR_SUCCESS
&& hkResult
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1059 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1060 RegCloseKey(hkResult
);
1063 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, KEY_READ
|KEY_WOW64_64KEY
, &hkResult
);
1064 ok((ret
== ERROR_SUCCESS
&& hkResult
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1065 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1066 RegCloseKey(hkResult
);
1068 /* check special HKEYs on 64bit
1069 * only the lower 4 bytes of the supplied key are used
1073 /* HKEY_CURRENT_USER */
1074 ret
= RegOpenKeyA(UlongToHandle(HandleToUlong(HKEY_CURRENT_USER
)), "Software", &hkResult
);
1075 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1076 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1077 RegCloseKey(hkResult
);
1079 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_CURRENT_USER
) | (ULONG64
)1 << 32), "Software", &hkResult
);
1080 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1081 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1082 RegCloseKey(hkResult
);
1084 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_CURRENT_USER
) | (ULONG64
)0xdeadbeef << 32), "Software", &hkResult
);
1085 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1086 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1087 RegCloseKey(hkResult
);
1089 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_CURRENT_USER
) | (ULONG64
)0xffffffff << 32), "Software", &hkResult
);
1090 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1091 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1092 RegCloseKey(hkResult
);
1094 /* HKEY_LOCAL_MACHINE */
1095 ret
= RegOpenKeyA((HKEY
)(HandleToUlong(HKEY_LOCAL_MACHINE
) | (ULONG64
)0xdeadbeef << 32), "Software", &hkResult
);
1096 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1097 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
1098 RegCloseKey(hkResult
);
1101 /* Try using WOW64 flags when opening a key with a DACL set to verify that
1102 * the registry access check is performed correctly. Redirection isn't
1103 * being tested, so the tests don't care about whether the process is
1104 * running under WOW64. */
1105 if (!pIsWow64Process
)
1107 win_skip("WOW64 flags are not recognized\n");
1111 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1112 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot32
, NULL
);
1114 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot32
== NULL
,
1115 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1117 ok(ret
== ERROR_SUCCESS
&& hkRoot32
!= NULL
,
1118 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1120 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1121 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot64
, NULL
);
1123 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot64
== NULL
,
1124 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1126 ok(ret
== ERROR_SUCCESS
&& hkRoot64
!= NULL
,
1127 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1129 bRet
= AllocateAndInitializeSid(&sid_authority
, 1, SECURITY_WORLD_RID
,
1130 0, 0, 0, 0, 0, 0, 0, &world_sid
);
1132 "Expected AllocateAndInitializeSid to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1134 access
.grfAccessPermissions
= GENERIC_ALL
| STANDARD_RIGHTS_ALL
;
1135 access
.grfAccessMode
= SET_ACCESS
;
1136 access
.grfInheritance
= SUB_CONTAINERS_AND_OBJECTS_INHERIT
;
1137 access
.Trustee
.pMultipleTrustee
= NULL
;
1138 access
.Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
1139 access
.Trustee
.TrusteeForm
= TRUSTEE_IS_SID
;
1140 access
.Trustee
.TrusteeType
= TRUSTEE_IS_WELL_KNOWN_GROUP
;
1141 access
.Trustee
.ptstrName
= (char *)world_sid
;
1143 ret
= SetEntriesInAclA(1, &access
, NULL
, &key_acl
);
1144 ok(ret
== ERROR_SUCCESS
,
1145 "Expected SetEntriesInAclA to return ERROR_SUCCESS, got %u, last error %u\n", ret
, GetLastError());
1147 sd
= HeapAlloc(GetProcessHeap(), 0, SECURITY_DESCRIPTOR_MIN_LENGTH
);
1148 bRet
= InitializeSecurityDescriptor(sd
, SECURITY_DESCRIPTOR_REVISION
);
1150 "Expected InitializeSecurityDescriptor to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1152 bRet
= SetSecurityDescriptorDacl(sd
, TRUE
, key_acl
, FALSE
);
1154 "Expected SetSecurityDescriptorDacl to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1158 skip("not enough privileges to modify HKLM\n");
1164 error
= RegSetKeySecurity(hkRoot64
, DACL_SECURITY_INFORMATION
, sd
);
1165 ok(error
== ERROR_SUCCESS
,
1166 "Expected RegSetKeySecurity to return success, got error %u\n", error
);
1168 error
= RegSetKeySecurity(hkRoot32
, DACL_SECURITY_INFORMATION
, sd
);
1169 ok(error
== ERROR_SUCCESS
,
1170 "Expected RegSetKeySecurity to return success, got error %u\n", error
);
1173 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, KEY_WOW64_64KEY
| KEY_READ
, &hkResult
);
1174 ok(ret
== ERROR_SUCCESS
&& hkResult
!= NULL
,
1175 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1176 RegCloseKey(hkResult
);
1179 ret
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, KEY_WOW64_32KEY
| KEY_READ
, &hkResult
);
1180 ok(ret
== ERROR_SUCCESS
&& hkResult
!= NULL
,
1181 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1182 RegCloseKey(hkResult
);
1185 HeapFree(GetProcessHeap(), 0, sd
);
1188 RegDeleteKeyA(hkRoot64
, "");
1189 RegCloseKey(hkRoot64
);
1190 RegDeleteKeyA(hkRoot32
, "");
1191 RegCloseKey(hkRoot32
);
1194 static void test_reg_create_key(void)
1198 HKEY hkRoot64
= NULL
;
1199 HKEY hkRoot32
= NULL
;
1202 SID_IDENTIFIER_AUTHORITY sid_authority
= {SECURITY_WORLD_SID_AUTHORITY
};
1204 EXPLICIT_ACCESSA access
;
1206 SECURITY_DESCRIPTOR
*sd
;
1208 ret
= RegCreateKeyExA(hkey_main
, "Subkey1", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
1209 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1210 /* should succeed: all versions of Windows ignore the access rights
1211 * to the parent handle */
1212 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, 0, KEY_SET_VALUE
, NULL
, &hkey2
, NULL
);
1213 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1216 RegDeleteKeyA(hkey2
, "");
1217 RegDeleteKeyA(hkey1
, "");
1221 /* test creation of volatile keys */
1222 ret
= RegCreateKeyExA(hkey_main
, "Volatile", 0, NULL
, REG_OPTION_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hkey1
, NULL
);
1223 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1224 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey2
, NULL
);
1225 ok(ret
== ERROR_CHILD_MUST_BE_VOLATILE
, "RegCreateKeyExA failed with error %d\n", ret
);
1226 if (!ret
) RegCloseKey( hkey2
);
1227 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, REG_OPTION_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hkey2
, NULL
);
1228 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1230 /* should succeed if the key already exists */
1231 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey2
, NULL
);
1232 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1235 RegDeleteKeyA(hkey2
, "");
1236 RegDeleteKeyA(hkey1
, "");
1240 /* beginning backslash character */
1241 ret
= RegCreateKeyExA(hkey_main
, "\\Subkey3", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
1242 if (!(GetVersion() & 0x80000000))
1243 ok(ret
== ERROR_BAD_PATHNAME
, "expected ERROR_BAD_PATHNAME, got %d\n", ret
);
1245 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
1246 RegDeleteKeyA(hkey1
, "");
1250 /* trailing backslash characters */
1251 ret
= RegCreateKeyExA(hkey_main
, "Subkey4\\\\", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
1252 ok(ret
== ERROR_SUCCESS
, "RegCreateKeyExA failed with error %d\n", ret
);
1253 RegDeleteKeyA(hkey1
, "");
1256 /* WOW64 flags - open an existing key */
1258 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0, KEY_READ
|KEY_WOW64_32KEY
, NULL
, &hkey1
, NULL
);
1259 ok((ret
== ERROR_SUCCESS
&& hkey1
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1260 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1264 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0, KEY_READ
|KEY_WOW64_64KEY
, NULL
, &hkey1
, NULL
);
1265 ok((ret
== ERROR_SUCCESS
&& hkey1
!= NULL
) || broken(ret
== ERROR_ACCESS_DENIED
/* NT4, win2k */),
1266 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1269 /* Try using WOW64 flags when opening a key with a DACL set to verify that
1270 * the registry access check is performed correctly. Redirection isn't
1271 * being tested, so the tests don't care about whether the process is
1272 * running under WOW64. */
1273 if (!pIsWow64Process
)
1275 win_skip("WOW64 flags are not recognized\n");
1279 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1280 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot32
, NULL
);
1282 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot32
== NULL
,
1283 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%d)\n", ret
);
1285 ok(ret
== ERROR_SUCCESS
&& hkRoot32
!= NULL
,
1286 "RegCreateKeyEx with KEY_WOW64_32KEY failed (err=%d)\n", ret
);
1288 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1289 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &hkRoot64
, NULL
);
1291 ok(ret
== ERROR_ACCESS_DENIED
&& hkRoot64
== NULL
,
1292 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%d)\n", ret
);
1294 ok(ret
== ERROR_SUCCESS
&& hkRoot64
!= NULL
,
1295 "RegCreateKeyEx with KEY_WOW64_64KEY failed (err=%d)\n", ret
);
1297 bRet
= AllocateAndInitializeSid(&sid_authority
, 1, SECURITY_WORLD_RID
,
1298 0, 0, 0, 0, 0, 0, 0, &world_sid
);
1300 "Expected AllocateAndInitializeSid to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1302 access
.grfAccessPermissions
= GENERIC_ALL
| STANDARD_RIGHTS_ALL
;
1303 access
.grfAccessMode
= SET_ACCESS
;
1304 access
.grfInheritance
= SUB_CONTAINERS_AND_OBJECTS_INHERIT
;
1305 access
.Trustee
.pMultipleTrustee
= NULL
;
1306 access
.Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
1307 access
.Trustee
.TrusteeForm
= TRUSTEE_IS_SID
;
1308 access
.Trustee
.TrusteeType
= TRUSTEE_IS_WELL_KNOWN_GROUP
;
1309 access
.Trustee
.ptstrName
= (char *)world_sid
;
1311 dwRet
= SetEntriesInAclA(1, &access
, NULL
, &key_acl
);
1312 ok(dwRet
== ERROR_SUCCESS
,
1313 "Expected SetEntriesInAclA to return ERROR_SUCCESS, got %u, last error %u\n", dwRet
, GetLastError());
1315 sd
= HeapAlloc(GetProcessHeap(), 0, SECURITY_DESCRIPTOR_MIN_LENGTH
);
1316 bRet
= InitializeSecurityDescriptor(sd
, SECURITY_DESCRIPTOR_REVISION
);
1318 "Expected InitializeSecurityDescriptor to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1320 bRet
= SetSecurityDescriptorDacl(sd
, TRUE
, key_acl
, FALSE
);
1322 "Expected SetSecurityDescriptorDacl to return TRUE, got %d, last error %u\n", bRet
, GetLastError());
1326 skip("not enough privileges to modify HKLM\n");
1330 ret
= RegSetKeySecurity(hkRoot64
, DACL_SECURITY_INFORMATION
, sd
);
1331 ok(ret
== ERROR_SUCCESS
,
1332 "Expected RegSetKeySecurity to return success, got error %u\n", ret
);
1334 ret
= RegSetKeySecurity(hkRoot32
, DACL_SECURITY_INFORMATION
, sd
);
1335 ok(ret
== ERROR_SUCCESS
,
1336 "Expected RegSetKeySecurity to return success, got error %u\n", ret
);
1339 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1340 KEY_WOW64_64KEY
| KEY_READ
, NULL
, &hkey1
, NULL
);
1341 ok(ret
== ERROR_SUCCESS
&& hkey1
!= NULL
,
1342 "RegOpenKeyEx with KEY_WOW64_64KEY failed (err=%u)\n", ret
);
1346 ret
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
1347 KEY_WOW64_32KEY
| KEY_READ
, NULL
, &hkey1
, NULL
);
1348 ok(ret
== ERROR_SUCCESS
&& hkey1
!= NULL
,
1349 "RegOpenKeyEx with KEY_WOW64_32KEY failed (err=%u)\n", ret
);
1353 HeapFree(GetProcessHeap(), 0, sd
);
1356 RegDeleteKeyA(hkRoot64
, "");
1357 RegCloseKey(hkRoot64
);
1358 RegDeleteKeyA(hkRoot32
, "");
1359 RegCloseKey(hkRoot32
);
1362 static void test_reg_close_key(void)
1367 /* successfully close key
1368 * hkHandle remains changed after call to RegCloseKey
1370 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkHandle
);
1371 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1372 ret
= RegCloseKey(hkHandle
);
1373 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1375 /* try to close the key twice */
1376 ret
= RegCloseKey(hkHandle
); /* Windows 95 doesn't mind. */
1377 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_SUCCESS
,
1378 "expected ERROR_INVALID_HANDLE or ERROR_SUCCESS, got %d\n", ret
);
1380 /* try to close a NULL handle */
1381 ret
= RegCloseKey(NULL
);
1382 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 95 returns BADKEY */
1383 "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1385 /* Check to see if we didn't potentially close our main handle, which could happen on win98 as
1386 * win98 doesn't give a new handle when the same key is opened.
1387 * Not re-opening will make some next tests fail.
1389 if (hkey_main
== hkHandle
)
1391 trace("The main handle is most likely closed, so re-opening\n");
1392 RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
);
1396 static void test_reg_delete_key(void)
1401 ret
= RegDeleteKeyA(hkey_main
, NULL
);
1403 /* There is a bug in NT4 and W2K that doesn't check if the subkey is NULL. If
1404 * there are also no subkeys available it will delete the key pointed to by hkey_main.
1405 * Not re-creating will make some next tests fail.
1407 if (ret
== ERROR_SUCCESS
)
1409 trace("We are probably running on NT4 or W2K as the main key is deleted,"
1410 " re-creating the main key\n");
1414 ok(ret
== ERROR_INVALID_PARAMETER
||
1415 ret
== ERROR_ACCESS_DENIED
||
1416 ret
== ERROR_BADKEY
, /* Win95 */
1419 ret
= RegCreateKeyA(hkey_main
, "deleteme", &key
);
1420 ok(ret
== ERROR_SUCCESS
, "Could not create key, got %d\n", ret
);
1421 ret
= RegDeleteKeyA(key
, "");
1422 ok(ret
== ERROR_SUCCESS
, "RegDeleteKeyA failed, got %d\n", ret
);
1424 ret
= RegOpenKeyA(hkey_main
, "deleteme", &key
);
1425 ok(ret
== ERROR_FILE_NOT_FOUND
, "Key was not deleted, got %d\n", ret
);
1429 static void test_reg_save_key(void)
1433 ret
= RegSaveKeyA(hkey_main
, "saved_key", NULL
);
1434 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1437 static void test_reg_load_key(void)
1442 ret
= RegLoadKeyA(HKEY_LOCAL_MACHINE
, "Test", "saved_key");
1443 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1445 ret
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Test", &hkHandle
);
1446 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1448 RegCloseKey(hkHandle
);
1451 static void test_reg_unload_key(void)
1455 ret
= RegUnLoadKeyA(HKEY_LOCAL_MACHINE
, "Test");
1456 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1458 DeleteFileA("saved_key");
1459 DeleteFileA("saved_key.LOG");
1462 static BOOL
set_privileges(LPCSTR privilege
, BOOL set
)
1464 TOKEN_PRIVILEGES tp
;
1468 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
1471 if(!LookupPrivilegeValueA(NULL
, privilege
, &luid
))
1473 CloseHandle(hToken
);
1477 tp
.PrivilegeCount
= 1;
1478 tp
.Privileges
[0].Luid
= luid
;
1481 tp
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1483 tp
.Privileges
[0].Attributes
= 0;
1485 AdjustTokenPrivileges(hToken
, FALSE
, &tp
, sizeof(TOKEN_PRIVILEGES
), NULL
, NULL
);
1486 if (GetLastError() != ERROR_SUCCESS
)
1488 CloseHandle(hToken
);
1492 CloseHandle(hToken
);
1496 /* tests that show that RegConnectRegistry and
1497 OpenSCManager accept computer names without the
1498 \\ prefix (what MSDN says). */
1499 static void test_regconnectregistry( void)
1501 CHAR compName
[MAX_COMPUTERNAME_LENGTH
+ 1];
1502 CHAR netwName
[MAX_COMPUTERNAME_LENGTH
+ 3]; /* 2 chars for double backslash */
1503 DWORD len
= sizeof(compName
) ;
1509 SetLastError(0xdeadbeef);
1510 ret
= GetComputerNameA(compName
, &len
);
1511 ok( ret
, "GetComputerName failed err = %d\n", GetLastError());
1514 lstrcpyA(netwName
, "\\\\");
1515 lstrcpynA(netwName
+2, compName
, MAX_COMPUTERNAME_LENGTH
+ 1);
1517 retl
= RegConnectRegistryA( compName
, HKEY_LOCAL_MACHINE
, &hkey
);
1519 retl
== ERROR_DLL_INIT_FAILED
||
1520 retl
== ERROR_BAD_NETPATH
, /* some win2k */
1521 "RegConnectRegistryA failed err = %d\n", retl
);
1522 if( !retl
) RegCloseKey( hkey
);
1524 retl
= RegConnectRegistryA( netwName
, HKEY_LOCAL_MACHINE
, &hkey
);
1526 retl
== ERROR_DLL_INIT_FAILED
||
1527 retl
== ERROR_BAD_NETPATH
, /* some win2k */
1528 "RegConnectRegistryA failed err = %d\n", retl
);
1529 if( !retl
) RegCloseKey( hkey
);
1531 SetLastError(0xdeadbeef);
1532 schnd
= OpenSCManagerA( compName
, NULL
, GENERIC_READ
);
1533 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1535 win_skip("OpenSCManagerA is not implemented\n");
1539 ok( schnd
!= NULL
, "OpenSCManagerA failed err = %d\n", GetLastError());
1540 CloseServiceHandle( schnd
);
1542 SetLastError(0xdeadbeef);
1543 schnd
= OpenSCManagerA( netwName
, NULL
, GENERIC_READ
);
1544 ok( schnd
!= NULL
, "OpenSCManagerA failed err = %d\n", GetLastError());
1545 CloseServiceHandle( schnd
);
1549 static void test_reg_query_value(void)
1556 static const WCHAR expected
[] = {'d','a','t','a',0};
1558 ret
= RegCreateKeyA(hkey_main
, "subkey", &subkey
);
1559 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1561 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data", 4);
1562 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1564 /* try an invalid hkey */
1565 SetLastError(0xdeadbeef);
1567 ret
= RegQueryValueA((HKEY
)0xcafebabe, "subkey", val
, &size
);
1568 ok(ret
== ERROR_INVALID_HANDLE
||
1569 ret
== ERROR_BADKEY
|| /* Windows 98 returns BADKEY */
1570 ret
== ERROR_ACCESS_DENIED
, /* non-admin winxp */
1571 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1572 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1574 /* try a NULL hkey */
1575 SetLastError(0xdeadbeef);
1577 ret
= RegQueryValueA(NULL
, "subkey", val
, &size
);
1578 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 98 returns BADKEY */
1579 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1580 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1582 /* try a NULL value */
1584 ret
= RegQueryValueA(hkey_main
, "subkey", NULL
, &size
);
1585 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1586 ok(size
== 5, "Expected 5, got %d\n", size
);
1588 /* try a NULL size */
1589 SetLastError(0xdeadbeef);
1591 ret
= RegQueryValueA(hkey_main
, "subkey", val
, NULL
);
1592 ok(ret
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1593 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1594 ok(!val
[0], "Expected val to be untouched, got %s\n", val
);
1596 /* try a NULL value and size */
1597 ret
= RegQueryValueA(hkey_main
, "subkey", NULL
, NULL
);
1598 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1600 /* try a size too small */
1601 SetLastError(0xdeadbeef);
1604 ret
= RegQueryValueA(hkey_main
, "subkey", val
, &size
);
1605 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1606 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1607 ok(!val
[0], "Expected val to be untouched, got %s\n", val
);
1608 ok(size
== 5, "Expected 5, got %d\n", size
);
1610 /* successfully read the value using 'subkey' */
1612 ret
= RegQueryValueA(hkey_main
, "subkey", val
, &size
);
1613 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1614 ok(!lstrcmpA(val
, "data"), "Expected 'data', got '%s'\n", val
);
1615 ok(size
== 5, "Expected 5, got %d\n", size
);
1617 /* successfully read the value using the subkey key */
1619 ret
= RegQueryValueA(subkey
, NULL
, val
, &size
);
1620 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1621 ok(!lstrcmpA(val
, "data"), "Expected 'data', got '%s'\n", val
);
1622 ok(size
== 5, "Expected 5, got %d\n", size
);
1624 /* unicode - try size too small */
1625 SetLastError(0xdeadbeef);
1628 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1629 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1631 win_skip("RegQueryValueW is not implemented\n");
1634 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1635 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1636 ok(!valW
[0], "Expected valW to be untouched\n");
1637 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1639 /* unicode - try size in WCHARS */
1640 SetLastError(0xdeadbeef);
1641 size
= sizeof(valW
) / sizeof(WCHAR
);
1642 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1643 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1644 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1645 ok(!valW
[0], "Expected valW to be untouched\n");
1646 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1648 /* unicode - successfully read the value */
1649 size
= sizeof(valW
);
1650 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1651 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1652 ok(!lstrcmpW(valW
, expected
), "Got wrong value\n");
1653 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1655 /* unicode - set the value without a NULL terminator */
1656 ret
= RegSetValueW(subkey
, NULL
, REG_SZ
, expected
, sizeof(expected
)-sizeof(WCHAR
));
1657 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1659 /* unicode - read the unterminated value, value is terminated for us */
1660 memset(valW
, 'a', sizeof(valW
));
1661 size
= sizeof(valW
);
1662 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1663 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1664 ok(!lstrcmpW(valW
, expected
), "Got wrong value\n");
1665 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1668 RegDeleteKeyA(subkey
, "");
1669 RegCloseKey(subkey
);
1672 static void test_reg_query_info(void)
1677 char classbuffer
[32];
1678 WCHAR classbufferW
[32];
1679 char subkey_class
[] = "subkey class";
1680 WCHAR subkey_classW
[] = {'s','u','b','k','e','y',' ','c','l','a','s','s',0};
1681 char subsubkey_class
[] = "subsubkey class";
1683 DWORD subkeys
, maxsubkeylen
, maxclasslen
;
1684 DWORD values
, maxvaluenamelen
, maxvaluelen
;
1688 ret
= RegCreateKeyExA(hkey_main
, "subkey", 0, subkey_class
, 0, KEY_ALL_ACCESS
, NULL
, &subkey
, NULL
);
1689 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1691 /* invalid parameters */
1692 ret
= RegQueryInfoKeyA(NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1693 ok(ret
== ERROR_INVALID_HANDLE
, "ret = %d\n", ret
);
1695 ret
= RegQueryInfoKeyA(subkey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1696 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1699 ret
= RegQueryInfoKeyA(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1700 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1701 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1702 ok(subkeys
== 0, "subkeys = %u\n", subkeys
);
1703 ok(maxsubkeylen
== 0, "maxsubkeylen = %u\n", maxsubkeylen
);
1704 ok(maxclasslen
== 0, "maxclasslen = %u\n", maxclasslen
);
1705 ok(values
== 0, "values = %u\n", values
);
1706 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1707 ok(maxvaluelen
== 0, "maxvaluelen = %u\n", maxvaluelen
);
1708 ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1709 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1710 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1712 ret
= RegQueryInfoKeyW(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1713 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1714 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1715 ok(subkeys
== 0, "subkeys = %u\n", subkeys
);
1716 ok(maxsubkeylen
== 0, "maxsubkeylen = %u\n", maxsubkeylen
);
1717 ok(maxclasslen
== 0, "maxclasslen = %u\n", maxclasslen
);
1718 ok(values
== 0, "values = %u\n", values
);
1719 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1720 ok(maxvaluelen
== 0, "maxvaluelen = %u\n", maxvaluelen
);
1721 ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1722 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1723 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1725 ret
= RegCreateKeyExA(subkey
, "subsubkey", 0, subsubkey_class
, 0, KEY_ALL_ACCESS
, NULL
, &subsubkey
, NULL
);
1726 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1728 ret
= RegSetValueExA(subkey
, NULL
, 0, REG_SZ
, (BYTE
*)"data", 5);
1729 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1731 /* with subkey & default value */
1732 ret
= RegQueryInfoKeyA(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1733 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1734 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1735 ok(subkeys
== 1, "subkeys = %u\n", subkeys
);
1736 ok(maxsubkeylen
== strlen("subsubkey"), "maxsubkeylen = %u\n", maxsubkeylen
);
1737 ok(maxclasslen
== strlen(subsubkey_class
), "maxclasslen = %u\n", maxclasslen
);
1738 ok(values
== 1, "values = %u\n", values
);
1739 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1740 ok(maxvaluelen
== sizeof("data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1741 ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1742 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1743 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1745 ret
= RegQueryInfoKeyW(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1746 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1747 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1748 ok(subkeys
== 1, "subkeys = %u\n", subkeys
);
1749 ok(maxsubkeylen
== strlen("subsubkey"), "maxsubkeylen = %u\n", maxsubkeylen
);
1750 ok(maxclasslen
== strlen(subsubkey_class
), "maxclasslen = %u\n", maxclasslen
);
1751 ok(values
== 1, "values = %u\n", values
);
1752 ok(maxvaluenamelen
== 0, "maxvaluenamelen = %u\n", maxvaluenamelen
);
1753 ok(maxvaluelen
== sizeof("data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1754 ok(sdlen
!= 0, "sdlen = %u\n", sdlen
);
1755 ok(lastwrite
.dwLowDateTime
!= 0, "lastwrite.dwLowDateTime = %u\n", lastwrite
.dwLowDateTime
);
1756 ok(lastwrite
.dwHighDateTime
!= 0, "lastwrite.dwHighDateTime = %u\n", lastwrite
.dwHighDateTime
);
1758 ret
= RegSetValueExA(subkey
, "value one", 0, REG_SZ
, (BYTE
*)"first value data", 17);
1759 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1761 ret
= RegSetValueExA(subkey
, "value 2", 0, REG_SZ
, (BYTE
*)"second value data", 18);
1762 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1764 /* with named value */
1765 ret
= RegQueryInfoKeyA(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1766 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1767 ok(values
== 3, "values = %u\n", values
);
1768 ok(maxvaluenamelen
== strlen("value one"), "maxvaluenamelen = %u\n", maxvaluenamelen
);
1769 ok(maxvaluelen
== sizeof("second value data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1771 ret
= RegQueryInfoKeyW(subkey
, NULL
, &classlen
, NULL
, &subkeys
, &maxsubkeylen
, &maxclasslen
, &values
, &maxvaluenamelen
, &maxvaluelen
, &sdlen
, &lastwrite
);
1772 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1773 ok(values
== 3, "values = %u\n", values
);
1774 ok(maxvaluenamelen
== strlen("value one"), "maxvaluenamelen = %u\n", maxvaluenamelen
);
1775 ok(maxvaluelen
== sizeof("second value data") * sizeof(WCHAR
), "maxvaluelen = %u\n", maxvaluelen
);
1777 /* class name with zero size buffer */
1778 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1780 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1781 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1782 ok(classlen
== 0, "classlen = %u\n", classlen
);
1783 ok(classbuffer
[0] == 0x55, "classbuffer[0] = 0x%x\n", classbuffer
[0]);
1785 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1787 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1788 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1789 ok(classlen
== 0, "classlen = %u\n", classlen
);
1790 ok(classbufferW
[0] == 0x5555, "classbufferW[0] = 0x%x\n", classbufferW
[0]);
1792 /* class name with one char buffer */
1793 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1795 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1796 ok(ret
== ERROR_MORE_DATA
, "ret = %d\n", ret
);
1797 ok(classlen
== 0, "classlen = %u\n", classlen
);
1798 ok(classbuffer
[0] == 0, "classbuffer[0] = 0x%x\n", classbuffer
[0]);
1799 ok(classbuffer
[1] == 0x55, "classbuffer[1] = 0x%x\n", classbuffer
[1]);
1801 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1803 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1804 ok(ret
== ERROR_INSUFFICIENT_BUFFER
, "ret = %d\n", ret
);
1805 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1806 ok(classbufferW
[0] == 0x5555, "classbufferW[0] = 0x%x\n", classbufferW
[0]);
1807 ok(classbufferW
[1] == 0x5555, "classbufferW[1] = 0x%x\n", classbufferW
[1]);
1809 /* class name with buffer one char too small */
1810 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1811 classlen
= sizeof(subkey_class
) - 1;
1812 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1813 ok(ret
== ERROR_MORE_DATA
, "ret = %d\n", ret
);
1814 ok(classlen
== sizeof(subkey_class
) - 2, "classlen = %u\n", classlen
);
1815 ok(classbuffer
[0] == 's', "classbuffer[0] = 0x%x\n", classbuffer
[0]);
1816 ok(classbuffer
[1] == 'u', "classbuffer[1] = 0x%x\n", classbuffer
[1]);
1817 ok(classbuffer
[10] == 's', "classbuffer[10] = 0x%x\n", classbuffer
[10]);
1818 ok(classbuffer
[11] == 0, "classbuffer[11] = 0x%x\n", classbuffer
[11]);
1819 ok(classbuffer
[12] == 0x55, "classbuffer[12] = 0x%x\n", classbuffer
[12]);
1821 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1822 classlen
= sizeof(subkey_class
) - 1;
1823 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1824 ok(ret
== ERROR_INSUFFICIENT_BUFFER
, "ret = %d\n", ret
);
1825 ok(classlen
== strlen(subkey_class
), "classlen = %u\n", classlen
);
1826 ok(classbufferW
[0] == 0x5555, "classbufferW[0] = 0x%x\n", classbufferW
[0]);
1827 ok(classbufferW
[1] == 0x5555, "classbufferW[1] = 0x%x\n", classbufferW
[1]);
1828 ok(classbufferW
[10] == 0x5555, "classbufferW[10] = 0x%x\n", classbufferW
[10]);
1829 ok(classbufferW
[11] == 0x5555, "classbufferW[11] = 0x%x\n", classbufferW
[11]);
1830 ok(classbufferW
[12] == 0x5555, "classbufferW[12] = 0x%x\n", classbufferW
[12]);
1832 /* class name with large enough buffer */
1833 memset(classbuffer
, 0x55, sizeof(classbuffer
));
1834 classlen
= sizeof(subkey_class
);
1835 ret
= RegQueryInfoKeyA(subkey
, classbuffer
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1836 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1837 ok(classlen
== sizeof(subkey_class
) - 1, "classlen = %u\n", classlen
);
1838 ok(!strcmp(classbuffer
, subkey_class
), "classbuffer = %s\n", classbuffer
);
1839 ok(classbuffer
[12] == 0, "classbuffer[12] = 0x%x\n", classbuffer
[12]);
1840 ok(classbuffer
[13] == 0x55, "classbuffer[13] = 0x%x\n", classbuffer
[13]);
1842 memset(classbufferW
, 0x55, sizeof(classbufferW
));
1843 classlen
= sizeof(subkey_class
);
1844 ret
= RegQueryInfoKeyW(subkey
, classbufferW
, &classlen
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
1845 ok(ret
== ERROR_SUCCESS
, "ret = %d\n", ret
);
1846 ok(classlen
== sizeof(subkey_class
) - 1, "classlen = %u\n", classlen
);
1847 ok(!lstrcmpW(classbufferW
, subkey_classW
), "classbufferW = %s\n", wine_dbgstr_w(classbufferW
));
1848 ok(classbufferW
[12] == 0, "classbufferW[12] = 0x%x\n", classbufferW
[12]);
1849 ok(classbufferW
[13] == 0x5555, "classbufferW[13] = 0x%x\n", classbufferW
[13]);
1851 RegDeleteKeyA(subsubkey
, "");
1852 RegCloseKey(subsubkey
);
1853 RegDeleteKeyA(subkey
, "");
1854 RegCloseKey(subkey
);
1857 static void test_string_termination(void)
1861 static const char string
[] = "FullString";
1864 DWORD insize
, outsize
, nsize
;
1866 ret
= RegCreateKeyA(hkey_main
, "string_termination", &subkey
);
1867 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1869 /* Off-by-one RegSetValueExA -> adds a trailing '\0'! */
1870 insize
=sizeof(string
)-1;
1871 ret
= RegSetValueExA(subkey
, "stringtest", 0, REG_SZ
, (BYTE
*)string
, insize
);
1872 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", ret
);
1874 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, buffer
, &outsize
);
1875 ok(ret
== ERROR_MORE_DATA
, "RegQueryValueExA returned: %d\n", ret
);
1877 /* Off-by-two RegSetValueExA -> no trailing '\0' */
1878 insize
=sizeof(string
)-2;
1879 ret
= RegSetValueExA(subkey
, "stringtest", 0, REG_SZ
, (BYTE
*)string
, insize
);
1880 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", ret
);
1882 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, NULL
, &outsize
);
1883 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", ret
);
1884 ok(outsize
== insize
, "wrong size %u != %u\n", outsize
, insize
);
1886 /* RegQueryValueExA may return a string with no trailing '\0' */
1888 memset(buffer
, 0xbd, sizeof(buffer
));
1889 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, buffer
, &outsize
);
1890 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", ret
);
1891 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
1892 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
1893 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
1894 ok(buffer
[insize
] == 0xbd, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
1896 /* RegQueryValueExA adds a trailing '\0' if there is room */
1898 memset(buffer
, 0xbd, sizeof(buffer
));
1899 ret
= RegQueryValueExA(subkey
, "stringtest", NULL
, NULL
, buffer
, &outsize
);
1900 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", ret
);
1901 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
1902 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
1903 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
1904 ok(buffer
[insize
] == 0, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
1906 /* RegEnumValueA may return a string with no trailing '\0' */
1908 memset(buffer
, 0xbd, sizeof(buffer
));
1910 ret
= RegEnumValueA(subkey
, 0, name
, &nsize
, NULL
, NULL
, buffer
, &outsize
);
1911 ok(ret
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", ret
);
1912 ok(strcmp(name
, "stringtest") == 0, "wrong name: %s\n", name
);
1913 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
1914 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
1915 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
1916 ok(buffer
[insize
] == 0xbd, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
1918 /* RegEnumValueA adds a trailing '\0' if there is room */
1920 memset(buffer
, 0xbd, sizeof(buffer
));
1922 ret
= RegEnumValueA(subkey
, 0, name
, &nsize
, NULL
, NULL
, buffer
, &outsize
);
1923 ok(ret
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", ret
);
1924 ok(strcmp(name
, "stringtest") == 0, "wrong name: %s\n", name
);
1925 ok(outsize
== insize
, "wrong size: %u != %u\n", outsize
, insize
);
1926 ok(memcmp(buffer
, string
, outsize
) == 0, "bad string: %s/%u != %s\n",
1927 wine_debugstr_an((char*)buffer
, outsize
), outsize
, string
);
1928 ok(buffer
[insize
] == 0, "buffer overflow at %u %02x\n", insize
, buffer
[insize
]);
1930 RegDeleteKeyA(subkey
, "");
1931 RegCloseKey(subkey
);
1934 static void test_reg_delete_tree(void)
1936 CHAR buffer
[MAX_PATH
];
1937 HKEY subkey
, subkey2
;
1940 if(!pRegDeleteTreeA
) {
1941 win_skip("Skipping RegDeleteTreeA tests, function not present\n");
1945 ret
= RegCreateKeyA(hkey_main
, "subkey", &subkey
);
1946 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1947 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
1948 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1949 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data", 4);
1950 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1951 ret
= RegSetValueA(subkey2
, NULL
, REG_SZ
, "data2", 5);
1952 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1953 ret
= RegCloseKey(subkey2
);
1954 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1956 ret
= pRegDeleteTreeA(subkey
, "subkey2");
1957 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1958 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
1959 "subkey2 was not deleted\n");
1961 ok(!RegQueryValueA(subkey
, NULL
, buffer
, &size
),
1962 "Default value of subkey not longer present\n");
1964 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
1965 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1966 ret
= RegCloseKey(subkey2
);
1967 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1968 ret
= pRegDeleteTreeA(hkey_main
, "subkey\\subkey2");
1969 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1970 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
1971 "subkey2 was not deleted\n");
1972 ok(!RegQueryValueA(subkey
, NULL
, buffer
, &size
),
1973 "Default value of subkey not longer present\n");
1975 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
1976 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1977 ret
= RegCloseKey(subkey2
);
1978 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1979 ret
= RegCreateKeyA(subkey
, "subkey3", &subkey2
);
1980 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1981 ret
= RegCloseKey(subkey2
);
1982 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1983 ret
= RegSetValueA(subkey
, "value", REG_SZ
, "data2", 5);
1984 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1985 ret
= pRegDeleteTreeA(subkey
, NULL
);
1986 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1987 ok(!RegOpenKeyA(hkey_main
, "subkey", &subkey
),
1988 "subkey was deleted\n");
1989 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
1990 "subkey2 was not deleted\n");
1991 ok(RegOpenKeyA(subkey
, "subkey3", &subkey2
),
1992 "subkey3 was not deleted\n");
1994 ret
= RegQueryValueA(subkey
, NULL
, buffer
, &size
);
1995 ok(ret
== ERROR_SUCCESS
,
1996 "Default value of subkey is not present\n");
1997 ok(!buffer
[0], "Expected length 0 got length %u(%s)\n", lstrlenA(buffer
), buffer
);
1999 ok(RegQueryValueA(subkey
, "value", buffer
, &size
),
2000 "Value is still present\n");
2002 ret
= pRegDeleteTreeA(hkey_main
, "not-here");
2003 ok(ret
== ERROR_FILE_NOT_FOUND
,
2004 "Expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
2007 static void test_rw_order(void)
2011 static const char keyname
[] = "test_rw_order";
2013 DWORD values
, value_len
, value_name_max_len
;
2016 RegDeleteKeyA(HKEY_CURRENT_USER
, keyname
);
2017 ret
= RegCreateKeyA(HKEY_CURRENT_USER
, keyname
, &hKey
);
2018 if(ret
!= ERROR_SUCCESS
) {
2019 skip("Couldn't create key. Skipping.\n");
2023 ok(!RegSetValueExA(hKey
, "A", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2024 "RegSetValueExA for value \"A\" failed\n");
2025 ok(!RegSetValueExA(hKey
, "C", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2026 "RegSetValueExA for value \"C\" failed\n");
2027 ok(!RegSetValueExA(hKey
, "D", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2028 "RegSetValueExA for value \"D\" failed\n");
2029 ok(!RegSetValueExA(hKey
, "B", 0, REG_DWORD
, (LPBYTE
)&dw
, sizeof(dw
)),
2030 "RegSetValueExA for value \"B\" failed\n");
2032 ok(!RegQueryInfoKeyA(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &values
,
2033 &value_name_max_len
, NULL
, NULL
, NULL
), "RegQueryInfoKeyA failed\n");
2034 ok(values
== 4, "Expected 4 values, got %u\n", values
);
2036 /* Value enumeration preserves RegSetValueEx call order */
2038 ok(!RegEnumValueA(hKey
, 0, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2039 ok(strcmp(value_buf
, "A") == 0, "Expected name \"A\", got %s\n", value_buf
);
2041 ok(!RegEnumValueA(hKey
, 1, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2042 todo_wine
ok(strcmp(value_buf
, "C") == 0, "Expected name \"C\", got %s\n", value_buf
);
2044 ok(!RegEnumValueA(hKey
, 2, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2045 todo_wine
ok(strcmp(value_buf
, "D") == 0, "Expected name \"D\", got %s\n", value_buf
);
2047 ok(!RegEnumValueA(hKey
, 3, value_buf
, &value_len
, NULL
, NULL
, NULL
, NULL
), "RegEnumValueA failed\n");
2048 todo_wine
ok(strcmp(value_buf
, "B") == 0, "Expected name \"B\", got %s\n", value_buf
);
2050 ok(!RegDeleteKeyA(HKEY_CURRENT_USER
, keyname
), "Failed to delete key\n");
2053 static void test_symlinks(void)
2055 static const WCHAR targetW
[] = {'\\','S','o','f','t','w','a','r','e','\\','W','i','n','e',
2056 '\\','T','e','s','t','\\','t','a','r','g','e','t',0};
2058 UNICODE_STRING target_str
;
2062 DWORD target_len
, type
, len
, dw
, err
;
2064 if (!pRtlFormatCurrentUserKeyPath
|| !pNtDeleteKey
)
2066 win_skip( "Can't perform symlink tests\n" );
2070 pRtlFormatCurrentUserKeyPath( &target_str
);
2072 target_len
= target_str
.Length
+ sizeof(targetW
);
2073 target
= HeapAlloc( GetProcessHeap(), 0, target_len
);
2074 memcpy( target
, target_str
.Buffer
, target_str
.Length
);
2075 memcpy( target
+ target_str
.Length
/sizeof(WCHAR
), targetW
, sizeof(targetW
) );
2077 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_CREATE_LINK
,
2078 KEY_ALL_ACCESS
, NULL
, &link
, NULL
);
2079 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed: %u\n", err
);
2081 /* REG_SZ is not allowed */
2082 err
= RegSetValueExA( link
, "SymbolicLinkValue", 0, REG_SZ
, (BYTE
*)"foobar", sizeof("foobar") );
2083 ok( err
== ERROR_ACCESS_DENIED
, "RegSetValueEx wrong error %u\n", err
);
2084 err
= RegSetValueExA( link
, "SymbolicLinkValue", 0, REG_LINK
,
2085 (BYTE
*)target
, target_len
- sizeof(WCHAR
) );
2086 ok( err
== ERROR_SUCCESS
, "RegSetValueEx failed error %u\n", err
);
2087 /* other values are not allowed */
2088 err
= RegSetValueExA( link
, "link", 0, REG_LINK
, (BYTE
*)target
, target_len
- sizeof(WCHAR
) );
2089 ok( err
== ERROR_ACCESS_DENIED
, "RegSetValueEx wrong error %u\n", err
);
2091 /* try opening the target through the link */
2093 err
= RegOpenKeyA( hkey_main
, "link", &key
);
2094 ok( err
== ERROR_FILE_NOT_FOUND
, "RegOpenKey wrong error %u\n", err
);
2096 err
= RegCreateKeyExA( hkey_main
, "target", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2097 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed error %u\n", err
);
2100 err
= RegSetValueExA( key
, "value", 0, REG_DWORD
, (BYTE
*)&dw
, sizeof(dw
) );
2101 ok( err
== ERROR_SUCCESS
, "RegSetValueEx failed error %u\n", err
);
2104 err
= RegOpenKeyA( hkey_main
, "link", &key
);
2105 ok( err
== ERROR_SUCCESS
, "RegOpenKey failed error %u\n", err
);
2107 len
= sizeof(buffer
);
2108 err
= RegQueryValueExA( key
, "value", NULL
, &type
, buffer
, &len
);
2109 ok( err
== ERROR_SUCCESS
, "RegOpenKey failed error %u\n", err
);
2110 ok( len
== sizeof(DWORD
), "wrong len %u\n", len
);
2112 len
= sizeof(buffer
);
2113 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2114 ok( err
== ERROR_FILE_NOT_FOUND
, "RegQueryValueEx wrong error %u\n", err
);
2116 /* REG_LINK can be created in non-link keys */
2117 err
= RegSetValueExA( key
, "SymbolicLinkValue", 0, REG_LINK
,
2118 (BYTE
*)target
, target_len
- sizeof(WCHAR
) );
2119 ok( err
== ERROR_SUCCESS
, "RegSetValueEx failed error %u\n", err
);
2120 len
= sizeof(buffer
);
2121 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2122 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2123 ok( len
== target_len
- sizeof(WCHAR
), "wrong len %u\n", len
);
2124 err
= RegDeleteValueA( key
, "SymbolicLinkValue" );
2125 ok( err
== ERROR_SUCCESS
, "RegDeleteValue failed error %u\n", err
);
2129 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2130 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed error %u\n", err
);
2132 len
= sizeof(buffer
);
2133 err
= RegQueryValueExA( key
, "value", NULL
, &type
, buffer
, &len
);
2134 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2135 ok( len
== sizeof(DWORD
), "wrong len %u\n", len
);
2137 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2138 ok( err
== ERROR_FILE_NOT_FOUND
, "RegQueryValueEx wrong error %u\n", err
);
2141 /* now open the symlink itself */
2143 err
= RegOpenKeyExA( hkey_main
, "link", REG_OPTION_OPEN_LINK
, KEY_ALL_ACCESS
, &key
);
2144 ok( err
== ERROR_SUCCESS
, "RegOpenKeyEx failed error %u\n", err
);
2145 len
= sizeof(buffer
);
2146 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2147 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2148 ok( len
== target_len
- sizeof(WCHAR
), "wrong len %u\n", len
);
2151 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_OPEN_LINK
,
2152 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2153 ok( err
== ERROR_SUCCESS
, "RegCreateKeyEx failed error %u\n", err
);
2154 len
= sizeof(buffer
);
2155 err
= RegQueryValueExA( key
, "SymbolicLinkValue", NULL
, &type
, buffer
, &len
);
2156 ok( err
== ERROR_SUCCESS
, "RegQueryValueEx failed error %u\n", err
);
2157 ok( len
== target_len
- sizeof(WCHAR
), "wrong len %u\n", len
);
2160 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_CREATE_LINK
,
2161 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2162 ok( err
== ERROR_ALREADY_EXISTS
, "RegCreateKeyEx wrong error %u\n", err
);
2164 err
= RegCreateKeyExA( hkey_main
, "link", 0, NULL
, REG_OPTION_CREATE_LINK
| REG_OPTION_OPEN_LINK
,
2165 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2166 ok( err
== ERROR_ALREADY_EXISTS
, "RegCreateKeyEx wrong error %u\n", err
);
2168 err
= RegDeleteKeyA( hkey_main
, "target" );
2169 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed error %u\n", err
);
2171 err
= RegDeleteKeyA( hkey_main
, "link" );
2172 ok( err
== ERROR_FILE_NOT_FOUND
, "RegDeleteKey wrong error %u\n", err
);
2174 status
= pNtDeleteKey( link
);
2175 ok( !status
, "NtDeleteKey failed: 0x%08x\n", status
);
2176 RegCloseKey( link
);
2178 HeapFree( GetProcessHeap(), 0, target
);
2179 pRtlFreeUnicodeString( &target_str
);
2182 static DWORD
get_key_value( HKEY root
, const char *name
, DWORD flags
)
2185 DWORD err
, type
, dw
, len
= sizeof(dw
);
2187 err
= RegCreateKeyExA( root
, name
, 0, NULL
, 0, flags
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2188 if (err
== ERROR_FILE_NOT_FOUND
) return 0;
2189 ok( err
== ERROR_SUCCESS
, "%08x: RegCreateKeyEx failed: %u\n", flags
, err
);
2191 err
= RegQueryValueExA( key
, "value", NULL
, &type
, (BYTE
*)&dw
, &len
);
2192 if (err
== ERROR_FILE_NOT_FOUND
)
2195 ok( err
== ERROR_SUCCESS
, "%08x: RegQueryValueEx failed: %u\n", flags
, err
);
2200 static void _check_key_value( int line
, HANDLE root
, const char *name
, DWORD flags
, DWORD expect
)
2202 DWORD dw
= get_key_value( root
, name
, flags
);
2203 ok_(__FILE__
,line
)( dw
== expect
, "%08x: wrong value %u/%u\n", flags
, dw
, expect
);
2205 #define check_key_value(root,name,flags,expect) _check_key_value( __LINE__, root, name, flags, expect )
2207 static void test_redirection(void)
2209 DWORD err
, type
, dw
, len
;
2210 HKEY key
, root32
, root64
, key32
, key64
, native
, op_key
;
2211 BOOL is_vista
= FALSE
;
2212 REGSAM opposite
= (sizeof(void*) == 8 ? KEY_WOW64_32KEY
: KEY_WOW64_64KEY
);
2217 if (!pIsWow64Process
|| !pIsWow64Process( GetCurrentProcess(), &is_wow64
) || !is_wow64
)
2219 skip( "Not on Wow64, no redirection\n" );
2224 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2225 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &root64
, NULL
);
2226 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2228 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2229 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &root32
, NULL
);
2230 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2232 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", 0, NULL
, 0,
2233 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key64
, NULL
);
2234 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2236 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", 0, NULL
, 0,
2237 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key32
, NULL
);
2238 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2241 err
= RegSetValueExA( key64
, "value", 0, REG_DWORD
, (BYTE
*)&dw
, sizeof(dw
) );
2242 ok( err
== ERROR_SUCCESS
, "RegSetValueExA failed: %u\n", err
);
2245 err
= RegSetValueExA( key32
, "value", 0, REG_DWORD
, (BYTE
*)&dw
, sizeof(dw
) );
2246 ok( err
== ERROR_SUCCESS
, "RegSetValueExA failed: %u\n", err
);
2250 err
= RegQueryValueExA( key32
, "value", NULL
, &type
, (BYTE
*)&dw
, &len
);
2251 ok( err
== ERROR_SUCCESS
, "RegQueryValueExA failed: %u\n", err
);
2252 ok( dw
== 32, "wrong value %u\n", dw
);
2256 err
= RegQueryValueExA( key64
, "value", NULL
, &type
, (BYTE
*)&dw
, &len
);
2257 ok( err
== ERROR_SUCCESS
, "RegQueryValueExA failed: %u\n", err
);
2258 ok( dw
== 64, "wrong value %u\n", dw
);
2260 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2261 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2262 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2266 /* the Vista mechanism allows opening Wow6432Node from a 32-bit key too */
2267 /* the new (and simpler) Win7 mechanism doesn't */
2268 if (get_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0 ) == 32)
2270 trace( "using Vista-style Wow6432Node handling\n" );
2273 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2274 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2275 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2276 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, is_vista
? 32 : 0 );
2277 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 0 );
2278 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, is_vista
? 32 : 0 );
2282 if (get_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
) == 64)
2284 trace( "using Vista-style Wow6432Node handling\n" );
2287 check_key_value( key
, "Wine\\Winetest", 0, 64 );
2288 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2294 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2295 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2296 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2297 dw
= get_key_value( key
, "Wine\\Winetest", 0 );
2298 ok( dw
== 64 || broken(dw
== 32) /* xp64 */, "wrong value %u\n", dw
);
2299 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2300 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2301 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2302 dw
= get_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
);
2303 ok( dw
== 32 || broken(dw
== 64) /* xp64 */, "wrong value %u\n", dw
);
2304 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2307 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2308 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2309 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2310 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2311 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2312 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2313 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, is_vista
? 32 : 0 );
2314 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 0 );
2315 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, is_vista
? 32 : 0 );
2320 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2321 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2322 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2323 check_key_value( key
, "Wine\\Winetest", 0, 64 );
2324 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2325 dw
= get_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
);
2326 todo_wine
ok( dw
== 32, "wrong value %u\n", dw
);
2327 check_key_value( key
, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2330 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software", 0, NULL
, 0,
2331 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2332 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2333 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2334 dw
= get_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
);
2335 ok( dw
== 32 || broken(dw
== 64) /* vista */, "wrong value %u\n", dw
);
2336 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2340 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", 0, ptr_size
);
2341 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", 0, 32 );
2344 /* KEY_WOW64 flags have no effect on 64-bit */
2345 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2346 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2347 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2348 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2352 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_64KEY
, 64 );
2353 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2354 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2355 check_key_value( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2358 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node", 0, NULL
, 0,
2359 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2360 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2361 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2362 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2363 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2368 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node", 0, NULL
, 0,
2369 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2370 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2371 dw
= get_key_value( key
, "Wine\\Winetest", 0 );
2372 ok( dw
== (is_vista
? 64 : 32) || broken(dw
== 32) /* xp64 */, "wrong value %u\n", dw
);
2373 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2374 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2377 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node", 0, NULL
, 0,
2378 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2379 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2380 check_key_value( key
, "Wine\\Winetest", 0, 32 );
2381 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2382 check_key_value( key
, "Wine\\Winetest", KEY_WOW64_32KEY
, 32 );
2386 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine", 0, NULL
, 0,
2387 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2388 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2389 check_key_value( key
, "Winetest", 0, 32 );
2390 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2391 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2396 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine", 0, NULL
, 0,
2397 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2398 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2399 dw
= get_key_value( key
, "Winetest", 0 );
2400 ok( dw
== 32 || (is_vista
&& dw
== 64), "wrong value %u\n", dw
);
2401 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2402 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2405 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wow6432Node\\Wine", 0, NULL
, 0,
2406 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2407 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2408 check_key_value( key
, "Winetest", 0, 32 );
2409 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2410 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2414 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2415 KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2416 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2417 check_key_value( key
, "Winetest", 0, ptr_size
);
2418 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : ptr_size
);
2419 dw
= get_key_value( key
, "Winetest", KEY_WOW64_32KEY
);
2420 if (ptr_size
== 32) ok( dw
== 32, "wrong value %u\n", dw
);
2421 else todo_wine
ok( dw
== 32, "wrong value %u\n", dw
);
2426 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2427 KEY_WOW64_64KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2428 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2429 dw
= get_key_value( key
, "Winetest", 0 );
2430 ok( dw
== 64 || broken(dw
== 32) /* xp64 */, "wrong value %u\n", dw
);
2431 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, 64 );
2432 dw
= get_key_value( key
, "Winetest", KEY_WOW64_32KEY
);
2433 todo_wine
ok( dw
== 32, "wrong value %u\n", dw
);
2436 err
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine", 0, NULL
, 0,
2437 KEY_WOW64_32KEY
| KEY_ALL_ACCESS
, NULL
, &key
, NULL
);
2438 ok( err
== ERROR_SUCCESS
, "RegCreateKeyExA failed: %u\n", err
);
2439 check_key_value( key
, "Winetest", 0, 32 );
2440 check_key_value( key
, "Winetest", KEY_WOW64_64KEY
, is_vista
? 64 : 32 );
2441 check_key_value( key
, "Winetest", KEY_WOW64_32KEY
, 32 );
2445 if (pRegDeleteKeyExA
)
2447 err
= pRegDeleteKeyExA( key32
, "", KEY_WOW64_32KEY
, 0 );
2448 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2449 err
= pRegDeleteKeyExA( key64
, "", KEY_WOW64_64KEY
, 0 );
2450 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2451 pRegDeleteKeyExA( key64
, "", KEY_WOW64_64KEY
, 0 );
2452 pRegDeleteKeyExA( root64
, "", KEY_WOW64_64KEY
, 0 );
2456 err
= RegDeleteKeyA( key32
, "" );
2457 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2458 err
= RegDeleteKeyA( key64
, "" );
2459 ok( err
== ERROR_SUCCESS
, "RegDeleteKey failed: %u\n", err
);
2460 RegDeleteKeyA( key64
, "" );
2461 RegDeleteKeyA( root64
, "" );
2463 RegCloseKey( key32
);
2464 RegCloseKey( key64
);
2465 RegCloseKey( root32
);
2466 RegCloseKey( root64
);
2468 /* open key in native bit mode */
2469 err
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "Interface", 0, KEY_ALL_ACCESS
, &native
);
2470 ok(err
== ERROR_SUCCESS
, "got %i\n", err
);
2472 pRegDeleteKeyExA(native
, "AWineTest", 0, 0);
2474 /* write subkey in opposite bit mode */
2475 err
= RegOpenKeyExA(HKEY_CLASSES_ROOT
, "Interface", 0, KEY_ALL_ACCESS
| opposite
, &op_key
);
2476 ok(err
== ERROR_SUCCESS
, "got %i\n", err
);
2478 err
= RegCreateKeyExA(op_key
, "AWineTest", 0, NULL
, 0, KEY_ALL_ACCESS
| opposite
,
2480 ok(err
== ERROR_SUCCESS
|| err
== ERROR_ACCESS_DENIED
, "got %i\n", err
);
2481 if(err
!= ERROR_SUCCESS
){
2482 win_skip("Can't write to registry\n");
2483 RegCloseKey(op_key
);
2484 RegCloseKey(native
);
2489 /* verify subkey is not present in native mode */
2490 err
= RegOpenKeyExA(native
, "AWineTest", 0, KEY_ALL_ACCESS
, &key
);
2491 ok(err
== ERROR_FILE_NOT_FOUND
||
2492 broken(err
== ERROR_SUCCESS
), /* before Win7, HKCR is reflected instead of redirected */
2495 err
= pRegDeleteKeyExA(op_key
, "AWineTest", opposite
, 0);
2496 ok(err
== ERROR_SUCCESS
, "got %i\n", err
);
2498 RegCloseKey(op_key
);
2499 RegCloseKey(native
);
2502 static void test_classesroot(void)
2504 HKEY hkey
, hklm
, hkcr
, hkeysub1
, hklmsub1
, hkcrsub1
, hklmsub2
, hkcrsub2
;
2506 DWORD type
= REG_SZ
;
2507 static CHAR buffer
[8];
2510 /* create a key in the user's classes */
2511 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", &hkey
))
2514 RegCloseKey( hkey
);
2516 res
= RegCreateKeyExA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
2517 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkey
, NULL
);
2518 if (res
== ERROR_ACCESS_DENIED
)
2520 skip("not enough privileges to add a user class\n");
2523 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
2525 /* try to open that key in hkcr */
2526 res
= RegOpenKeyExA( HKEY_CLASSES_ROOT
, "WineTestCls", 0,
2527 KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcr
);
2528 todo_wine
ok(res
== ERROR_SUCCESS
||
2529 broken(res
== ERROR_FILE_NOT_FOUND
/* WinNT */),
2530 "test key not found in hkcr: %d\n", res
);
2533 skip("HKCR key merging not supported\n");
2535 RegCloseKey( hkey
);
2539 todo_wine
ok(IS_HKCR(hkcr
), "hkcr mask not set in %p\n", hkcr
);
2541 /* set a value in user's classes */
2542 res
= RegSetValueExA(hkey
, "val1", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
2543 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2545 /* try to find the value in hkcr */
2546 res
= RegQueryValueExA(hkcr
, "val1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2547 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2548 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2550 /* modify the value in hkcr */
2551 res
= RegSetValueExA(hkcr
, "val1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2552 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2554 /* check if the value is also modified in user's classes */
2555 res
= RegQueryValueExA(hkey
, "val1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2556 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2557 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2559 /* set a value in hkcr */
2560 res
= RegSetValueExA(hkcr
, "val0", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2561 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2563 /* try to find the value in user's classes */
2564 res
= RegQueryValueExA(hkey
, "val0", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2565 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2566 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2568 /* modify the value in user's classes */
2569 res
= RegSetValueExA(hkey
, "val0", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
2570 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2572 /* check if the value is also modified in hkcr */
2573 res
= RegQueryValueExA(hkcr
, "val0", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2574 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2575 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2580 RegCloseKey( hkey
);
2581 RegCloseKey( hkcr
);
2583 /* create a key in the hklm classes */
2584 if (!RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", &hklm
))
2587 RegCloseKey( hklm
);
2589 res
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", 0, NULL
, REG_OPTION_NON_VOLATILE
,
2590 KEY_ALL_ACCESS
, NULL
, &hklm
, NULL
);
2591 if (res
== ERROR_ACCESS_DENIED
)
2593 skip("not enough privileges to add a system class\n");
2596 ok(!IS_HKCR(hklm
), "hkcr mask set in %p\n", hklm
);
2598 /* try to open that key in hkcr */
2599 res
= RegOpenKeyExA( HKEY_CLASSES_ROOT
, "WineTestCls", 0,
2600 KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcr
);
2601 ok(res
== ERROR_SUCCESS
,
2602 "test key not found in hkcr: %d\n", res
);
2603 ok(IS_HKCR(hkcr
), "hkcr mask not set in %p\n", hkcr
);
2607 RegCloseKey( hklm
);
2611 /* set a value in hklm classes */
2612 res
= RegSetValueExA(hklm
, "val2", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
2613 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2615 /* try to find the value in hkcr */
2616 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2617 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2618 ok(!strcmp( buffer
, "hklm" ), "value set to '%s'\n", buffer
);
2620 /* modify the value in hkcr */
2621 res
= RegSetValueExA(hkcr
, "val2", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2622 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2624 /* check that the value is modified in hklm classes */
2625 res
= RegQueryValueExA(hklm
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2626 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2627 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2629 if (RegCreateKeyExA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
2630 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkey
, NULL
)) return;
2631 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
2633 /* try to open that key in hkcr */
2634 res
= RegOpenKeyExA( HKEY_CLASSES_ROOT
, "WineTestCls", 0,
2635 KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcr
);
2636 ok(res
== ERROR_SUCCESS
,
2637 "test key not found in hkcr: %d\n", res
);
2638 ok(IS_HKCR(hkcr
), "hkcr mask not set in %p\n", hkcr
);
2640 /* set a value in user's classes */
2641 res
= RegSetValueExA(hkey
, "val2", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
2642 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2644 /* try to find the value in hkcr */
2645 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2646 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2647 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2649 /* modify the value in hklm */
2650 res
= RegSetValueExA(hklm
, "val2", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
2651 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2653 /* check that the value is not overwritten in hkcr or user's classes */
2654 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2655 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2656 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2657 res
= RegQueryValueExA(hkey
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2658 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2659 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2661 /* modify the value in hkcr */
2662 res
= RegSetValueExA(hkcr
, "val2", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2663 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2665 /* check that the value is overwritten in hklm and user's classes */
2666 res
= RegQueryValueExA(hkcr
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2667 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2668 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2669 res
= RegQueryValueExA(hkey
, "val2", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2670 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2671 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2673 /* create a subkey in hklm */
2674 if (RegCreateKeyExA( hklm
, "subkey1", 0, NULL
, 0,
2675 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hklmsub1
, NULL
)) return;
2676 ok(!IS_HKCR(hklmsub1
), "hkcr mask set in %p\n", hklmsub1
);
2677 /* try to open that subkey in hkcr */
2678 res
= RegOpenKeyExA( hkcr
, "subkey1", 0, KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hkcrsub1
);
2679 ok(res
== ERROR_SUCCESS
, "test key not found in hkcr: %d\n", res
);
2680 ok(IS_HKCR(hkcrsub1
), "hkcr mask not set in %p\n", hkcrsub1
);
2682 /* set a value in hklm classes */
2683 res
= RegSetValueExA(hklmsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
2684 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2686 /* try to find the value in hkcr */
2687 res
= RegQueryValueExA(hkcrsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2688 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2689 ok(!strcmp( buffer
, "hklm" ), "value set to '%s'\n", buffer
);
2691 /* modify the value in hkcr */
2692 res
= RegSetValueExA(hkcrsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2693 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2695 /* check that the value is modified in hklm classes */
2696 res
= RegQueryValueExA(hklmsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2697 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2698 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2700 /* create a subkey in user's classes */
2701 if (RegCreateKeyExA( hkey
, "subkey1", 0, NULL
, 0,
2702 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkeysub1
, NULL
)) return;
2703 ok(!IS_HKCR(hkeysub1
), "hkcr mask set in %p\n", hkeysub1
);
2705 /* set a value in user's classes */
2706 res
= RegSetValueExA(hkeysub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"user", sizeof("user"));
2707 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2709 /* try to find the value in hkcr */
2710 res
= RegQueryValueExA(hkcrsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2711 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2712 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2714 /* modify the value in hklm */
2715 res
= RegSetValueExA(hklmsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hklm", sizeof("hklm"));
2716 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2718 /* check that the value is not overwritten in hkcr or user's classes */
2719 res
= RegQueryValueExA(hkcrsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2720 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2721 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2722 res
= RegQueryValueExA(hkeysub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2723 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2724 ok(!strcmp( buffer
, "user" ), "value set to '%s'\n", buffer
);
2726 /* modify the value in hkcr */
2727 res
= RegSetValueExA(hkcrsub1
, "subval1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2728 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2730 /* check that the value is not overwritten in hklm, but in user's classes */
2731 res
= RegQueryValueExA(hklmsub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2732 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2733 ok(!strcmp( buffer
, "hklm" ), "value set to '%s'\n", buffer
);
2734 res
= RegQueryValueExA(hkeysub1
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2735 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2736 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2738 /* new subkey in hkcr */
2739 if (RegCreateKeyExA( hkcr
, "subkey2", 0, NULL
, 0,
2740 KEY_QUERY_VALUE
|KEY_SET_VALUE
, NULL
, &hkcrsub2
, NULL
)) return;
2741 ok(IS_HKCR(hkcrsub2
), "hkcr mask not set in %p\n", hkcrsub2
);
2742 res
= RegSetValueExA(hkcrsub2
, "subval1", 0, REG_SZ
, (const BYTE
*)"hkcr", sizeof("hkcr"));
2743 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%x\n", res
, GetLastError());
2745 /* try to open that new subkey in user's classes and hklm */
2746 res
= RegOpenKeyExA( hkey
, "subkey2", 0, KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hklmsub2
);
2747 ok(res
!= ERROR_SUCCESS
, "test key found in user's classes: %d\n", res
);
2749 res
= RegOpenKeyExA( hklm
, "subkey2", 0, KEY_QUERY_VALUE
|KEY_SET_VALUE
, &hklmsub2
);
2750 ok(res
== ERROR_SUCCESS
, "test key not found in hklm: %d\n", res
);
2751 ok(!IS_HKCR(hklmsub2
), "hkcr mask set in %p\n", hklmsub2
);
2753 /* check that the value is present in hklm */
2754 res
= RegQueryValueExA(hklmsub2
, "subval1", NULL
, &type
, (LPBYTE
)buffer
, &size
);
2755 ok(res
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d\n", res
);
2756 ok(!strcmp( buffer
, "hkcr" ), "value set to '%s'\n", buffer
);
2759 RegCloseKey( hkeysub1
);
2760 RegCloseKey( hklmsub1
);
2762 /* delete subkey1 from hkcr (should point at user's classes) */
2763 res
= RegDeleteKeyA(hkcr
, "subkey1");
2764 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
2766 /* confirm key was removed in hkey but not hklm */
2767 res
= RegOpenKeyExA(hkey
, "subkey1", 0, KEY_READ
, &hkeysub1
);
2768 ok(res
== ERROR_FILE_NOT_FOUND
, "test key found in user's classes: %d\n", res
);
2769 res
= RegOpenKeyExA(hklm
, "subkey1", 0, KEY_READ
, &hklmsub1
);
2770 ok(res
== ERROR_SUCCESS
, "test key not found in hklm: %d\n", res
);
2771 ok(!IS_HKCR(hklmsub1
), "hkcr mask set in %p\n", hklmsub1
);
2773 /* delete subkey1 from hkcr again (which should now point at hklm) */
2774 res
= RegDeleteKeyA(hkcr
, "subkey1");
2775 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
2777 /* confirm hkey was removed in hklm */
2778 RegCloseKey( hklmsub1
);
2779 res
= RegOpenKeyExA(hklm
, "subkey1", 0, KEY_READ
, &hklmsub1
);
2780 ok(res
== ERROR_FILE_NOT_FOUND
, "test key found in hklm: %d\n", res
);
2786 delete_key( hkeysub1
);
2787 delete_key( hklmsub1
);
2788 delete_key( hkcrsub1
);
2789 delete_key( hklmsub2
);
2790 delete_key( hkcrsub2
);
2791 RegCloseKey( hkey
);
2792 RegCloseKey( hklm
);
2793 RegCloseKey( hkcr
);
2794 RegCloseKey( hkeysub1
);
2795 RegCloseKey( hklmsub1
);
2796 RegCloseKey( hkcrsub1
);
2797 RegCloseKey( hklmsub2
);
2798 RegCloseKey( hkcrsub2
);
2801 static void test_classesroot_enum(void)
2803 HKEY hkcu
=0, hklm
=0, hkcr
=0, hkcusub
[2]={0}, hklmsub
[2]={0};
2805 static CHAR buffer
[2];
2808 /* prepare initial testing env in HKCU */
2809 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", &hkcu
))
2812 RegCloseKey( hkcu
);
2814 res
= RegCreateKeyExA( HKEY_CURRENT_USER
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
2815 KEY_SET_VALUE
|KEY_ENUMERATE_SUB_KEYS
, NULL
, &hkcu
, NULL
);
2817 if (res
!= ERROR_SUCCESS
)
2819 skip("failed to add a user class\n");
2823 res
= RegOpenKeyA( HKEY_CLASSES_ROOT
, "WineTestCls", &hkcr
);
2824 todo_wine
ok(res
== ERROR_SUCCESS
||
2825 broken(res
== ERROR_FILE_NOT_FOUND
/* WinNT */),
2826 "test key not found in hkcr: %d\n", res
);
2829 skip("HKCR key merging not supported\n");
2831 RegCloseKey( hkcu
);
2835 res
= RegSetValueExA( hkcu
, "X", 0, REG_SZ
, (const BYTE
*) "AA", 3 );
2836 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
2837 res
= RegSetValueExA( hkcu
, "Y", 0, REG_SZ
, (const BYTE
*) "B", 2 );
2838 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
2839 res
= RegCreateKeyA( hkcu
, "A", &hkcusub
[0] );
2840 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
2841 res
= RegCreateKeyA( hkcu
, "B", &hkcusub
[1] );
2842 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
2844 /* test on values in HKCU */
2845 size
= sizeof(buffer
);
2846 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2847 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
2848 ok(!strcmp( buffer
, "X" ), "expected 'X', got '%s'\n", buffer
);
2849 size
= sizeof(buffer
);
2850 res
= RegEnumValueA( hkcr
, 1, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2851 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
2852 ok(!strcmp( buffer
, "Y" ), "expected 'Y', got '%s'\n", buffer
);
2853 size
= sizeof(buffer
);
2854 res
= RegEnumValueA( hkcr
, 2, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2855 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
2857 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
2858 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
2859 ok(!strcmp( buffer
, "A" ), "expected 'A', got '%s'\n", buffer
);
2860 res
= RegEnumKeyA( hkcr
, 1, buffer
, size
);
2861 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
2862 ok(!strcmp( buffer
, "B" ), "expected 'B', got '%s'\n", buffer
);
2863 res
= RegEnumKeyA( hkcr
, 2, buffer
, size
);
2864 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
2866 /* prepare test env in HKLM */
2867 if (!RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", &hklm
))
2870 RegCloseKey( hklm
);
2873 res
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Classes\\WineTestCls", 0, NULL
, 0,
2874 KEY_SET_VALUE
|KEY_ENUMERATE_SUB_KEYS
, NULL
, &hklm
, NULL
);
2876 if (res
== ERROR_ACCESS_DENIED
)
2878 RegCloseKey( hkcusub
[0] );
2879 RegCloseKey( hkcusub
[1] );
2881 RegCloseKey( hkcu
);
2882 RegCloseKey( hkcr
);
2883 skip("not enough privileges to add a system class\n");
2887 res
= RegSetValueExA( hklm
, "X", 0, REG_SZ
, (const BYTE
*) "AB", 3 );
2888 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
2889 res
= RegSetValueExA( hklm
, "Z", 0, REG_SZ
, (const BYTE
*) "C", 2 );
2890 ok(res
== ERROR_SUCCESS
, "RegSetValueExA failed: %d\n", res
);
2891 res
= RegCreateKeyA( hklm
, "A", &hklmsub
[0] );
2892 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
2893 res
= RegCreateKeyA( hklm
, "C", &hklmsub
[1] );
2894 ok(res
== ERROR_SUCCESS
, "RegCreateKeyA failed: %d\n", res
);
2896 /* test on values/keys in both HKCU and HKLM */
2897 size
= sizeof(buffer
);
2898 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2899 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
2900 ok(!strcmp( buffer
, "X" ), "expected 'X', got '%s'\n", buffer
);
2901 size
= sizeof(buffer
);
2902 res
= RegEnumValueA( hkcr
, 1, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2903 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
2904 ok(!strcmp( buffer
, "Y" ), "expected 'Y', got '%s'\n", buffer
);
2905 size
= sizeof(buffer
);
2906 res
= RegEnumValueA( hkcr
, 2, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2907 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
2908 ok(!strcmp( buffer
, "Z" ), "expected 'Z', got '%s'\n", buffer
);
2909 size
= sizeof(buffer
);
2910 res
= RegEnumValueA( hkcr
, 3, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2911 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
2913 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
2914 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
2915 ok(!strcmp( buffer
, "A" ), "expected 'A', got '%s'\n", buffer
);
2916 res
= RegEnumKeyA( hkcr
, 1, buffer
, size
);
2917 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
2918 ok(!strcmp( buffer
, "B" ), "expected 'B', got '%s'\n", buffer
);
2919 res
= RegEnumKeyA( hkcr
, 2, buffer
, size
);
2920 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
2921 ok(!strcmp( buffer
, "C" ), "expected 'C', got '%s'\n", buffer
);
2922 res
= RegEnumKeyA( hkcr
, 3, buffer
, size
);
2923 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
2925 /* delete values/keys from HKCU to test only on HKLM */
2926 RegCloseKey( hkcusub
[0] );
2927 RegCloseKey( hkcusub
[1] );
2929 RegCloseKey( hkcu
);
2931 size
= sizeof(buffer
);
2932 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2933 ok(res
== ERROR_KEY_DELETED
||
2934 res
== ERROR_NO_SYSTEM_RESOURCES
, /* Windows XP */
2935 "expected ERROR_KEY_DELETED, got %d\n", res
);
2936 size
= sizeof(buffer
);
2937 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
2938 ok(res
== ERROR_KEY_DELETED
||
2939 res
== ERROR_NO_SYSTEM_RESOURCES
, /* Windows XP */
2940 "expected ERROR_KEY_DELETED, got %d\n", res
);
2942 /* reopen HKCR handle */
2943 RegCloseKey( hkcr
);
2944 res
= RegOpenKeyA( HKEY_CLASSES_ROOT
, "WineTestCls", &hkcr
);
2945 ok(res
== ERROR_SUCCESS
, "test key not found in hkcr: %d\n", res
);
2946 if (res
) goto cleanup
;
2948 /* test on values/keys in HKLM */
2949 size
= sizeof(buffer
);
2950 res
= RegEnumValueA( hkcr
, 0, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2951 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
2952 ok(!strcmp( buffer
, "X" ), "expected 'X', got '%s'\n", buffer
);
2953 size
= sizeof(buffer
);
2954 res
= RegEnumValueA( hkcr
, 1, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2955 ok(res
== ERROR_SUCCESS
, "RegEnumValueA failed: %d\n", res
);
2956 ok(!strcmp( buffer
, "Z" ), "expected 'Z', got '%s'\n", buffer
);
2957 size
= sizeof(buffer
);
2958 res
= RegEnumValueA( hkcr
, 2, buffer
, &size
, NULL
, NULL
, NULL
, NULL
);
2959 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
2961 res
= RegEnumKeyA( hkcr
, 0, buffer
, size
);
2962 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
2963 ok(!strcmp( buffer
, "A" ), "expected 'A', got '%s'\n", buffer
);
2964 res
= RegEnumKeyA( hkcr
, 1, buffer
, size
);
2965 ok(res
== ERROR_SUCCESS
, "RegEnumKey failed: %d\n", res
);
2966 ok(!strcmp( buffer
, "C" ), "expected 'C', got '%s'\n", buffer
);
2967 res
= RegEnumKeyA( hkcr
, 2, buffer
, size
);
2968 ok(res
== ERROR_NO_MORE_ITEMS
, "expected ERROR_NO_MORE_ITEMS, got %d\n", res
);
2971 RegCloseKey( hklmsub
[0] );
2972 RegCloseKey( hklmsub
[1] );
2974 RegCloseKey( hklm
);
2975 RegCloseKey( hkcr
);
2978 static void test_classesroot_mask(void)
2983 res
= RegOpenKeyA( HKEY_CLASSES_ROOT
, "CLSID", &hkey
);
2984 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
2985 todo_wine
ok(IS_HKCR(hkey
) || broken(!IS_HKCR(hkey
)) /* WinNT */,
2986 "hkcr mask not set in %p\n", hkey
);
2987 RegCloseKey( hkey
);
2989 res
= RegOpenKeyA( HKEY_CURRENT_USER
, "Software", &hkey
);
2990 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
2991 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
2992 RegCloseKey( hkey
);
2994 res
= RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software", &hkey
);
2995 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
2996 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
2997 RegCloseKey( hkey
);
2999 res
= RegOpenKeyA( HKEY_USERS
, ".Default", &hkey
);
3000 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
3001 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
3002 RegCloseKey( hkey
);
3004 res
= RegOpenKeyA( HKEY_CURRENT_CONFIG
, "Software", &hkey
);
3005 ok(res
== ERROR_SUCCESS
, "RegOpenKeyA failed: %d\n", res
);
3006 ok(!IS_HKCR(hkey
), "hkcr mask set in %p\n", hkey
);
3007 RegCloseKey( hkey
);
3010 static void test_deleted_key(void)
3014 DWORD val_count
, type
;
3017 /* Open the test key, then delete it while it's open */
3018 RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey
);
3020 delete_key( hkey_main
);
3022 val_count
= sizeof(value
);
3024 res
= RegEnumValueA( hkey
, 0, value
, &val_count
, NULL
, &type
, 0, 0 );
3025 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3027 res
= RegEnumKeyA( hkey
, 0, value
, sizeof(value
) );
3028 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3030 val_count
= sizeof(value
);
3032 res
= RegQueryValueExA( hkey
, "test", NULL
, &type
, (BYTE
*)value
, &val_count
);
3033 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3035 res
= RegSetValueExA( hkey
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6);
3036 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3038 res
= RegOpenKeyA( hkey
, "test", &hkey2
);
3039 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3041 RegCloseKey( hkey2
);
3043 res
= RegCreateKeyA( hkey
, "test", &hkey2
);
3044 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3046 RegCloseKey( hkey2
);
3048 res
= RegFlushKey( hkey
);
3049 ok(res
== ERROR_KEY_DELETED
, "expect ERROR_KEY_DELETED, got %i\n", res
);
3051 RegCloseKey( hkey
);
3056 static void test_delete_value(void)
3061 res
= RegSetValueExA( hkey_main
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6 );
3062 ok(res
== ERROR_SUCCESS
, "expect ERROR_SUCCESS, got %i\n", res
);
3064 res
= RegQueryValueExA( hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3065 ok(res
== ERROR_SUCCESS
, "expect ERROR_SUCCESS, got %i\n", res
);
3067 res
= RegDeleteValueA( hkey_main
, "test" );
3068 ok(res
== ERROR_SUCCESS
, "expect ERROR_SUCCESS, got %i\n", res
);
3070 res
= RegQueryValueExA( hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3071 ok(res
== ERROR_FILE_NOT_FOUND
, "expect ERROR_FILE_NOT_FOUND, got %i\n", res
);
3073 res
= RegDeleteValueA( hkey_main
, "test" );
3074 ok(res
== ERROR_FILE_NOT_FOUND
, "expect ERROR_FILE_NOT_FOUND, got %i\n", res
);
3076 memset(longname
, 'a', 400);
3078 res
= RegDeleteValueA( hkey_main
, longname
);
3079 ok(res
== ERROR_FILE_NOT_FOUND
|| broken(res
== ERROR_MORE_DATA
), /* nt4, win2k */
3080 "expect ERROR_FILE_NOT_FOUND, got %i\n", res
);
3083 static void test_delete_key_value(void)
3088 if (!pRegDeleteKeyValueA
)
3090 win_skip("RegDeleteKeyValue is not available.\n");
3094 ret
= pRegDeleteKeyValueA(NULL
, NULL
, NULL
);
3095 ok(ret
== ERROR_INVALID_HANDLE
, "got %d\n", ret
);
3097 ret
= pRegDeleteKeyValueA(hkey_main
, NULL
, NULL
);
3098 ok(ret
== ERROR_FILE_NOT_FOUND
, "got %d\n", ret
);
3100 ret
= RegSetValueExA(hkey_main
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6);
3101 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3103 ret
= RegQueryValueExA(hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3104 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3106 /* NULL subkey name means delete from open key */
3107 ret
= pRegDeleteKeyValueA(hkey_main
, NULL
, "test");
3108 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3110 ret
= RegQueryValueExA(hkey_main
, "test", NULL
, NULL
, NULL
, NULL
);
3111 ok(ret
== ERROR_FILE_NOT_FOUND
, "got %d\n", ret
);
3113 /* now with real subkey */
3114 ret
= RegCreateKeyExA(hkey_main
, "Subkey1", 0, NULL
, 0, KEY_WRITE
|KEY_READ
, NULL
, &subkey
, NULL
);
3115 ok(!ret
, "failed with error %d\n", ret
);
3117 ret
= RegSetValueExA(subkey
, "test", 0, REG_SZ
, (const BYTE
*)"value", 6);
3118 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3120 ret
= RegQueryValueExA(subkey
, "test", NULL
, NULL
, NULL
, NULL
);
3121 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3123 ret
= pRegDeleteKeyValueA(hkey_main
, "Subkey1", "test");
3124 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
3126 ret
= RegQueryValueExA(subkey
, "test", NULL
, NULL
, NULL
, NULL
);
3127 ok(ret
== ERROR_FILE_NOT_FOUND
, "got %d\n", ret
);
3129 RegDeleteKeyA(subkey
, "");
3130 RegCloseKey(subkey
);
3133 START_TEST(registry
)
3135 /* Load pointers for functions that are not available in all Windows versions */
3141 create_test_entries();
3143 test_query_value_ex();
3145 test_reg_open_key();
3146 test_reg_create_key();
3147 test_reg_close_key();
3148 test_reg_delete_key();
3149 test_reg_query_value();
3150 test_reg_query_info();
3151 test_string_termination();
3155 test_classesroot_enum();
3156 test_classesroot_mask();
3158 /* SaveKey/LoadKey require the SE_BACKUP_NAME privilege to be set */
3159 if (set_privileges(SE_BACKUP_NAME
, TRUE
) &&
3160 set_privileges(SE_RESTORE_NAME
, TRUE
))
3162 test_reg_save_key();
3163 test_reg_load_key();
3164 test_reg_unload_key();
3166 set_privileges(SE_BACKUP_NAME
, FALSE
);
3167 set_privileges(SE_RESTORE_NAME
, FALSE
);
3170 test_reg_delete_tree();
3173 test_delete_value();
3174 test_delete_key_value();
3177 delete_key( hkey_main
);
3179 test_regconnectregistry();