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