fc6dc40b561147f0d002e1923cefc59a941712c7
[reactos.git] / rostests / apitests / advapi32 / RegOpenKeyExW.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for the RegOpenKeyExW alignment
5 * PROGRAMMER: Mark Jansen <mark.jansen@reactos.org>
6 */
7 #include <apitest.h>
8
9 #define WIN32_NO_STATUS
10 #include <winreg.h>
11
12 #include <pshpack1.h>
13 struct Unalignment1
14 {
15 char dum;
16 WCHAR buffer[20];
17 } Unalignment1;
18 struct Unalignment2
19 {
20 char dum;
21 HKEY hk;
22 } Unalignment2;
23 #include <poppack.h>
24
25
26 #define TEST_STR L".exe"
27
28
29 START_TEST(RegOpenKeyExW)
30 {
31 struct Unalignment1 un;
32 struct Unalignment2 un2;
33 HKEY hk;
34 LONG lRes;
35
36 memcpy(un.buffer, TEST_STR, sizeof(TEST_STR));
37 un2.hk = 0;
38
39 lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, TEST_STR, 0, KEY_READ, &hk);
40 ok_int(lRes, ERROR_SUCCESS);
41 if (lRes)
42 return;
43 RegCloseKey(hk);
44
45 ok_hex(((ULONG_PTR)un.buffer) % 2, 1);
46 lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, un.buffer, 0, KEY_READ, &hk);
47 ok_int(lRes, ERROR_SUCCESS);
48 if (!lRes)
49 RegCloseKey(hk);
50
51 ok_hex(((ULONG_PTR)&un2.hk) % 2, 1);
52 lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, TEST_STR, 0, KEY_READ, &un2.hk);
53 ok_int(lRes, ERROR_SUCCESS);
54 if (!lRes)
55 {
56 hk = un2.hk;
57 RegCloseKey(hk);
58 }
59 }