Handle generic column width changes.
[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
233 /******************************************************************************
234  * TestEnumKeyEx
235  */
236 void TestEnumKeyEx()
237 {
238     long lSts;
239     char *sVal;
240     char *sClass;
241     unsigned long lLen1;
242     unsigned long lLen2;
243     FILETIME ft;
244
245     lLen1 = 1;
246     sVal = (char *)malloc(lLen1 * sizeof(char));
247     lLen2 = 1;
248     sClass = (char *)malloc(lLen2 * sizeof(char));
249
250     lSts = RegEnumKeyEx((HKEY)2,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
251     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
252
253     lSts = RegEnumKeyEx(HKEY_LOCAL_MACHINE,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
254     if (lSts != ERROR_MORE_DATA) xERROR(2,lSts);
255
256     lSts = RegEnumKeyEx(HKEY_LOCAL_MACHINE,0,sVal,&lLen1,0,sClass,&lLen2,&ft);
257     if (lSts != ERROR_MORE_DATA) xERROR(3,lSts);
258 }
259
260 /******************************************************************************
261  * TestEnumValue
262  */
263 void TestEnumValue()
264 {
265     long lSts;
266     char *sVal;
267     unsigned long lVal;
268     unsigned long lType;
269     unsigned long lLen1;
270     char *bVal;
271
272     lVal = 1;
273     sVal = (char *)malloc(lVal * sizeof(char));
274     lLen1 = 1;
275     bVal = (char *)malloc(lLen1 * sizeof(char));
276
277     lSts = RegEnumValue((HKEY)2,-1,sVal,&lVal,0,&lType,NULL,&lLen1);
278     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
279
280     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,-1,sVal,&lVal,0,&lType,NULL,&lLen1);
281     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(2,lSts);
282
283     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,0,sVal,&lVal,0,&lType,NULL,&lLen1);
284     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
285
286     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,0,sVal,&lVal,0,NULL,NULL,&lLen1);
287     if (lSts != ERROR_SUCCESS) xERROR(4,lSts);
288
289     lSts = RegEnumValue(HKEY_LOCAL_MACHINE,1,sVal,&lVal,0,&lType,bVal,&lLen1);
290     if (lSts != ERROR_NO_MORE_ITEMS) xERROR(5,lSts);
291 }
292
293 /******************************************************************************
294  * TestFlushKey
295  */
296 void TestFlushKey()
297 {
298     long lSts;
299
300     lSts = RegFlushKey((HKEY)2);
301     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
302
303     lSts = RegFlushKey(HKEY_LOCAL_MACHINE);
304     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
305 }
306
307 /******************************************************************************
308  * TestGetKeySecurity
309  */
310 void TestGetKeySecurity()
311 {
312     long lSts;
313     SECURITY_INFORMATION si;
314     SECURITY_DESCRIPTOR sd;
315     unsigned long lLen;
316
317     lLen = sizeof(sd);
318     si = 0;
319     lSts = RegGetKeySecurity((HKEY)2,si,&sd,&lLen);
320     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
321
322     lSts = RegGetKeySecurity(HKEY_LOCAL_MACHINE,si,&sd,&lLen);
323     if (lSts != ERROR_INSUFFICIENT_BUFFER) xERROR(2,lSts);
324
325     si = GROUP_SECURITY_INFORMATION;
326     lSts = RegGetKeySecurity(HKEY_LOCAL_MACHINE,si,&sd,&lLen);
327     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
328 }
329
330 /******************************************************************************
331  * TestLoadKey
332  */
333 void TestLoadKey()
334 {
335     long lSts;
336
337     lSts = RegLoadKey((HKEY)2,"","");
338     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
339
340     lSts = RegLoadKey(HKEY_CURRENT_USER,"","");
341     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
342
343     lSts = RegLoadKey(HKEY_CURRENT_USER,"regtest","");
344     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
345
346     lSts = RegLoadKey(HKEY_CURRENT_USER,"\\regtest","");
347     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
348
349 #if CHECK_SAM
350     lSts = RegLoadKey(HKEY_CURRENT_USER,"regtest","regtest.dat");
351     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(5,lSts);
352
353     lSts = RegLoadKey(HKEY_CURRENT_USER,"\\regtest","regtest.dat");
354     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(6,lSts);
355 #endif
356 }
357
358 /******************************************************************************
359  * TestNotifyChangeKeyValue
360  */
361 void TestNotifyChangeKeyValue()
362 {
363     long lSts;
364     HANDLE hEvent;
365
366     hEvent = (HANDLE)0;
367
368     lSts = RegNotifyChangeKeyValue((HKEY)2, TRUE, REG_NOTIFY_CHANGE_NAME, 0, 0);
369     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
370
371     lSts = RegNotifyChangeKeyValue(HKEY_CURRENT_USER, TRUE, REG_NOTIFY_CHANGE_NAME, 0, 1);
372     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
373
374     hEvent = (HANDLE)HKEY_CURRENT_USER;
375     lSts = RegNotifyChangeKeyValue(HKEY_CURRENT_USER, TRUE, REG_NOTIFY_CHANGE_NAME, hEvent, 1);
376     if (lSts != ERROR_INVALID_HANDLE) xERROR(3,lSts);
377 }
378
379 /******************************************************************************
380  * TestOpenKey
381  */
382 void TestOpenKey()
383 {
384     long lSts;
385     HKEY hkey;
386
387     lSts = RegOpenKey((HKEY)72, "",&hkey);
388     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
389     RegCloseKey(hkey);
390
391     lSts = RegOpenKey((HKEY)2, "regtest",&hkey);
392     if (lSts != ERROR_INVALID_HANDLE) xERROR(2,lSts);
393
394     lSts = RegOpenKey(HKEY_CURRENT_USER, "regtest",&hkey);
395     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
396
397     lSts = RegOpenKey(HKEY_CURRENT_USER, "\\regtest",&hkey);
398     if (lSts != ERROR_BAD_PATHNAME) xERROR(4,lSts);
399 }
400
401 /******************************************************************************
402  * TestOpenKeyEx
403  */
404 void TestOpenKeyEx()
405 {
406     long lSts;
407     HKEY hkey;
408
409     lSts = RegOpenKeyEx((HKEY)2,"",0,KEY_ALL_ACCESS,&hkey);
410     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
411
412     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"\\regtest",0,KEY_ALL_ACCESS,&hkey);
413     if (lSts != ERROR_BAD_PATHNAME) xERROR(2,lSts);
414
415     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"regtest",0,0,&hkey);
416     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
417
418     lSts = RegOpenKeyEx(HKEY_CURRENT_USER,"regtest\\",0,0,&hkey);
419     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(4,lSts);
420 }
421
422 /******************************************************************************
423  * TestQueryInfoKey
424  */
425 void TestQueryInfoKey()
426 {
427     long lSts;
428     char *sClass;
429     unsigned long lClass;
430     unsigned long lSubKeys;
431     unsigned long lMaxSubLen;
432     unsigned long lMaxClassLen;
433     unsigned long lValues;
434     unsigned long lMaxValNameLen;
435     unsigned long lMaxValLen;
436     unsigned long lSecDescLen;
437     FILETIME ft;
438
439     lClass = 1;
440     sClass = (char *)malloc(lClass * sizeof(char));
441
442     lSts = RegQueryInfoKey((HKEY)2,sClass,&lClass,0,&lSubKeys,&lMaxSubLen,
443                            &lMaxClassLen,&lValues,&lMaxValNameLen,&lMaxValLen,
444                            &lSecDescLen, &ft);
445     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
446
447     lSts = RegQueryInfoKey(HKEY_CURRENT_USER,sClass,&lClass,0,&lSubKeys,
448                            &lMaxSubLen,&lMaxClassLen,&lValues,&lMaxValNameLen,
449                            &lMaxValLen,&lSecDescLen, &ft);
450     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
451 }
452
453 /******************************************************************************
454  * TestQueryValue
455  */
456 void TestQueryValue()
457 {
458     long lSts;
459     long lLen;
460     char *sVal;
461
462     sVal = (char *)malloc(80 * sizeof(char));
463     lLen = strlen(sVal);
464
465     lSts = RegQueryValue((HKEY)2,"",NULL,&lLen);
466     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
467
468     lSts = RegQueryValue(HKEY_CURRENT_USER,"",NULL,&lLen);
469     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
470
471     lSts = RegQueryValue(HKEY_CURRENT_USER,"\\regtest",NULL,&lLen);
472     if (lSts != ERROR_BAD_PATHNAME) xERROR(3,lSts);
473
474     lSts = RegQueryValue(HKEY_CURRENT_USER,"",sVal,&lLen);
475     if (lSts != ERROR_SUCCESS) xERROR(4,lSts);
476 }
477
478 /******************************************************************************
479  * TestQueryValueEx
480  */
481 void TestQueryValueEx()
482 {
483     char *sVal;
484     long lSts;
485     unsigned long lType;
486     unsigned long lLen;
487
488     lLen = 80;
489     sVal = (char *)malloc(lLen * sizeof(char));
490
491     lSts = RegQueryValueEx((HKEY)2,"",0,&lType,sVal,&lLen);
492     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
493
494     lSts = RegQueryValueEx(HKEY_CURRENT_USER,"",(LPDWORD)1,&lType,sVal,&lLen);
495     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
496
497     lSts = RegQueryValueEx(HKEY_LOCAL_MACHINE,"",0,&lType,sVal,&lLen);
498     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
499 }
500
501 /******************************************************************************
502  * TestReplaceKey
503  */
504 void TestReplaceKey()
505 {
506     long lSts;
507
508     lSts = RegReplaceKey((HKEY)2,"","","");
509     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
510
511 #if CHECK_SAM
512     lSts = RegReplaceKey(HKEY_LOCAL_MACHINE,"","","");
513     if (lSts != ERROR_ACCESS_DENIED) xERROR(2,lSts);
514
515     lSts = RegReplaceKey(HKEY_LOCAL_MACHINE,"Software","","");
516     if (lSts != ERROR_ACCESS_DENIED) xERROR(3,lSts);
517 #endif
518 }
519
520 /******************************************************************************
521  * TestRestoreKey
522  */
523 void TestRestoreKey()
524 {
525     long lSts;
526
527     lSts = RegRestoreKey((HKEY)2,"",0);
528     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
529
530     lSts = RegRestoreKey(HKEY_LOCAL_MACHINE,"",0);
531     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
532
533     lSts = RegRestoreKey(HKEY_LOCAL_MACHINE,"a.a",0);
534     if (lSts != ERROR_FILE_NOT_FOUND) xERROR(3,lSts);
535 }
536
537 /******************************************************************************
538  * TestSaveKey
539  */
540 void TestSaveKey()
541 {
542     long lSts;
543
544     lSts = RegSaveKey((HKEY)2,"",NULL);
545     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
546
547     lSts = RegSaveKey(HKEY_LOCAL_MACHINE,"",NULL);
548     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
549
550 #if CHECK_SAM
551     lSts = RegSaveKey(HKEY_LOCAL_MACHINE,"a.a",NULL);
552     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(3,lSts);
553 #endif
554 }
555
556 /******************************************************************************
557  * TestSetKeySecurity
558  */
559 void TestSetKeySecurity()
560 {
561     long lSts;
562     SECURITY_DESCRIPTOR sd;
563
564     lSts = RegSetKeySecurity((HKEY)2,0,NULL);
565     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
566
567     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,0,NULL);
568     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
569
570     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,OWNER_SECURITY_INFORMATION,NULL);
571     if (lSts != ERROR_INVALID_PARAMETER) xERROR(3,lSts);
572
573     lSts = RegSetKeySecurity(HKEY_LOCAL_MACHINE,OWNER_SECURITY_INFORMATION,&sd);
574     if (lSts != ERROR_INVALID_PARAMETER) xERROR(4,lSts);
575 }
576
577 /******************************************************************************
578  * TestSetValue
579  */
580 void TestSetValue()
581 {
582 #if MAKE_NT_CRASH
583     long lSts;
584 #endif
585
586 #if MAKE_NT_CRASH
587     lSts = RegSetValue((HKEY)2,"",0,NULL,0);
588     if (lSts != ERROR_INVALID_PARAMETER) xERROR(1,lSts);
589 #endif
590
591 #if MAKE_NT_CRASH
592     lSts = RegSetValue((HKEY)2,"regtest",0,NULL,0);
593     if (lSts != ERROR_INVALID_PARAMETER) xERROR(2,lSts);
594 #endif
595
596 #if MAKE_NT_CRASH
597     lSts = RegSetValue((HKEY)2,"regtest",REG_SZ,NULL,0);
598     if (lSts != ERROR_INVALID_HANDLE) xERROR(3,lSts);
599 #endif
600
601 #if MAKE_NT_CRASH
602     lSts = RegSetValue(HKEY_LOCAL_MACHINE,"regtest",REG_SZ,NULL,0);
603     if (lSts != ERROR_INVALID_HANDLE) xERROR(4,lSts);
604 #endif
605 }
606
607 /******************************************************************************
608  * TestSetValueEx
609  */
610 void TestSetValueEx()
611 {
612     long lSts;
613
614     lSts = RegSetValueEx((HKEY)2,"",0,0,NULL,0);
615     if (lSts != ERROR_INVALID_HANDLE) xERROR(1,lSts);
616
617     lSts = RegSetValueEx(HKEY_LOCAL_MACHINE,"",0,0,NULL,0);
618     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
619 }
620
621 /******************************************************************************
622  * TestUnLoadKey
623  */
624 void TestUnLoadKey()
625 {
626 #if CHECK_SAM
627     long lSts;
628 #endif
629
630 #if CHECK_SAM
631     lSts = RegUnLoadKey((HKEY)2,"");
632     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(1,lSts);
633
634     lSts = RegUnLoadKey(HKEY_LOCAL_MACHINE,"");
635     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(2,lSts);
636
637     lSts = RegUnLoadKey(HKEY_LOCAL_MACHINE,"\\regtest");
638     if (lSts != ERROR_PRIVILEGE_NOT_HELD) xERROR(3,lSts);
639 #endif
640 }
641
642 /******************************************************************************
643  * TestSequence1
644  */
645 void TestSequence1()
646 {
647     HKEY hkey;
648     long lSts;
649
650     lSts = RegCreateKey(HKEY_CURRENT_USER,"regtest",&hkey);
651     if (lSts != ERROR_SUCCESS) xERROR(1,lSts);
652
653 /*    fprintf(stderr, " hkey=0x%x\n", hkey); */
654
655     lSts = RegDeleteKey(HKEY_CURRENT_USER, "regtest");
656     if (lSts != ERROR_SUCCESS) xERROR(2,lSts);
657     lSts = RegCloseKey(hkey);
658     if (lSts != ERROR_SUCCESS) xERROR(3,lSts);
659 }
660
661
662 int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
663 {
664
665     /* These can be in any order */
666     TestCloseKey();
667     TestConnectRegistry();
668     TestCreateKey();
669     TestCreateKeyEx();
670     TestDeleteKey();
671     TestDeleteValue();
672     TestEnumKey();
673     TestEnumKeyEx();
674     TestEnumValue();
675     TestFlushKey();
676     TestGetKeySecurity();
677     TestLoadKey();
678     TestNotifyChangeKeyValue();
679     TestOpenKey();
680     TestOpenKeyEx();
681     TestQueryInfoKey();
682     TestQueryValue();
683     TestQueryValueEx();
684     TestReplaceKey();
685     TestRestoreKey();
686     TestSaveKey();
687     TestSetKeySecurity();
688     TestSetValue();
689     TestSetValueEx();
690     TestUnLoadKey();
691     TestCreateKeyEx1();
692
693     /* Now we have some sequence testing */
694     TestSequence1();
695
696     return 0;
697 }
698