Added an unknown VxD error code.
[wine] / programs / regtest / regtest.c
1 /*
2  * Registry testing program
3  *
4  * Copyright 1998 Matthew Becker
5  *
6  * The return codes were generated in an NT40 environment, using lcc-win32
7  *
8  * NOTES
9  *    When compiling under lcc-win32, I get three (3) warning, but they all
10  *    seem to be issues with lcc.
11  *
12  *    If creating a new testing sequence, please try to clean up any
13  *    registry changes that are made.
14  */
15
16 #include <stdio.h>
17 #include <malloc.h>
18 #include <windows.h>
19 #include <winreg.h>
20 #include <winerror.h>
21 #include <winnt.h>
22
23 #ifndef __GNUC__
24 #define __FUNCTION__ "<function>"
25 #endif
26
27 /* True this when security is implemented */
28 #define CHECK_SAM FALSE
29
30 #define xERROR(s,d) fprintf(stderr, "%s:#%d(Status=%ld)\n", __FUNCTION__,s,d)
31
32 /*
33  * NOTES: These individual routines are listed in alphabetical order.
34  *
35  * They are meant to test error conditions.  Success conditions are
36  * tested in the sequences found at the end.
37  */
38
39 /******************************************************************************
40  * TestCloseKey
41  */
42 void TestCloseKey()
43 {
44     long lSts;
45
46     lSts = RegCloseKey((HKEY)2);
47     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
48
49     lSts = RegCloseKey(HKEY_LOCAL_MACHINE);
50     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
51
52     /* Check twice just for kicks */
53     lSts = RegCloseKey(HKEY_LOCAL_MACHINE);
54     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
55 }
56
57 /******************************************************************************
58  * TestConnectRegistry
59  */
60 void TestConnectRegistry()
61 {
62     long lSts;
63     HKEY hkey;
64
65     lSts = RegConnectRegistry("",(HKEY)2,&hkey);
66     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
67
68     lSts = RegConnectRegistry("",HKEY_LOCAL_MACHINE,&hkey);
69     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
70
71 #if TOO_SLOW
72     lSts = RegConnectRegistry("\\\\regtest",HKEY_LOCAL_MACHINE,&hkey);
73     if (lSts != ERROR_BAD_NETPATH) xERROR(3,lSts);
74 #endif
75 }
76
77 /******************************************************************************
78  * TestCreateKey
79  */
80 void TestCreateKey()
81 {
82     long lSts;
83     HKEY hkey;
84
85     lSts = RegCreateKey((HKEY)2,"",&hkey);
86     if (lSts != ERROR_BADKEY) xERROR(1,lSts);
87
88     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"",&hkey);
89     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
90     RegCloseKey(hkey);
91
92     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"\\asdf",&hkey);
93     if (lSts != ERROR_BAD_PATHNAME) xERROR(3,lSts);
94
95 #if 0
96     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"asdf\\",&hkey);
97     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
98 #endif
99
100     lSts = RegCreateKey(HKEY_LOCAL_MACHINE,"\\asdf\\",&hkey);
101     if (lSts != ERROR_BAD_PATHNAME) xERROR(5,lSts);
102 }
103
104 /******************************************************************************
105  * TestCreateKeyEx
106  */
107 void TestCreateKeyEx()
108 {
109     long lSts;
110     HKEY hkey;
111     DWORD dwDisp;
112
113     lSts = RegCreateKeyEx((HKEY)2,"",0,"",0,0,NULL,&hkey,&dwDisp);
114     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
115
116     lSts = RegCreateKeyEx(HKEY_LOCAL_MACHINE,"regtest",0,"",0,0,NULL,&hkey,
117                           &dwDisp);
118     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
119
120     lSts = RegCreateKeyEx(HKEY_LOCAL_MACHINE,"regtest",0,"asdf",0,
121                           KEY_ALL_ACCESS,NULL,&hkey,&dwDisp);
122     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
123
124     lSts = RegCreateKeyEx(HKEY_LOCAL_MACHINE,"regtest",0,"",0,
125                           KEY_ALL_ACCESS,NULL,&hkey,&dwDisp);
126     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
127
128 }
129
130 /******************************************************************************
131  * TestCreateKeyEx
132  */
133 void TestCreateKeyEx1()
134 {
135     long lSts;
136     HKEY hkey,hkeyP;
137     DWORD dwDisp;
138     char keyname[]="regtest1";
139
140     lSts = RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE",0,1,&hkeyP);
141     if (lSts != ERROR_SUCCESS) 
142       {
143         xERROR(1,lSts);
144         return;
145       }
146     lSts = RegCreateKeyEx(hkeyP,keyname,0,0,0,0xf003f,0,&hkey,&dwDisp);
147     if (lSts != ERROR_SUCCESS) 
148     {
149       xERROR(2,lSts);
150       RegCloseKey(hkeyP);
151       return;
152     }
153     lSts = RegDeleteKey( hkeyP,keyname);
154     if (lSts != ERROR_SUCCESS)  xERROR(3,lSts);
155     RegCloseKey(hkeyP);
156 }
157
158 /******************************************************************************
159  * TestDeleteKey
160  */
161 void TestDeleteKey()
162 {
163     long lSts;
164
165     lSts = RegDeleteKey((HKEY)2, "asdf");
166     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
167
168     lSts = RegDeleteKey(HKEY_CURRENT_USER, "asdf");
169     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(2,lSts);
170
171 #if CHECK_SAM
172     lSts = RegDeleteKey(HKEY_CURRENT_USER, "");
173     if (lSts != ERROR_ACCESS_DENIED) xERROR(3,lSts);
174 #endif
175 }
176
177 /******************************************************************************
178  * TestDeleteValue
179  */
180 void TestDeleteValue()
181 {
182     long lSts;
183
184     lSts = RegDeleteValue((HKEY)2, "asdf");
185     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
186
187     lSts = RegDeleteValue(HKEY_CURRENT_USER, "");
188     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(2,lSts);
189
190     lSts = RegDeleteValue(HKEY_CURRENT_USER, "asdf");
191     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
192
193     lSts = RegDeleteValue(HKEY_CURRENT_USER, "\\asdf");
194     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(4,lSts);
195 }
196
197 /******************************************************************************
198  * TestEnumKey
199  */
200 void TestEnumKey()
201 {
202     long lSts;
203     char *sVal;
204     long lVal;
205
206     lVal = 1;
207     sVal = (char *)malloc(lVal * sizeof(char));
208
209     lSts = RegEnumKey((HKEY)2,3,sVal,lVal);
210     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
211
212     lSts = RegEnumKey(HKEY_CURRENT_USER,-1,sVal,lVal);
213     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(2,lSts);
214
215     lSts = RegEnumKey(HKEY_CURRENT_USER,0,sVal,lVal);
216     if (lSts != ERROR_MORE_DATA) xERROR(3,lSts);
217 }
218
219 /******************************************************************************
220  * TestEnumKeyEx
221  */
222 void TestEnumKeyEx()
223 {
224     long lSts;
225     char *sVal;
226     char *sClass;
227     unsigned long lLen1;
228     unsigned long lLen2;
229     FILETIME ft;
230
231     lLen1 = 1;
232     sVal = (char *)malloc(lLen1 * sizeof(char));
233     lLen2 = 1;
234     sClass = (char *)malloc(lLen2 * sizeof(char));
235
236     lSts = RegEnumKeyEx((HKEY)2,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
237     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
238
239     lSts = RegEnumKeyEx(HKEY_LOCAL_MACHINE,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
240     if (lSts != ERROR_MORE_DATA) xERROR(2,lSts);
241
242     lSts = RegEnumKeyEx(HKEY_LOCAL_MACHINE,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
243     if (lSts != ERROR_MORE_DATA) xERROR(3,lSts);
244 }
245
246 /******************************************************************************
247  * TestEnumValue
248  */
249 void TestEnumValue()
250 {
251     long lSts;
252     char *sVal;
253     unsigned long lVal;
254     unsigned long lType;
255     unsigned long lLen1;
256     char *bVal;
257
258     lVal = 1;
259     sVal = (char *)malloc(lVal * sizeof(char));
260     lLen1 = 1;
261     bVal = (char *)malloc(lLen1 * sizeof(char));
262
263     lSts = RegEnumValue((HKEY)2,-1,sVal,&lVal,0,&lType,NULL,&lLen1);
264     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
265
266     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,-1,sVal,&lVal,0,&lType,NULL,&lLen1);
267     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(2,lSts);
268
269     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,0,sVal,&lVal,0,&lType,NULL,&lLen1);
270     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
271
272     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,0,sVal,&lVal,0,NULL,NULL,&lLen1);
273     if (lSts != ERROR_SUCCESS) xERROR(4,lSts);
274
275     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,1,sVal,&lVal,0,&lType,bVal,&lLen1);
276     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(5,lSts);
277 }
278
279 /******************************************************************************
280  * TestFlushKey
281  */
282 void TestFlushKey()
283 {
284     long lSts;
285
286     lSts = RegFlushKey((HKEY)2);
287     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
288
289     lSts = RegFlushKey(HKEY_LOCAL_MACHINE);
290     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
291 }
292
293 /******************************************************************************
294  * TestGetKeySecurity
295  */
296 void TestGetKeySecurity()
297 {
298     long lSts;
299     SECURITY_INFORMATION si;
300     SECURITY_DESCRIPTOR sd;
301     unsigned long lLen;
302
303     lLen = sizeof(sd);
304     si = 0;
305     lSts = RegGetKeySecurity((HKEY)2,si,&sd,&lLen);
306     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
307
308     lSts = RegGetKeySecurity(HKEY_LOCAL_MACHINE,si,&sd,&lLen);
309     if (lSts != ERROR_INSUFFICIENT_BUFFER) xERROR(2,lSts);
310
311     si = GROUP_SECURITY_INFORMATION;
312     lSts = RegGetKeySecurity(HKEY_LOCAL_MACHINE,si,&sd,&lLen);
313     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
314 }
315
316 /******************************************************************************
317  * TestLoadKey
318  */
319 void TestLoadKey()
320 {
321     long lSts;
322
323     lSts = RegLoadKey((HKEY)2,"","");
324     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
325
326     lSts = RegLoadKey(HKEY_CURRENT_USER,"","");
327     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
328
329     lSts = RegLoadKey(HKEY_CURRENT_USER,"regtest","");
330     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
331
332     lSts = RegLoadKey(HKEY_CURRENT_USER,"\\regtest","");
333     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
334
335 #if CHECK_SAM
336     lSts = RegLoadKey(HKEY_CURRENT_USER,"regtest","regtest.dat");
337     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(5,lSts);
338
339     lSts = RegLoadKey(HKEY_CURRENT_USER,"\\regtest","regtest.dat");
340     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(6,lSts);
341 #endif
342 }
343
344 /******************************************************************************
345  * TestNotifyChangeKeyValue
346  */
347 void TestNotifyChangeKeyValue()
348 {
349     long lSts;
350     HANDLE hEvent;
351
352     hEvent = (HANDLE)0;
353
354     lSts = RegNotifyChangeKeyValue((HKEY)2, TRUE, REG_NOTIFY_CHANGE_NAME, 0, 0);
355     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
356
357     lSts = RegNotifyChangeKeyValue(HKEY_CURRENT_USER, TRUE, REG_NOTIFY_CHANGE_NAME, 0, 1);
358     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
359
360     hEvent = (HANDLE)HKEY_CURRENT_USER;
361     lSts = RegNotifyChangeKeyValue(HKEY_CURRENT_USER, TRUE, REG_NOTIFY_CHANGE_NAME, hEvent, 1);
362     if (lSts != ERROR_INVALID_HANDLE) xERROR(3,lSts);
363 }
364
365 /******************************************************************************
366  * TestOpenKey
367  */
368 void TestOpenKey()
369 {
370     long lSts;
371     HKEY hkey;
372
373     lSts = RegOpenKey((HKEY)72, "",&hkey);
374     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
375     RegCloseKey(hkey);
376
377     lSts = RegOpenKey((HKEY)2, "regtest",&hkey);
378     if (lSts != ERROR_INVALID_HANDLE) xERROR(2,lSts);
379
380     lSts = RegOpenKey(HKEY_CURRENT_USER, "regtest",&hkey);
381     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
382
383     lSts = RegOpenKey(HKEY_CURRENT_USER, "\\regtest",&hkey);
384     if (lSts != ERROR_BAD_PATHNAME) xERROR(4,lSts);
385 }
386
387 /******************************************************************************
388  * TestOpenKeyEx
389  */
390 void TestOpenKeyEx()
391 {
392     long lSts;
393     HKEY hkey;
394
395     lSts = RegOpenKeyEx((HKEY)2,"",0,KEY_ALL_ACCESS,&hkey);
396     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
397
398     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"\\regtest",0,KEY_ALL_ACCESS,&hkey);
399     if (lSts != ERROR_BAD_PATHNAME) xERROR(2,lSts);
400
401     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"regtest",0,0,&hkey);
402     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
403
404     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"regtest\\",0,0,&hkey);
405     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(4,lSts);
406 }
407
408 /******************************************************************************
409  * TestQueryInfoKey
410  */
411 void TestQueryInfoKey()
412 {
413     long lSts;
414     char *sClass;
415     unsigned long lClass;
416     unsigned long lSubKeys;
417     unsigned long lMaxSubLen;
418     unsigned long lMaxClassLen;
419     unsigned long lValues;
420     unsigned long lMaxValNameLen;
421     unsigned long lMaxValLen;
422     unsigned long lSecDescLen;
423     FILETIME ft;
424
425     lClass = 1;
426     sClass = (char *)malloc(lClass * sizeof(char));
427
428     lSts = RegQueryInfoKey((HKEY)2,sClass,&lClass,0,&lSubKeys,&lMaxSubLen,
429                            &lMaxClassLen,&lValues,&lMaxValNameLen,&lMaxValLen,
430                            &lSecDescLen, &ft);
431     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
432
433     lSts = RegQueryInfoKey(HKEY_CURRENT_USER,sClass,&lClass,0,&lSubKeys,
434                            &lMaxSubLen,&lMaxClassLen,&lValues,&lMaxValNameLen,
435                            &lMaxValLen,&lSecDescLen, &ft);
436     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
437 }
438
439 /******************************************************************************
440  * TestQueryValue
441  */
442 void TestQueryValue()
443 {
444     long lSts;
445     long lLen;
446     char *sVal;
447
448     sVal = (char *)malloc(80 * sizeof(char));
449     lLen = strlen(sVal);
450
451     lSts = RegQueryValue((HKEY)2,"",NULL,&lLen);
452     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
453
454     lSts = RegQueryValue(HKEY_CURRENT_USER,"",NULL,&lLen);
455     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
456
457     lSts = RegQueryValue(HKEY_CURRENT_USER,"\\regtest",NULL,&lLen);
458     if (lSts != ERROR_BAD_PATHNAME) xERROR(3,lSts);
459
460     lSts = RegQueryValue(HKEY_CURRENT_USER,"",sVal,&lLen);
461     if (lSts != ERROR_SUCCESS) xERROR(4,lSts);
462 }
463
464 /******************************************************************************
465  * TestQueryValueEx
466  */
467 void TestQueryValueEx()
468 {
469     char *sVal;
470     long lSts;
471     unsigned long lType;
472     unsigned long lLen;
473
474     lLen = 80;
475     sVal = (char *)malloc(lLen * sizeof(char));
476
477     lSts = RegQueryValueEx((HKEY)2,"",0,&lType,sVal,&lLen);
478     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
479
480     lSts = RegQueryValueEx(HKEY_CURRENT_USER,"",(LPDWORD)1,&lType,sVal,&lLen);
481     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
482
483     lSts = RegQueryValueEx(HKEY_LOCAL_MACHINE,"",0,&lType,sVal,&lLen);
484     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
485 }
486
487 /******************************************************************************
488  * TestReplaceKey
489  */
490 void TestReplaceKey()
491 {
492     long lSts;
493
494     lSts = RegReplaceKey((HKEY)2,"","","");
495     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
496
497 #if CHECK_SAM
498     lSts = RegReplaceKey(HKEY_LOCAL_MACHINE,"","","");
499     if (lSts != ERROR_ACCESS_DENIED) xERROR(2,lSts);
500
501     lSts = RegReplaceKey(HKEY_LOCAL_MACHINE,"Software","","");
502     if (lSts != ERROR_ACCESS_DENIED) xERROR(3,lSts);
503 #endif
504 }
505
506 /******************************************************************************
507  * TestRestoreKey
508  */
509 void TestRestoreKey()
510 {
511     long lSts;
512
513     lSts = RegRestoreKey((HKEY)2,"",0);
514     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
515
516     lSts = RegRestoreKey(HKEY_LOCAL_MACHINE,"",0);
517     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
518
519     lSts = RegRestoreKey(HKEY_LOCAL_MACHINE,"a.a",0);
520     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
521 }
522
523 /******************************************************************************
524  * TestSaveKey
525  */
526 void TestSaveKey()
527 {
528     long lSts;
529
530     lSts = RegSaveKey((HKEY)2,"",NULL);
531     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
532
533     lSts = RegSaveKey(HKEY_LOCAL_MACHINE,"",NULL);
534     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
535
536 #if CHECK_SAM
537     lSts = RegSaveKey(HKEY_LOCAL_MACHINE,"a.a",NULL);
538     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(3,lSts);
539 #endif
540 }
541
542 /******************************************************************************
543  * TestSetKeySecurity
544  */
545 void TestSetKeySecurity()
546 {
547     long lSts;
548     SECURITY_DESCRIPTOR sd;
549
550     lSts = RegSetKeySecurity((HKEY)2,0,NULL);
551     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
552
553     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,0,NULL);
554     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
555
556     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,OWNER_SECURITY_INFORMATION,NULL);
557     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
558
559     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,OWNER_SECURITY_INFORMATION,&sd);
560     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
561 }
562
563 /******************************************************************************
564  * TestSetValue
565  */
566 void TestSetValue()
567 {
568 #if MAKE_NT_CRASH
569     long lSts;
570 #endif
571
572 #if MAKE_NT_CRASH
573     lSts = RegSetValue((HKEY)2,"",0,NULL,0);
574     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
575 #endif
576
577 #if MAKE_NT_CRASH
578     lSts = RegSetValue((HKEY)2,"regtest",0,NULL,0);
579     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
580 #endif
581
582 #if MAKE_NT_CRASH
583     lSts = RegSetValue((HKEY)2,"regtest",REG_SZ,NULL,0);
584     if (lSts != ERROR_INVALID_HANDLE) xERROR(3,lSts);
585 #endif
586
587 #if MAKE_NT_CRASH
588     lSts = RegSetValue(HKEY_LOCAL_MACHINE,"regtest",REG_SZ,NULL,0);
589     if (lSts != ERROR_INVALID_HANDLE) xERROR(4,lSts);
590 #endif
591 }
592
593 /******************************************************************************
594  * TestSetValueEx
595  */
596 void TestSetValueEx()
597 {
598     long lSts;
599
600     lSts = RegSetValueEx((HKEY)2,"",0,0,NULL,0);
601     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
602
603     lSts = RegSetValueEx(HKEY_LOCAL_MACHINE,"",0,0,NULL,0);
604     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
605 }
606
607 /******************************************************************************
608  * TestUnLoadKey
609  */
610 void TestUnLoadKey()
611 {
612 #if CHECK_SAM
613     long lSts;
614 #endif
615
616 #if CHECK_SAM
617     lSts = RegUnLoadKey((HKEY)2,"");
618     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(1,lSts);
619
620     lSts = RegUnLoadKey(HKEY_LOCAL_MACHINE,"");
621     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(2,lSts);
622
623     lSts = RegUnLoadKey(HKEY_LOCAL_MACHINE,"\\regtest");
624     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(3,lSts);
625 #endif
626 }
627
628 /******************************************************************************
629  * TestSequence1
630  */
631 void TestSequence1()
632 {
633     HKEY hkey;
634     long lSts;
635
636     lSts = RegCreateKey(HKEY_CURRENT_USER,"regtest",&hkey);
637     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
638
639 /*    fprintf(stderr, " hkey=0x%x\n", hkey); */
640
641     lSts = RegDeleteKey(HKEY_CURRENT_USER, "regtest");
642     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
643     lSts = RegCloseKey(hkey);
644     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
645 }
646
647
648 int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
649 {
650
651     /* These can be in any order */
652     TestCloseKey();
653     TestConnectRegistry();
654     TestCreateKey();
655     TestCreateKeyEx();
656     TestDeleteKey();
657     TestDeleteValue();
658     TestEnumKey();
659     TestEnumKeyEx();
660     TestEnumValue();
661     TestFlushKey();
662     TestGetKeySecurity();
663     TestLoadKey();
664     TestNotifyChangeKeyValue();
665     TestOpenKey();
666     TestOpenKeyEx();
667     TestQueryInfoKey();
668     TestQueryValue();
669     TestQueryValueEx();
670     TestReplaceKey();
671     TestRestoreKey();
672     TestSaveKey();
673     TestSetKeySecurity();
674     TestSetValue();
675     TestSetValueEx();
676     TestUnLoadKey();
677     TestCreateKeyEx1();
678
679     /* Now we have some sequence testing */
680     TestSequence1();
681
682     return 0;
683 }
684