4 * Copyright 2010 Damjan Jovanovic
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
26 #include <wine/test.h>
40 static const char textA
[] =
43 " ForceRemove eebf73c4-50fd-478f-bbcf-db212221227a \n"
45 " val 'string' = s 'string' \n"
46 " val 'dword_quoted_dec' = d '1' \n"
47 " val 'dword_unquoted_dec' = d 1 \n"
48 " val 'dword_quoted_hex' = d '0xA' \n"
49 " val 'dword_unquoted_hex' = d 0xA \n"
50 " val 'binary_quoted' = b 'deadbeef' \n"
51 " val 'binary_unquoted' = b deadbeef \n"
55 static void test_registrar(void)
57 IRegistrar
*registrar
= NULL
;
62 if (!GetProcAddress(GetModuleHandleA("atl.dll"), "AtlAxAttachControl"))
64 win_skip("Old versions of atl.dll don't support binary values\n");
68 hr
= CoCreateInstance(&CLSID_Registrar
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IRegistrar
, (void**)®istrar
);
71 skip("creating IRegistrar failed, hr = 0x%08X\n", hr
);
75 count
= MultiByteToWideChar(CP_ACP
, 0, textA
, -1, NULL
, 0);
76 textW
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(WCHAR
));
85 MultiByteToWideChar(CP_ACP
, 0, textA
, -1, textW
, count
);
86 hr
= IRegistrar_StringRegister(registrar
, textW
);
87 ok(SUCCEEDED(hr
), "IRegistrar_StringRegister failed, hr = 0x%08X\n", hr
);
89 lret
= RegOpenKeyA(HKEY_CLASSES_ROOT
, "eebf73c4-50fd-478f-bbcf-db212221227a", &key
);
90 ok(lret
== ERROR_SUCCESS
, "error %d opening registry key\n", lret
);
93 lret
= RegQueryValueExA(key
, "dword_unquoted_hex", NULL
, NULL
, (BYTE
*)&dword
, &size
);
94 ok(lret
== ERROR_SUCCESS
, "RegQueryValueExA failed, error %d\n", lret
);
95 ok(dword
!= 0xA, "unquoted hex is not supposed to be preserved\n");
98 lret
= RegQueryValueExA(key
, "dword_quoted_hex", NULL
, NULL
, (BYTE
*)&dword
, &size
);
99 ok(lret
== ERROR_SUCCESS
, "RegQueryValueExA failed, error %d\n", lret
);
100 ok(dword
!= 0xA, "quoted hex is not supposed to be preserved\n");
102 size
= sizeof(dword
);
103 lret
= RegQueryValueExA(key
, "dword_unquoted_dec", NULL
, NULL
, (BYTE
*)&dword
, &size
);
104 ok(lret
== ERROR_SUCCESS
, "RegQueryValueExA failed, error %d\n", lret
);
105 ok(dword
== 1, "unquoted dec is not supposed to be %d\n", dword
);
107 size
= sizeof(dword
);
108 lret
= RegQueryValueExA(key
, "dword_quoted_dec", NULL
, NULL
, (BYTE
*)&dword
, &size
);
109 ok(lret
== ERROR_SUCCESS
, "RegQueryValueExA failed, error %d\n", lret
);
110 ok(dword
== 1, "quoted dec is not supposed to be %d\n", dword
);
113 lret
= RegQueryValueExA(key
, "binary_quoted", NULL
, NULL
, bytes
, &size
);
114 ok(lret
== ERROR_SUCCESS
, "RegQueryValueA, failed, error %d\n", lret
);
115 ok(bytes
[0] == 0xde && bytes
[1] == 0xad && bytes
[2] == 0xbe && bytes
[3] == 0xef,
116 "binary quoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
117 0xff & bytes
[0], 0xff & bytes
[1], 0xff & bytes
[2], 0xff & bytes
[3]);
120 lret
= RegQueryValueExA(key
, "binary_unquoted", NULL
, NULL
, bytes
, &size
);
121 ok(lret
== ERROR_SUCCESS
, "RegQueryValueA, failed, error %d\n", lret
);
122 ok(bytes
[0] == 0xde && bytes
[1] == 0xad && bytes
[2] == 0xbe && bytes
[3] == 0xef,
123 "binary unquoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
124 0xff & bytes
[0], 0xff & bytes
[1], 0xff & bytes
[2], 0xff & bytes
[3]);
126 hr
= IRegistrar_StringUnregister(registrar
, textW
);
127 ok(SUCCEEDED(hr
), "IRegistrar_StringUnregister failed, hr = 0x%08X\n", hr
);
130 HeapFree(GetProcessHeap(), 0, textW
);
133 skip("allocating memory failed\n");
135 IRegistrar_Release(registrar
);
138 START_TEST(registrar
)