2 * Unit tests for registry functions
4 * Copyright (c) 2002 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
31 static HKEY hkey_main
;
34 static const char * sTestpath1
= "%LONGSYSTEMVAR%\\subdir1";
35 static const char * sTestpath2
= "%FOO%\\subdir1";
37 static HMODULE hadvapi32
;
38 static DWORD (WINAPI
*pRegGetValueA
)(HKEY
,LPCSTR
,LPCSTR
,DWORD
,LPDWORD
,PVOID
,LPDWORD
);
39 static DWORD (WINAPI
*pRegDeleteTreeA
)(HKEY
,LPCSTR
);
43 /* Debugging functions from wine/libs/wine/debug.c */
45 /* allocate some tmp string space */
46 /* FIXME: this is not 100% thread-safe */
47 static char *get_temp_buffer( int size
)
49 static char *list
[32];
54 idx
= ++pos
% (sizeof(list
)/sizeof(list
[0]));
55 if ((ret
= realloc( list
[idx
], size
))) list
[idx
] = ret
;
59 static const char *wine_debugstr_an( const char *str
, int n
)
61 static const char hex
[16] = "0123456789abcdef";
65 if (!((ULONG_PTR
)str
>> 16))
67 if (!str
) return "(null)";
68 res
= get_temp_buffer( 6 );
69 sprintf( res
, "#%04x", LOWORD(str
) );
72 if (n
== -1) n
= strlen(str
);
74 size
= 10 + min( 300, n
* 4 );
75 dst
= res
= get_temp_buffer( size
);
77 while (n
-- > 0 && dst
<= res
+ size
- 9)
79 unsigned char c
= *str
++;
82 case '\n': *dst
++ = '\\'; *dst
++ = 'n'; break;
83 case '\r': *dst
++ = '\\'; *dst
++ = 'r'; break;
84 case '\t': *dst
++ = '\\'; *dst
++ = 't'; break;
85 case '"': *dst
++ = '\\'; *dst
++ = '"'; break;
86 case '\\': *dst
++ = '\\'; *dst
++ = '\\'; break;
88 if (c
>= ' ' && c
<= 126)
94 *dst
++ = hex
[(c
>> 4) & 0x0f];
95 *dst
++ = hex
[c
& 0x0f];
110 static const char *wine_debugstr_wn( const WCHAR
*str
, int n
)
117 if (!str
) return "(null)";
118 res
= get_temp_buffer( 6 );
119 sprintf( res
, "#%04x", LOWORD(str
) );
122 if (n
== -1) n
= lstrlenW(str
);
124 size
= 12 + min( 300, n
* 5);
125 dst
= res
= get_temp_buffer( n
* 5 + 7 );
128 while (n
-- > 0 && dst
<= res
+ size
- 10)
133 case '\n': *dst
++ = '\\'; *dst
++ = 'n'; break;
134 case '\r': *dst
++ = '\\'; *dst
++ = 'r'; break;
135 case '\t': *dst
++ = '\\'; *dst
++ = 't'; break;
136 case '"': *dst
++ = '\\'; *dst
++ = '"'; break;
137 case '\\': *dst
++ = '\\'; *dst
++ = '\\'; break;
139 if (c
>= ' ' && c
<= 126)
144 sprintf(dst
,"%04x",c
);
161 #define ADVAPI32_GET_PROC(func) \
162 p ## func = (void*)GetProcAddress(hadvapi32, #func); \
164 trace("GetProcAddress(%s) failed\n", #func);
166 static void InitFunctionPtrs(void)
168 hadvapi32
= GetModuleHandleA("advapi32.dll");
170 /* This function was introduced with Windows 2003 SP1 */
171 ADVAPI32_GET_PROC(RegGetValueA
)
172 ADVAPI32_GET_PROC(RegDeleteTreeA
)
175 /* delete key and all its subkeys */
176 static DWORD
delete_key( HKEY hkey
)
181 while (!(ret
= RegEnumKeyA(hkey
, 0, name
, sizeof(name
))))
184 if (!(ret
= RegOpenKeyExA( hkey
, name
, 0, KEY_ENUMERATE_SUB_KEYS
, &tmp
)))
186 ret
= delete_key( tmp
);
191 if (ret
!= ERROR_NO_MORE_ITEMS
) return ret
;
192 RegDeleteKeyA( hkey
, "" );
196 static void setup_main_key(void)
198 if (!RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
)) delete_key( hkey_main
);
200 assert (!RegCreateKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
));
203 static void test_hkey_main_Value_A(LPCSTR name
, LPCSTR string
,
206 DWORD ret
, type
, cbData
;
209 static const char nA
[]={'N', 0};
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 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA 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 ok(type
== REG_SZ
, "RegQueryValueExA returned type %d\n", type
);
226 ok(cbData
== full_byte_len
|| cbData
== str_byte_len
/* Win9x */,
227 "cbData=%d instead of %d or %d\n", cbData
, full_byte_len
, str_byte_len
);
229 value
= HeapAlloc(GetProcessHeap(), 0, (cbData
+2)*sizeof(*value
));
232 ret
= RegQueryValueExA(hkey_main
, name
, NULL
, &type
, (BYTE
*)value
, &cbData
);
233 GLE
= GetLastError();
234 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExA failed: %d, GLE=%d\n", ret
, GLE
);
237 /* When cbData == 0, RegQueryValueExA() should not modify the buffer */
238 ok(strcmp(value
, nA
) == 0 || (cbData
== 1 && *value
== '\0') /* Win9x */,
239 "RegQueryValueExA failed: '%s' != '%s'\n", value
, string
);
243 ok(memcmp(value
, string
, cbData
) == 0, "RegQueryValueExA failed: %s/%d != %s/%d\n",
244 wine_debugstr_an(value
, cbData
), cbData
,
245 wine_debugstr_an(string
, full_byte_len
), full_byte_len
);
247 HeapFree(GetProcessHeap(), 0, value
);
250 static void test_hkey_main_Value_W(LPCWSTR name
, LPCWSTR string
,
253 DWORD ret
, type
, cbData
;
255 static const WCHAR nW
[]={'N', 0};
259 /* When successful RegQueryValueExW() leaves GLE as is,
260 * so we must reset it to detect unimplemented functions.
262 SetLastError(0xdeadbeef);
263 ret
= RegQueryValueExW(hkey_main
, name
, NULL
, &type
, NULL
, &cbData
);
264 GLE
= GetLastError();
265 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExW failed: %d, GLE=%d\n", ret
, GLE
);
266 if(GLE
== ERROR_CALL_NOT_IMPLEMENTED
) return;
268 ok(type
== REG_SZ
, "RegQueryValueExW returned type %d\n", type
);
269 ok(cbData
== full_byte_len
,
270 "cbData=%d instead of %d\n", cbData
, full_byte_len
);
272 value
= HeapAlloc(GetProcessHeap(), 0, (cbData
+2)*sizeof(*value
));
275 ret
= RegQueryValueExW(hkey_main
, name
, NULL
, &type
, (BYTE
*)value
, &cbData
);
276 GLE
= GetLastError();
277 ok(ret
== ERROR_SUCCESS
, "RegQueryValueExW failed: %d, GLE=%d\n", ret
, GLE
);
280 /* When cbData == 0, RegQueryValueExW() should not modify the buffer */
283 ok(memcmp(value
, string
, cbData
) == 0, "RegQueryValueExW failed: %s/%d != %s/%d\n",
284 wine_debugstr_wn(value
, cbData
/ sizeof(WCHAR
)), cbData
,
285 wine_debugstr_wn(string
, full_byte_len
/ sizeof(WCHAR
)), full_byte_len
);
286 HeapFree(GetProcessHeap(), 0, value
);
289 static void test_set_value(void)
293 static const WCHAR name1W
[] = {'C','l','e','a','n','S','i','n','g','l','e','S','t','r','i','n','g', 0};
294 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};
295 static const WCHAR emptyW
[] = {0};
296 static const WCHAR string1W
[] = {'T','h','i','s','N','e','v','e','r','B','r','e','a','k','s', 0};
297 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};
298 static const WCHAR substring2W
[] = {'T','h','i','s',0};
300 static const char name1A
[] = "CleanSingleString";
301 static const char name2A
[] = "SomeIntraZeroedString";
302 static const char emptyA
[] = "";
303 static const char string1A
[] = "ThisNeverBreaks";
304 static const char string2A
[] = "This\0Breaks\0\0A\0\0\0Lot\0\0\0\0";
305 static const char substring2A
[] = "This";
309 /* Crashes on NT4, Windows 2000 and XP SP1 */
310 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, NULL
, 0);
311 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueA should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret
);
314 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string1A
, sizeof(string1A
));
315 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
316 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
317 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
319 /* RegSetValueA ignores the size passed in */
320 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string1A
, 4);
321 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
322 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
323 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
325 /* stops at first null */
326 ret
= RegSetValueA(hkey_main
, NULL
, REG_SZ
, string2A
, sizeof(string2A
));
327 ok(ret
== ERROR_SUCCESS
, "RegSetValueA failed: %d, GLE=%d\n", ret
, GetLastError());
328 test_hkey_main_Value_A(NULL
, substring2A
, sizeof(substring2A
));
329 test_hkey_main_Value_W(NULL
, substring2W
, sizeof(substring2W
));
331 /* only REG_SZ is supported */
332 ret
= RegSetValueA(hkey_main
, NULL
, REG_BINARY
, string2A
, sizeof(string2A
));
333 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueA should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
334 ret
= RegSetValueA(hkey_main
, NULL
, REG_EXPAND_SZ
, string2A
, sizeof(string2A
));
335 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueA should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
336 ret
= RegSetValueA(hkey_main
, NULL
, REG_MULTI_SZ
, string2A
, sizeof(string2A
));
337 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueA should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
339 /* Test RegSetValueExA with a 'zero-byte' string (as Office 2003 does).
340 * Surprisingly enough we're supposed to get zero bytes out of it.
342 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)emptyA
, 0);
343 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
344 test_hkey_main_Value_A(name1A
, NULL
, 0);
345 test_hkey_main_Value_W(name1W
, NULL
, 0);
347 /* test RegSetValueExA with an empty string */
348 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)emptyA
, sizeof(emptyA
));
349 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
350 test_hkey_main_Value_A(name1A
, emptyA
, sizeof(emptyA
));
351 test_hkey_main_Value_W(name1W
, emptyW
, sizeof(emptyW
));
353 /* test RegSetValueExA with off-by-one size */
354 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)string1A
, sizeof(string1A
)-sizeof(string1A
[0]));
355 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
356 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
357 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
359 /* test RegSetValueExA with normal string */
360 ret
= RegSetValueExA(hkey_main
, name1A
, 0, REG_SZ
, (const BYTE
*)string1A
, sizeof(string1A
));
361 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
362 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
363 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
365 /* test RegSetValueExA with intrazeroed string */
366 ret
= RegSetValueExA(hkey_main
, name2A
, 0, REG_SZ
, (const BYTE
*)string2A
, sizeof(string2A
));
367 ok(ret
== ERROR_SUCCESS
, "RegSetValueExA failed: %d, GLE=%d\n", ret
, GetLastError());
368 test_hkey_main_Value_A(name2A
, string2A
, sizeof(string2A
));
369 test_hkey_main_Value_W(name2W
, string2W
, sizeof(string2W
));
371 /* 9x doesn't support W-calls, so don't test them then */
372 if(GLE
== ERROR_CALL_NOT_IMPLEMENTED
) return;
376 /* Crashes on NT4, Windows 2000 and XP SP1 */
377 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, NULL
, 0);
378 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret
);
381 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string1W
, sizeof(string1W
));
382 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
383 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
384 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
386 /* RegSetValueA ignores the size passed in */
387 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string1W
, 4 * sizeof(string1W
[0]));
388 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
389 test_hkey_main_Value_A(NULL
, string1A
, sizeof(string1A
));
390 test_hkey_main_Value_W(NULL
, string1W
, sizeof(string1W
));
392 /* stops at first null */
393 ret
= RegSetValueW(hkey_main
, NULL
, REG_SZ
, string2W
, sizeof(string2W
));
394 ok(ret
== ERROR_SUCCESS
, "RegSetValueW failed: %d, GLE=%d\n", ret
, GetLastError());
395 test_hkey_main_Value_A(NULL
, substring2A
, sizeof(substring2A
));
396 test_hkey_main_Value_W(NULL
, substring2W
, sizeof(substring2W
));
398 /* only REG_SZ is supported */
399 ret
= RegSetValueW(hkey_main
, NULL
, REG_BINARY
, string2W
, sizeof(string2W
));
400 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
401 ret
= RegSetValueW(hkey_main
, NULL
, REG_EXPAND_SZ
, string2W
, sizeof(string2W
));
402 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
403 ret
= RegSetValueW(hkey_main
, NULL
, REG_MULTI_SZ
, string2W
, sizeof(string2W
));
404 ok(ret
== ERROR_INVALID_PARAMETER
, "RegSetValueW should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
406 /* test RegSetValueExW with off-by-one size */
407 ret
= RegSetValueExW(hkey_main
, name1W
, 0, REG_SZ
, (const BYTE
*)string1W
, sizeof(string1W
)-sizeof(string1W
[0]));
408 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
409 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
410 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
412 /* test RegSetValueExW with normal string */
413 ret
= RegSetValueExW(hkey_main
, name1W
, 0, REG_SZ
, (const BYTE
*)string1W
, sizeof(string1W
));
414 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
415 test_hkey_main_Value_A(name1A
, string1A
, sizeof(string1A
));
416 test_hkey_main_Value_W(name1W
, string1W
, sizeof(string1W
));
418 /* test RegSetValueExW with intrazeroed string */
419 ret
= RegSetValueExW(hkey_main
, name2W
, 0, REG_SZ
, (const BYTE
*)string2W
, sizeof(string2W
));
420 ok(ret
== ERROR_SUCCESS
, "RegSetValueExW failed: %d, GLE=%d\n", ret
, GetLastError());
421 test_hkey_main_Value_A(name2A
, string2A
, sizeof(string2A
));
422 test_hkey_main_Value_W(name2W
, string2W
, sizeof(string2W
));
425 static void create_test_entries(void)
427 static const DWORD qw
[2] = { 0x12345678, 0x87654321 };
429 SetEnvironmentVariableA("LONGSYSTEMVAR", "bar");
430 SetEnvironmentVariableA("FOO", "ImARatherLongButIndeedNeededString");
432 ok(!RegSetValueExA(hkey_main
,"TP1_EXP_SZ",0,REG_EXPAND_SZ
, (const BYTE
*)sTestpath1
, strlen(sTestpath1
)+1),
433 "RegSetValueExA failed\n");
434 ok(!RegSetValueExA(hkey_main
,"TP1_SZ",0,REG_SZ
, (const BYTE
*)sTestpath1
, strlen(sTestpath1
)+1),
435 "RegSetValueExA failed\n");
436 ok(!RegSetValueExA(hkey_main
,"TP1_ZB_SZ",0,REG_SZ
, NULL
, 0),
437 "RegSetValueExA failed\n");
438 ok(!RegSetValueExA(hkey_main
,"TP2_EXP_SZ",0,REG_EXPAND_SZ
, (const BYTE
*)sTestpath2
, strlen(sTestpath2
)+1),
439 "RegSetValueExA failed\n");
440 ok(!RegSetValueExA(hkey_main
,"DWORD",0,REG_DWORD
, (const BYTE
*)qw
, 4),
441 "RegSetValueExA failed\n");
442 ok(!RegSetValueExA(hkey_main
,"BIN32",0,REG_BINARY
, (const BYTE
*)qw
, 4),
443 "RegSetValueExA failed\n");
444 ok(!RegSetValueExA(hkey_main
,"BIN64",0,REG_BINARY
, (const BYTE
*)qw
, 8),
445 "RegSetValueExA failed\n");
448 static void test_enum_value(void)
452 char value
[20], data
[20];
453 WCHAR valueW
[20], dataW
[20];
454 DWORD val_count
, data_count
, type
;
455 static const WCHAR foobarW
[] = {'f','o','o','b','a','r',0};
456 static const WCHAR testW
[] = {'T','e','s','t',0};
457 static const WCHAR xxxW
[] = {'x','x','x','x','x','x','x','x',0};
459 /* create the working key for new 'Test' value */
460 res
= RegCreateKeyA( hkey_main
, "TestKey", &test_key
);
461 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
463 /* check NULL data with zero length */
464 res
= RegSetValueExA( test_key
, "Test", 0, REG_SZ
, NULL
, 0 );
465 if (GetVersion() & 0x80000000)
466 ok( res
== ERROR_INVALID_PARAMETER
, "RegSetValueExA returned %d\n", res
);
468 ok( !res
, "RegSetValueExA returned %d\n", res
);
469 res
= RegSetValueExA( test_key
, "Test", 0, REG_EXPAND_SZ
, NULL
, 0 );
470 ok( ERROR_SUCCESS
== res
|| ERROR_INVALID_PARAMETER
== res
, "RegSetValueExA returned %d\n", res
);
471 res
= RegSetValueExA( test_key
, "Test", 0, REG_BINARY
, NULL
, 0 );
472 ok( ERROR_SUCCESS
== res
|| ERROR_INVALID_PARAMETER
== res
, "RegSetValueExA returned %d\n", res
);
474 res
= RegSetValueExA( test_key
, "Test", 0, REG_SZ
, (const BYTE
*)"foobar", 7 );
475 ok( res
== 0, "RegSetValueExA failed error %d\n", res
);
477 /* overflow both name and data */
481 strcpy( value
, "xxxxxxxxxx" );
482 strcpy( data
, "xxxxxxxxxx" );
483 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
484 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
485 ok( val_count
== 2, "val_count set to %d\n", val_count
);
486 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
487 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
488 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
489 ok( !strcmp( data
, "xxxxxxxxxx" ), "data set to '%s'\n", data
);
495 strcpy( value
, "xxxxxxxxxx" );
496 strcpy( data
, "xxxxxxxxxx" );
497 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
498 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
499 /* Win9x returns 2 as specified by MSDN but NT returns 3... */
500 ok( val_count
== 2 || val_count
== 3, "val_count set to %d\n", val_count
);
501 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
502 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
503 /* v5.1.2600.0 (XP Home and Professional) does not touch value or data in this case */
504 ok( !strcmp( value
, "Te" ) || !strcmp( value
, "xxxxxxxxxx" ),
505 "value set to '%s' instead of 'Te' or 'xxxxxxxxxx'\n", value
);
506 ok( !strcmp( data
, "foobar" ) || !strcmp( data
, "xxxxxxx" ),
507 "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data
);
509 /* overflow empty name */
513 strcpy( value
, "xxxxxxxxxx" );
514 strcpy( data
, "xxxxxxxxxx" );
515 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
516 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
517 ok( val_count
== 0, "val_count set to %d\n", val_count
);
518 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
519 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
520 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
521 /* v5.1.2600.0 (XP Home and Professional) does not touch data in this case */
522 ok( !strcmp( data
, "foobar" ) || !strcmp( data
, "xxxxxxx" ),
523 "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data
);
529 strcpy( value
, "xxxxxxxxxx" );
530 strcpy( data
, "xxxxxxxxxx" );
531 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
532 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
533 ok( val_count
== 20, "val_count set to %d\n", val_count
);
534 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
535 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
536 ok( !strcmp( value
, "xxxxxxxxxx" ), "value set to '%s'\n", value
);
537 ok( !strcmp( data
, "xxxxxxxxxx" ), "data set to '%s'\n", data
);
543 strcpy( value
, "xxxxxxxxxx" );
544 strcpy( data
, "xxxxxxxxxx" );
545 res
= RegEnumValueA( test_key
, 0, value
, &val_count
, NULL
, &type
, (LPBYTE
)data
, &data_count
);
546 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
547 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
548 ok( data_count
== 7, "data_count set to %d instead of 7\n", data_count
);
549 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
550 ok( !strcmp( value
, "Test" ), "value is '%s' instead of Test\n", value
);
551 ok( !strcmp( data
, "foobar" ), "data is '%s' instead of foobar\n", data
);
555 SetLastError(0xdeadbeef);
556 res
= RegSetValueExW( test_key
, testW
, 0, REG_SZ
, (const BYTE
*)foobarW
, 7*sizeof(WCHAR
) );
557 if (res
==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
559 skip("RegSetValueExW is not implemented\n");
562 ok( res
== 0, "RegSetValueExW failed error %d\n", res
);
564 /* overflow both name and data */
568 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
569 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
570 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
571 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
572 ok( val_count
== 2, "val_count set to %d\n", val_count
);
573 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
574 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
575 ok( !memcmp( valueW
, xxxW
, sizeof(xxxW
) ), "value modified\n" );
576 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
582 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
583 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
584 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
585 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
586 ok( val_count
== 3, "val_count set to %d\n", val_count
);
587 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
588 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
589 ok( !memcmp( valueW
, xxxW
, sizeof(xxxW
) ), "value modified\n" );
590 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
596 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
597 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
598 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
599 ok( res
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %d\n", res
);
600 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
601 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
602 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
603 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
604 ok( !memcmp( dataW
, xxxW
, sizeof(xxxW
) ), "data modified\n" );
610 memcpy( valueW
, xxxW
, sizeof(xxxW
) );
611 memcpy( dataW
, xxxW
, sizeof(xxxW
) );
612 res
= RegEnumValueW( test_key
, 0, valueW
, &val_count
, NULL
, &type
, (BYTE
*)dataW
, &data_count
);
613 ok( res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", res
);
614 ok( val_count
== 4, "val_count set to %d instead of 4\n", val_count
);
615 ok( data_count
== 7*sizeof(WCHAR
), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count
);
616 ok( type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
617 ok( !memcmp( valueW
, testW
, sizeof(testW
) ), "value is not 'Test'\n" );
618 ok( !memcmp( dataW
, foobarW
, sizeof(foobarW
) ), "data is not 'foobar'\n" );
621 RegDeleteKeyA(test_key
, "");
622 RegCloseKey(test_key
);
625 static void test_query_value_ex(void)
632 ret
= RegQueryValueExA(hkey_main
, "TP1_SZ", NULL
, &type
, NULL
, &size
);
633 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
634 ok(size
== strlen(sTestpath1
) + 1, "(%d,%d)\n", (DWORD
)strlen(sTestpath1
) + 1, size
);
635 ok(type
== REG_SZ
, "type %d is not REG_SZ\n", type
);
639 ret
= RegQueryValueExA(HKEY_CLASSES_ROOT
, "Nonexistent Value", NULL
, &type
, NULL
, &size
);
640 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
641 /* the type parameter is cleared on Win9x, but is set to a random value on
642 * NT, so don't do that test there. The size parameter is left untouched on Win9x
643 * but cleared on NT+, this can be tested on all platforms.
645 if (GetVersion() & 0x80000000)
647 ok(type
== 0, "type should have been set to 0 instead of 0x%x\n", type
);
648 ok(size
== 0xdeadbeef, "size should have been left untouched (0xdeadbeef)\n");
652 trace("test_query_value_ex: type set to: 0x%08x\n", type
);
653 ok(size
== 0, "size should have been set to 0 instead of %d\n", size
);
656 size
= sizeof(buffer
);
657 ret
= RegQueryValueExA(HKEY_CLASSES_ROOT
, "Nonexistent Value", NULL
, &type
, buffer
, &size
);
658 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
659 ok(size
== sizeof(buffer
), "size shouldn't have been changed to %d\n", size
);
662 ret
= RegQueryValueExA(hkey_main
, "BIN32", NULL
, &size
, buffer
, &size
);
663 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
666 static void test_get_value(void)
673 CHAR expanded
[] = "bar\\subdir1";
674 CHAR expanded2
[] = "ImARatherLongButIndeedNeededString\\subdir1";
678 skip("RegGetValue not available on this platform\n");
682 /* Invalid parameter */
683 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_DWORD
, &type
, &dw
, NULL
);
684 ok(ret
== ERROR_INVALID_PARAMETER
, "ret=%d\n", ret
);
686 /* Query REG_DWORD using RRF_RT_REG_DWORD (ok) */
687 size
= type
= dw
= 0xdeadbeef;
688 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_DWORD
, &type
, &dw
, &size
);
689 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
690 ok(size
== 4, "size=%d\n", size
);
691 ok(type
== REG_DWORD
, "type=%d\n", type
);
692 ok(dw
== 0x12345678, "dw=%d\n", dw
);
694 /* Query by subkey-name */
695 ret
= pRegGetValueA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", "DWORD", RRF_RT_REG_DWORD
, NULL
, NULL
, NULL
);
696 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
698 /* Query REG_DWORD using RRF_RT_REG_BINARY (restricted) */
699 size
= type
= dw
= 0xdeadbeef;
700 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_BINARY
, &type
, &dw
, &size
);
701 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
702 /* Although the function failed all values are retrieved */
703 ok(size
== 4, "size=%d\n", size
);
704 ok(type
== REG_DWORD
, "type=%d\n", type
);
705 ok(dw
== 0x12345678, "dw=%d\n", dw
);
707 /* Test RRF_ZEROONFAILURE */
708 type
= dw
= 0xdeadbeef; size
= 4;
709 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_SZ
|RRF_ZEROONFAILURE
, &type
, &dw
, &size
);
710 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
711 /* Again all values are retrieved ... */
712 ok(size
== 4, "size=%d\n", size
);
713 ok(type
== REG_DWORD
, "type=%d\n", type
);
714 /* ... except the buffer, which is zeroed out */
715 ok(dw
== 0, "dw=%d\n", dw
);
717 /* Test RRF_ZEROONFAILURE with a NULL buffer... */
718 type
= size
= 0xbadbeef;
719 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_REG_SZ
|RRF_ZEROONFAILURE
, &type
, NULL
, &size
);
720 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
721 ok(size
== 4, "size=%d\n", size
);
722 ok(type
== REG_DWORD
, "type=%d\n", type
);
724 /* Query REG_DWORD using RRF_RT_DWORD (ok) */
725 size
= type
= dw
= 0xdeadbeef;
726 ret
= pRegGetValueA(hkey_main
, NULL
, "DWORD", RRF_RT_DWORD
, &type
, &dw
, &size
);
727 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
728 ok(size
== 4, "size=%d\n", size
);
729 ok(type
== REG_DWORD
, "type=%d\n", type
);
730 ok(dw
== 0x12345678, "dw=%d\n", dw
);
732 /* Query 32-bit REG_BINARY using RRF_RT_DWORD (ok) */
733 size
= type
= dw
= 0xdeadbeef;
734 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN32", RRF_RT_DWORD
, &type
, &dw
, &size
);
735 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
736 ok(size
== 4, "size=%d\n", size
);
737 ok(type
== REG_BINARY
, "type=%d\n", type
);
738 ok(dw
== 0x12345678, "dw=%d\n", dw
);
740 /* Query 64-bit REG_BINARY using RRF_RT_DWORD (type mismatch) */
741 qw
[0] = qw
[1] = size
= type
= 0xdeadbeef;
742 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_DWORD
, &type
, qw
, &size
);
743 ok(ret
== ERROR_DATATYPE_MISMATCH
, "ret=%d\n", ret
);
744 ok(size
== 8, "size=%d\n", size
);
745 ok(type
== REG_BINARY
, "type=%d\n", type
);
746 ok(qw
[0] == 0x12345678 &&
747 qw
[1] == 0x87654321, "qw={%d,%d}\n", qw
[0], qw
[1]);
749 /* Query 64-bit REG_BINARY using 32-bit buffer (buffer too small) */
750 type
= dw
= 0xdeadbeef; size
= 4;
751 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_REG_BINARY
, &type
, &dw
, &size
);
752 ok(ret
== ERROR_MORE_DATA
, "ret=%d\n", ret
);
753 ok(dw
== 0xdeadbeef, "dw=%d\n", dw
);
754 ok(size
== 8, "size=%d\n", size
);
756 /* Query 64-bit REG_BINARY using RRF_RT_QWORD (ok) */
757 qw
[0] = qw
[1] = size
= type
= 0xdeadbeef;
758 ret
= pRegGetValueA(hkey_main
, NULL
, "BIN64", RRF_RT_QWORD
, &type
, qw
, &size
);
759 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
760 ok(size
== 8, "size=%d\n", size
);
761 ok(type
== REG_BINARY
, "type=%d\n", type
);
762 ok(qw
[0] == 0x12345678 &&
763 qw
[1] == 0x87654321, "qw={%d,%d}\n", qw
[0], qw
[1]);
765 /* Query REG_SZ using RRF_RT_REG_SZ (ok) */
766 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
767 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
768 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
769 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
770 ok(type
== REG_SZ
, "type=%d\n", type
);
771 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
773 /* Query REG_SZ using RRF_RT_REG_SZ and no buffer (ok) */
774 type
= 0xdeadbeef; size
= 0;
775 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
, &type
, NULL
, &size
);
776 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
777 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
778 ok(size
== strlen(sTestpath1
)+1 || size
== strlen(sTestpath1
)+2,
779 "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
780 ok(type
== REG_SZ
, "type=%d\n", type
);
782 /* Query REG_SZ using RRF_RT_REG_SZ on a zero-byte value (ok) */
783 strcpy(buf
, sTestpath1
);
786 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_ZB_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
787 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
788 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
790 size
== 1, /* win2k3 */
792 ok(type
== REG_SZ
, "type=%d\n", type
);
793 ok(!strcmp(sTestpath1
, buf
) ||
795 "Expected \"%s\" or \"\", got \"%s\"\n", sTestpath1
, buf
);
797 /* Query REG_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (ok) */
798 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
799 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_SZ", RRF_RT_REG_SZ
|RRF_NOEXPAND
, &type
, buf
, &size
);
800 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
801 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
802 ok(type
== REG_SZ
, "type=%d\n", type
);
803 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
805 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ and no buffer (ok, expands) */
807 ret
= pRegGetValueA(hkey_main
, NULL
, "TP2_EXP_SZ", RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
808 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
809 ok((size
== strlen(expanded2
)+1) || /* win2k3 SP1 */
810 (size
== strlen(expanded2
)+2) || /* win2k3 SP2 */
811 (size
== strlen(sTestpath2
)+1),
812 "strlen(expanded2)=%d, strlen(sTestpath2)=%d, size=%d\n", lstrlenA(expanded2
), lstrlenA(sTestpath2
), size
);
814 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands) */
815 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
816 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
817 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
818 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
819 ok((size
== strlen(expanded
)+1) || (size
== strlen(sTestpath1
)+1),
820 "strlen(expanded)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded
), lstrlenA(sTestpath1
), size
);
821 ok(type
== REG_SZ
, "type=%d\n", type
);
822 ok(!strcmp(expanded
, buf
), "expanded=\"%s\" buf=\"%s\"\n", expanded
, buf
);
824 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands a lot) */
825 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
826 ret
= pRegGetValueA(hkey_main
, NULL
, "TP2_EXP_SZ", RRF_RT_REG_SZ
, &type
, buf
, &size
);
827 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
828 /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath2 length + 1 here. */
829 ok((size
== strlen(expanded2
)+1) || (size
== strlen(sTestpath2
)+1),
830 "strlen(expanded2)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded2
), lstrlenA(sTestpath2
), size
);
831 ok(type
== REG_SZ
, "type=%d\n", type
);
832 ok(!strcmp(expanded2
, buf
), "expanded2=\"%s\" buf=\"%s\"\n", expanded2
, buf
);
834 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND (ok, doesn't expand) */
835 buf
[0] = 0; type
= 0xdeadbeef; size
= sizeof(buf
);
836 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
|RRF_NOEXPAND
, &type
, buf
, &size
);
837 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
838 ok(size
== strlen(sTestpath1
)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
839 ok(type
== REG_EXPAND_SZ
, "type=%d\n", type
);
840 ok(!strcmp(sTestpath1
, buf
), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1
, buf
);
842 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND and no buffer (ok, doesn't expand) */
844 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
|RRF_NOEXPAND
, NULL
, NULL
, &size
);
845 ok(ret
== ERROR_SUCCESS
, "ret=%d\n", ret
);
846 /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
847 ok(size
== strlen(sTestpath1
)+1 || size
== strlen(sTestpath1
)+2,
848 "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1
), size
);
850 /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (type mismatch) */
851 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_SZ
|RRF_NOEXPAND
, NULL
, NULL
, NULL
);
852 ok(ret
== ERROR_UNSUPPORTED_TYPE
, "ret=%d\n", ret
);
854 /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ (not allowed without RRF_NOEXPAND) */
855 ret
= pRegGetValueA(hkey_main
, NULL
, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ
, NULL
, NULL
, NULL
);
856 ok(ret
== ERROR_INVALID_PARAMETER
, "ret=%d\n", ret
);
859 static void test_reg_open_key(void)
862 HKEY hkResult
= NULL
;
863 HKEY hkPreserve
= NULL
;
865 /* successful open */
866 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkResult
);
867 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
868 ok(hkResult
!= NULL
, "expected hkResult != NULL\n");
869 hkPreserve
= hkResult
;
871 /* these tests fail on Win9x, but we want to be compatible with NT, so
872 * run them if we can */
873 if (!(GetVersion() & 0x80000000))
875 /* open same key twice */
876 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkResult
);
877 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
878 ok(hkResult
!= hkPreserve
, "epxected hkResult != hkPreserve\n");
879 ok(hkResult
!= NULL
, "hkResult != NULL\n");
880 RegCloseKey(hkResult
);
882 /* open nonexistent key
883 * check that hkResult is set to NULL
885 hkResult
= hkPreserve
;
886 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Nonexistent", &hkResult
);
887 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
888 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
890 /* open the same nonexistent key again to make sure the key wasn't created */
891 hkResult
= hkPreserve
;
892 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Nonexistent", &hkResult
);
893 ok(ret
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
894 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
896 /* send in NULL lpSubKey
897 * check that hkResult receives the value of hKey
899 hkResult
= hkPreserve
;
900 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, NULL
, &hkResult
);
901 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
902 ok(hkResult
== HKEY_CURRENT_USER
, "expected hkResult == HKEY_CURRENT_USER\n");
904 /* send empty-string in lpSubKey */
905 hkResult
= hkPreserve
;
906 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "", &hkResult
);
907 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
908 ok(hkResult
== HKEY_CURRENT_USER
, "expected hkResult == HKEY_CURRENT_USER\n");
910 /* send in NULL lpSubKey and NULL hKey
911 * hkResult is set to NULL
913 hkResult
= hkPreserve
;
914 ret
= RegOpenKeyA(NULL
, NULL
, &hkResult
);
915 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
916 ok(hkResult
== NULL
, "expected hkResult == NULL\n");
919 /* only send NULL hKey
920 * the value of hkResult remains unchanged
922 hkResult
= hkPreserve
;
923 ret
= RegOpenKeyA(NULL
, "Software\\Wine\\Test", &hkResult
);
924 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 95 returns BADKEY */
925 "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
926 ok(hkResult
== hkPreserve
, "expected hkResult == hkPreserve\n");
927 RegCloseKey(hkResult
);
929 /* send in NULL hkResult */
930 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", NULL
);
931 ok(ret
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
933 /* beginning backslash character */
934 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "\\Software\\Wine\\Test", &hkResult
);
935 ok(ret
== ERROR_BAD_PATHNAME
|| /* NT/2k/XP */
936 ret
== ERROR_FILE_NOT_FOUND
/* Win9x,ME */
937 , "expected ERROR_BAD_PATHNAME or ERROR_FILE_NOT_FOUND, got %d\n", ret
);
940 static void test_reg_create_key(void)
944 ret
= RegCreateKeyExA(hkey_main
, "Subkey1", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
945 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
946 /* should succeed: all versions of Windows ignore the access rights
947 * to the parent handle */
948 ret
= RegCreateKeyExA(hkey1
, "Subkey2", 0, NULL
, 0, KEY_SET_VALUE
, NULL
, &hkey2
, NULL
);
949 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
952 RegDeleteKey(hkey2
, "");
953 RegDeleteKey(hkey1
, "");
955 /* beginning backslash character */
956 ret
= RegCreateKeyExA(hkey_main
, "\\Subkey3", 0, NULL
, 0, KEY_NOTIFY
, NULL
, &hkey1
, NULL
);
957 if (!(GetVersion() & 0x80000000))
958 ok(ret
== ERROR_BAD_PATHNAME
, "expected ERROR_BAD_PATHNAME, got %d\n", ret
);
960 ok(!ret
, "RegCreateKeyExA failed with error %d\n", ret
);
961 RegDeleteKey(hkey1
, NULL
);
965 static void test_reg_close_key(void)
970 /* successfully close key
971 * hkHandle remains changed after call to RegCloseKey
973 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkHandle
);
974 ret
= RegCloseKey(hkHandle
);
975 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
977 /* try to close the key twice */
978 ret
= RegCloseKey(hkHandle
); /* Windows 95 doesn't mind. */
979 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_SUCCESS
,
980 "expected ERROR_INVALID_HANDLE or ERROR_SUCCESS, got %d\n", ret
);
982 /* try to close a NULL handle */
983 ret
= RegCloseKey(NULL
);
984 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 95 returns BADKEY */
985 "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
987 /* Check to see if we didn't potentially close our main handle, which could happen on win98 as
988 * win98 doesn't give a new handle when the same key is opened.
989 * Not re-opening will make some next tests fail.
991 if (hkey_main
== hkHandle
)
993 trace("The main handle is most likely closed, so re-opening\n");
994 RegOpenKeyA( HKEY_CURRENT_USER
, "Software\\Wine\\Test", &hkey_main
);
998 static void test_reg_delete_key(void)
1002 ret
= RegDeleteKey(hkey_main
, NULL
);
1004 /* There is a bug in NT4 and W2K that doesn't check if the subkey is NULL. If
1005 * there are also no subkeys available it will delete the key pointed to by hkey_main.
1006 * Not re-creating will make some next tests fail.
1008 if (ret
== ERROR_SUCCESS
)
1010 trace("We are probably running on NT4 or W2K as the main key is deleted,"
1011 " re-creating the main key\n");
1015 ok(ret
== ERROR_INVALID_PARAMETER
||
1016 ret
== ERROR_ACCESS_DENIED
||
1017 ret
== ERROR_BADKEY
, /* Win95 */
1021 static void test_reg_save_key(void)
1025 ret
= RegSaveKey(hkey_main
, "saved_key", NULL
);
1026 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1029 static void test_reg_load_key(void)
1034 ret
= RegLoadKey(HKEY_LOCAL_MACHINE
, "Test", "saved_key");
1035 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1037 ret
= RegOpenKey(HKEY_LOCAL_MACHINE
, "Test", &hkHandle
);
1038 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1040 RegCloseKey(hkHandle
);
1043 static void test_reg_unload_key(void)
1047 ret
= RegUnLoadKey(HKEY_LOCAL_MACHINE
, "Test");
1048 ok(ret
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %d\n", ret
);
1050 DeleteFile("saved_key");
1051 DeleteFile("saved_key.LOG");
1054 static BOOL
set_privileges(LPCSTR privilege
, BOOL set
)
1056 TOKEN_PRIVILEGES tp
;
1060 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
1063 if(!LookupPrivilegeValue(NULL
, privilege
, &luid
))
1065 CloseHandle(hToken
);
1069 tp
.PrivilegeCount
= 1;
1070 tp
.Privileges
[0].Luid
= luid
;
1073 tp
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
1075 tp
.Privileges
[0].Attributes
= 0;
1077 AdjustTokenPrivileges(hToken
, FALSE
, &tp
, sizeof(TOKEN_PRIVILEGES
), NULL
, NULL
);
1078 if (GetLastError() != ERROR_SUCCESS
)
1080 CloseHandle(hToken
);
1084 CloseHandle(hToken
);
1088 /* tests that show that RegConnectRegistry and
1089 OpenSCManager accept computer names without the
1090 \\ prefix (what MSDN says). */
1091 static void test_regconnectregistry( void)
1093 CHAR compName
[MAX_COMPUTERNAME_LENGTH
+ 1];
1094 CHAR netwName
[MAX_COMPUTERNAME_LENGTH
+ 3]; /* 2 chars for double backslash */
1095 DWORD len
= sizeof(compName
) ;
1101 SetLastError(0xdeadbeef);
1102 ret
= GetComputerNameA(compName
, &len
);
1103 ok( ret
, "GetComputerName failed err = %d\n", GetLastError());
1106 lstrcpyA(netwName
, "\\\\");
1107 lstrcpynA(netwName
+2, compName
, MAX_COMPUTERNAME_LENGTH
+ 1);
1109 retl
= RegConnectRegistryA( compName
, HKEY_LOCAL_MACHINE
, &hkey
);
1111 retl
== ERROR_DLL_INIT_FAILED
||
1112 retl
== ERROR_BAD_NETPATH
, /* some win2k */
1113 "RegConnectRegistryA failed err = %d\n", retl
);
1114 if( !retl
) RegCloseKey( hkey
);
1116 retl
= RegConnectRegistryA( netwName
, HKEY_LOCAL_MACHINE
, &hkey
);
1118 retl
== ERROR_DLL_INIT_FAILED
||
1119 retl
== ERROR_BAD_NETPATH
, /* some win2k */
1120 "RegConnectRegistryA failed err = %d\n", retl
);
1121 if( !retl
) RegCloseKey( hkey
);
1123 SetLastError(0xdeadbeef);
1124 schnd
= OpenSCManagerA( compName
, NULL
, GENERIC_READ
);
1125 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1127 skip("OpenSCManagerA is not implemented\n");
1131 ok( schnd
!= NULL
, "OpenSCManagerA failed err = %d\n", GetLastError());
1132 CloseServiceHandle( schnd
);
1134 SetLastError(0xdeadbeef);
1135 schnd
= OpenSCManagerA( netwName
, NULL
, GENERIC_READ
);
1136 ok( schnd
!= NULL
, "OpenSCManagerA failed err = %d\n", GetLastError());
1137 CloseServiceHandle( schnd
);
1141 static void test_reg_query_value(void)
1148 static const WCHAR expected
[] = {'d','a','t','a',0};
1150 ret
= RegCreateKeyA(hkey_main
, "subkey", &subkey
);
1151 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1153 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data", 4);
1154 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1156 /* try an invalid hkey */
1157 SetLastError(0xdeadbeef);
1159 ret
= RegQueryValueA((HKEY
)0xcafebabe, "subkey", val
, &size
);
1160 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 98 returns BADKEY */
1161 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1162 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1164 /* try a NULL hkey */
1165 SetLastError(0xdeadbeef);
1167 ret
= RegQueryValueA(NULL
, "subkey", val
, &size
);
1168 ok(ret
== ERROR_INVALID_HANDLE
|| ret
== ERROR_BADKEY
, /* Windows 98 returns BADKEY */
1169 "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret
);
1170 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1172 /* try a NULL value */
1174 ret
= RegQueryValueA(hkey_main
, "subkey", NULL
, &size
);
1175 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1176 ok(size
== 5, "Expected 5, got %d\n", size
);
1178 /* try a NULL size */
1179 SetLastError(0xdeadbeef);
1181 ret
= RegQueryValueA(hkey_main
, "subkey", val
, NULL
);
1182 ok(ret
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
1183 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1184 ok(lstrlenA(val
) == 0, "Expected val to be untouched, got %s\n", val
);
1186 /* try a NULL value and size */
1187 ret
= RegQueryValueA(hkey_main
, "subkey", NULL
, NULL
);
1188 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1190 /* try a size too small */
1191 SetLastError(0xdeadbeef);
1194 ret
= RegQueryValueA(hkey_main
, "subkey", val
, &size
);
1195 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1196 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1197 ok(lstrlenA(val
) == 0, "Expected val to be untouched, got %s\n", val
);
1198 ok(size
== 5, "Expected 5, got %d\n", size
);
1200 /* successfully read the value using 'subkey' */
1202 ret
= RegQueryValueA(hkey_main
, "subkey", val
, &size
);
1203 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1204 ok(!lstrcmpA(val
, "data"), "Expected 'data', got '%s'\n", val
);
1205 ok(size
== 5, "Expected 5, got %d\n", size
);
1207 /* successfully read the value using the subkey key */
1209 ret
= RegQueryValueA(subkey
, NULL
, val
, &size
);
1210 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1211 ok(!lstrcmpA(val
, "data"), "Expected 'data', got '%s'\n", val
);
1212 ok(size
== 5, "Expected 5, got %d\n", size
);
1214 /* unicode - try size too small */
1215 SetLastError(0xdeadbeef);
1218 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1219 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1221 skip("RegQueryValueW is not implemented\n");
1224 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1225 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1226 ok(lstrlenW(valW
) == 0, "Expected valW to be untouched\n");
1227 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1229 /* unicode - try size in WCHARS */
1230 SetLastError(0xdeadbeef);
1231 size
= sizeof(valW
) / sizeof(WCHAR
);
1232 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1233 ok(ret
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", ret
);
1234 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
1235 ok(lstrlenW(valW
) == 0, "Expected valW to be untouched\n");
1236 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1238 /* unicode - successfully read the value */
1239 size
= sizeof(valW
);
1240 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1241 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1242 ok(!lstrcmpW(valW
, expected
), "Got wrong value\n");
1243 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1245 /* unicode - set the value without a NULL terminator */
1246 ret
= RegSetValueW(subkey
, NULL
, REG_SZ
, expected
, sizeof(expected
)-sizeof(WCHAR
));
1247 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1249 /* unicode - read the unterminated value, value is terminated for us */
1250 memset(valW
, 'a', sizeof(valW
));
1251 size
= sizeof(valW
);
1252 ret
= RegQueryValueW(subkey
, NULL
, valW
, &size
);
1253 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1254 ok(!lstrcmpW(valW
, expected
), "Got wrong value\n");
1255 ok(size
== sizeof(expected
), "Got wrong size: %d\n", size
);
1258 RegDeleteKeyA(subkey
, "");
1259 RegCloseKey(subkey
);
1262 static void test_reg_delete_tree(void)
1264 CHAR buffer
[MAX_PATH
];
1265 HKEY subkey
, subkey2
;
1268 if(!pRegDeleteTreeA
) {
1269 skip("Skipping RegDeleteTreeA tests, function not present\n");
1273 ret
= RegCreateKeyA(hkey_main
, "subkey", &subkey
);
1274 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1275 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
1276 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1277 ret
= RegSetValueA(subkey
, NULL
, REG_SZ
, "data", 4);
1278 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1279 ret
= RegSetValueA(subkey2
, NULL
, REG_SZ
, "data2", 5);
1280 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1281 ret
= RegCloseKey(subkey2
);
1282 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1284 ret
= pRegDeleteTreeA(subkey
, "subkey2");
1285 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1286 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
1287 "subkey2 was not deleted\n");
1289 ok(!RegQueryValueA(subkey
, NULL
, buffer
, &size
),
1290 "Default value of subkey not longer present\n");
1292 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
1293 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1294 ret
= RegCloseKey(subkey2
);
1295 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1296 ret
= pRegDeleteTreeA(hkey_main
, "subkey\\subkey2");
1297 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1298 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
1299 "subkey2 was not deleted\n");
1300 ok(!RegQueryValueA(subkey
, NULL
, buffer
, &size
),
1301 "Default value of subkey not longer present\n");
1303 ret
= RegCreateKeyA(subkey
, "subkey2", &subkey2
);
1304 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1305 ret
= RegCloseKey(subkey2
);
1306 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1307 ret
= RegCreateKeyA(subkey
, "subkey3", &subkey2
);
1308 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1309 ret
= RegCloseKey(subkey2
);
1310 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1311 ret
= RegSetValueA(subkey
, "value", REG_SZ
, "data2", 5);
1312 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1313 ret
= pRegDeleteTreeA(subkey
, NULL
);
1314 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
1315 ok(!RegOpenKeyA(hkey_main
, "subkey", &subkey
),
1316 "subkey was deleted\n");
1317 ok(RegOpenKeyA(subkey
, "subkey2", &subkey2
),
1318 "subkey2 was not deleted\n");
1319 ok(RegOpenKeyA(subkey
, "subkey3", &subkey2
),
1320 "subkey3 was not deleted\n");
1322 ret
= RegQueryValueA(subkey
, NULL
, buffer
, &size
);
1323 ok(ret
== ERROR_SUCCESS
,
1324 "Default value of subkey is not present\n");
1325 ok(!lstrlenA(buffer
),
1326 "Expected length 0 got length %u(%s)\n", lstrlenA(buffer
), buffer
);
1328 ok(RegQueryValueA(subkey
, "value", buffer
, &size
),
1329 "Value is still present\n");
1331 ret
= pRegDeleteTreeA(hkey_main
, "not-here");
1332 ok(ret
== ERROR_FILE_NOT_FOUND
,
1333 "Expected ERROR_FILE_NOT_FOUND, got %d\n", ret
);
1336 START_TEST(registry
)
1338 /* Load pointers for functions that are not available in all Windows versions */
1343 create_test_entries();
1345 test_query_value_ex();
1347 test_reg_open_key();
1348 test_reg_create_key();
1349 test_reg_close_key();
1350 test_reg_delete_key();
1351 test_reg_query_value();
1353 /* SaveKey/LoadKey require the SE_BACKUP_NAME privilege to be set */
1354 if (set_privileges(SE_BACKUP_NAME
, TRUE
) &&
1355 set_privileges(SE_RESTORE_NAME
, TRUE
))
1357 test_reg_save_key();
1358 test_reg_load_key();
1359 test_reg_unload_key();
1361 set_privileges(SE_BACKUP_NAME
, FALSE
);
1362 set_privileges(SE_RESTORE_NAME
, FALSE
);
1365 test_reg_delete_tree();
1368 delete_key( hkey_main
);
1370 test_regconnectregistry();