Sync with trunk r43123
[reactos.git] / rostests / winetests / msi / msi.c
1 /*
2 * tests for Microsoft Installer functionality
3 *
4 * Copyright 2005 Mike McCormack for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #define _WIN32_MSI 300
22
23 #include <stdio.h>
24 #include <windows.h>
25 #include <msi.h>
26 #include <msiquery.h>
27 #include <sddl.h>
28
29 #include "wine/test.h"
30
31 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
32
33 static INSTALLSTATE (WINAPI *pMsiGetComponentPathA)
34 (LPCSTR, LPCSTR, LPSTR, DWORD*);
35 static UINT (WINAPI *pMsiGetFileHashA)
36 (LPCSTR, DWORD, PMSIFILEHASHINFO);
37 static UINT (WINAPI *pMsiGetProductInfoExA)
38 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, LPSTR, LPDWORD);
39 static UINT (WINAPI *pMsiOpenPackageExA)
40 (LPCSTR, DWORD, MSIHANDLE*);
41 static UINT (WINAPI *pMsiOpenPackageExW)
42 (LPCWSTR, DWORD, MSIHANDLE*);
43 static UINT (WINAPI *pMsiQueryComponentStateA)
44 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
45 static INSTALLSTATE (WINAPI *pMsiUseFeatureExA)
46 (LPCSTR, LPCSTR ,DWORD, DWORD );
47
48 static void init_functionpointers(void)
49 {
50 HMODULE hmsi = GetModuleHandleA("msi.dll");
51 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
52
53 #define GET_PROC(dll, func) \
54 p ## func = (void *)GetProcAddress(dll, #func); \
55 if(!p ## func) \
56 trace("GetProcAddress(%s) failed\n", #func);
57
58 GET_PROC(hmsi, MsiGetComponentPathA)
59 GET_PROC(hmsi, MsiGetFileHashA)
60 GET_PROC(hmsi, MsiGetProductInfoExA)
61 GET_PROC(hmsi, MsiOpenPackageExA)
62 GET_PROC(hmsi, MsiOpenPackageExW)
63 GET_PROC(hmsi, MsiQueryComponentStateA)
64 GET_PROC(hmsi, MsiUseFeatureExA)
65
66 GET_PROC(hadvapi32, ConvertSidToStringSidA)
67
68 #undef GET_PROC
69 }
70
71 static void test_usefeature(void)
72 {
73 INSTALLSTATE r;
74
75 if (!pMsiUseFeatureExA)
76 {
77 skip("MsiUseFeatureExA not implemented\n");
78 return;
79 }
80
81 r = MsiQueryFeatureState(NULL,NULL);
82 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
83
84 r = MsiQueryFeatureState("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL);
85 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
86
87 r = pMsiUseFeatureExA(NULL,NULL,0,0);
88 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
89
90 r = pMsiUseFeatureExA(NULL, "WORDVIEWFiles", -2, 1 );
91 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
92
93 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
94 NULL, -2, 0 );
95 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
96
97 r = pMsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
98 "WORDVIEWFiles", -2, 0 );
99 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
100
101 r = pMsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
102 "WORDVIEWFiles", -2, 0 );
103 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
104
105 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
106 "WORDVIEWFiles", -2, 1 );
107 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
108 }
109
110 static void test_null(void)
111 {
112 MSIHANDLE hpkg;
113 UINT r;
114 HKEY hkey;
115 DWORD dwType, cbData;
116 LPBYTE lpData = NULL;
117 INSTALLSTATE state;
118
119 r = pMsiOpenPackageExW(NULL, 0, &hpkg);
120 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
121
122 state = MsiQueryProductStateW(NULL);
123 ok( state == INSTALLSTATE_INVALIDARG, "wrong return\n");
124
125 r = MsiEnumFeaturesW(NULL,0,NULL,NULL);
126 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
127
128 r = MsiConfigureFeatureW(NULL, NULL, 0);
129 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
130
131 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", NULL, 0);
132 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
133
134 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", "foo", 0);
135 ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
136
137 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", "foo", INSTALLSTATE_DEFAULT);
138 ok( r == ERROR_UNKNOWN_PRODUCT, "wrong error %d\n", r);
139
140 /* make sure empty string to MsiGetProductInfo is not a handle to default registry value, saving and restoring the
141 * necessary registry values */
142
143 /* empty product string */
144 r = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", &hkey);
145 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
146
147 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
148 ok ( r == ERROR_SUCCESS || r == ERROR_FILE_NOT_FOUND, "wrong error %d\n", r);
149 if ( r == ERROR_SUCCESS )
150 {
151 lpData = HeapAlloc(GetProcessHeap(), 0, cbData);
152 if (!lpData)
153 skip("Out of memory\n");
154 else
155 {
156 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
157 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
158 }
159 }
160
161 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
162 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
163
164 r = MsiGetProductInfoA("", "", NULL, NULL);
165 ok ( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
166
167 if (lpData)
168 {
169 r = RegSetValueExA(hkey, NULL, 0, dwType, lpData, cbData);
170 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
171
172 HeapFree(GetProcessHeap(), 0, lpData);
173 }
174 else
175 {
176 r = RegDeleteValueA(hkey, NULL);
177 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
178 }
179
180 r = RegCloseKey(hkey);
181 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
182
183 /* empty attribute */
184 r = RegCreateKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", &hkey);
185 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
186
187 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
188 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
189
190 r = MsiGetProductInfoA("{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", "", NULL, NULL);
191 ok ( r == ERROR_UNKNOWN_PROPERTY, "wrong error %d\n", r);
192
193 r = RegCloseKey(hkey);
194 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
195
196 r = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}");
197 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
198 }
199
200 static void test_getcomponentpath(void)
201 {
202 INSTALLSTATE r;
203 char buffer[0x100];
204 DWORD sz;
205
206 if(!pMsiGetComponentPathA)
207 return;
208
209 r = pMsiGetComponentPathA( NULL, NULL, NULL, NULL );
210 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
211
212 r = pMsiGetComponentPathA( "bogus", "bogus", NULL, NULL );
213 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
214
215 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL, NULL );
216 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
217
218 sz = sizeof buffer;
219 buffer[0]=0;
220 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer, &sz );
221 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
222
223 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}",
224 "{00000000-0000-0000-0000-000000000000}", buffer, &sz );
225 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
226
227 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
228 "{00000000-0000-0000-0000-00000000}", buffer, &sz );
229 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
230
231 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
232 "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer, &sz );
233 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
234
235 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}",
236 "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer, &sz );
237 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
238 }
239
240 static void create_file(LPCSTR name, LPCSTR data, DWORD size)
241 {
242 HANDLE file;
243 DWORD written;
244
245 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
246 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
247 WriteFile(file, data, strlen(data), &written, NULL);
248
249 if (size)
250 {
251 SetFilePointer(file, size, NULL, FILE_BEGIN);
252 SetEndOfFile(file);
253 }
254
255 CloseHandle(file);
256 }
257
258 #define HASHSIZE sizeof(MSIFILEHASHINFO)
259
260 static const struct
261 {
262 LPCSTR data;
263 DWORD size;
264 MSIFILEHASHINFO hash;
265 } hash_data[] =
266 {
267 { "abc", 0,
268 { HASHSIZE,
269 { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 },
270 },
271 },
272
273 { "C:\\Program Files\\msitest\\caesar\n", 0,
274 { HASHSIZE,
275 { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 },
276 },
277 },
278
279 { "C:\\Program Files\\msitest\\caesar\n", 500,
280 { HASHSIZE,
281 { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 },
282 },
283 },
284 };
285
286 static void test_MsiGetFileHash(void)
287 {
288 const char name[] = "msitest.bin";
289 UINT r;
290 MSIFILEHASHINFO hash;
291 DWORD i;
292
293 if (!pMsiGetFileHashA)
294 {
295 skip("MsiGetFileHash not implemented\n");
296 return;
297 }
298
299 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
300
301 /* szFilePath is NULL */
302 r = pMsiGetFileHashA(NULL, 0, &hash);
303 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
304
305 /* szFilePath is empty */
306 r = pMsiGetFileHashA("", 0, &hash);
307 ok(r == ERROR_PATH_NOT_FOUND || r == ERROR_BAD_PATHNAME,
308 "Expected ERROR_PATH_NOT_FOUND or ERROR_BAD_PATHNAME, got %d\n", r);
309
310 /* szFilePath is nonexistent */
311 r = pMsiGetFileHashA(name, 0, &hash);
312 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
313
314 /* dwOptions is non-zero */
315 r = pMsiGetFileHashA(name, 1, &hash);
316 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
317
318 /* pHash.dwFileHashInfoSize is not correct */
319 hash.dwFileHashInfoSize = 0;
320 r = pMsiGetFileHashA(name, 0, &hash);
321 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
322
323 /* pHash is NULL */
324 r = pMsiGetFileHashA(name, 0, NULL);
325 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
326
327 for (i = 0; i < sizeof(hash_data) / sizeof(hash_data[0]); i++)
328 {
329 create_file(name, hash_data[i].data, hash_data[i].size);
330
331 memset(&hash, 0, sizeof(MSIFILEHASHINFO));
332 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
333
334 r = pMsiGetFileHashA(name, 0, &hash);
335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
336 ok(!memcmp(&hash, &hash_data[i].hash, HASHSIZE), "Hash incorrect\n");
337
338 DeleteFile(name);
339 }
340 }
341
342 /* copied from dlls/msi/registry.c */
343 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
344 {
345 DWORD i,n=1;
346 GUID guid;
347
348 if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
349 return FALSE;
350
351 for(i=0; i<8; i++)
352 out[7-i] = in[n++];
353 n++;
354 for(i=0; i<4; i++)
355 out[11-i] = in[n++];
356 n++;
357 for(i=0; i<4; i++)
358 out[15-i] = in[n++];
359 n++;
360 for(i=0; i<2; i++)
361 {
362 out[17+i*2] = in[n++];
363 out[16+i*2] = in[n++];
364 }
365 n++;
366 for( ; i<8; i++)
367 {
368 out[17+i*2] = in[n++];
369 out[16+i*2] = in[n++];
370 }
371 out[32]=0;
372 return TRUE;
373 }
374
375 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
376 {
377 WCHAR guidW[MAX_PATH];
378 WCHAR squashedW[MAX_PATH];
379 GUID guid;
380 HRESULT hr;
381 int size;
382
383 hr = CoCreateGuid(&guid);
384 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
385
386 size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
387 ok(size == 39, "Expected 39, got %d\n", hr);
388
389 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
390 squash_guid(guidW, squashedW);
391 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
392 }
393
394 static void get_user_sid(LPSTR *usersid)
395 {
396 HANDLE token;
397 BYTE buf[1024];
398 DWORD size;
399 PTOKEN_USER user;
400
401 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
402 size = sizeof(buf);
403 GetTokenInformation(token, TokenUser, (void *)buf, size, &size);
404 user = (PTOKEN_USER)buf;
405 pConvertSidToStringSidA(user->User.Sid, usersid);
406 }
407
408 static void test_MsiQueryProductState(void)
409 {
410 CHAR prodcode[MAX_PATH];
411 CHAR prod_squashed[MAX_PATH];
412 CHAR keypath[MAX_PATH*2];
413 LPSTR usersid;
414 INSTALLSTATE state;
415 LONG res;
416 HKEY userkey, localkey, props;
417 HKEY prodkey;
418 DWORD data;
419
420 create_test_guid(prodcode, prod_squashed);
421 get_user_sid(&usersid);
422
423 /* NULL prodcode */
424 state = MsiQueryProductStateA(NULL);
425 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
426
427 /* empty prodcode */
428 state = MsiQueryProductStateA("");
429 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
430
431 /* garbage prodcode */
432 state = MsiQueryProductStateA("garbage");
433 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
434
435 /* guid without brackets */
436 state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
437 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
438
439 /* guid with brackets */
440 state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
441 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
442
443 /* same length as guid, but random */
444 state = MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
445 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
446
447 /* MSIINSTALLCONTEXT_USERUNMANAGED */
448
449 state = MsiQueryProductStateA(prodcode);
450 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
451
452 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
453 lstrcatA(keypath, prod_squashed);
454
455 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
456 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
457
458 /* user product key exists */
459 state = MsiQueryProductStateA(prodcode);
460 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
461
462 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
463 lstrcatA(keypath, prodcode);
464
465 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
466 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
467
468 /* local uninstall key exists */
469 state = MsiQueryProductStateA(prodcode);
470 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
471
472 data = 1;
473 res = RegSetValueExA(localkey, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
474 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
475
476 /* WindowsInstaller value exists */
477 state = MsiQueryProductStateA(prodcode);
478 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
479
480 RegDeleteValueA(localkey, "WindowsInstaller");
481 RegDeleteKeyA(localkey, "");
482
483 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
484 lstrcatA(keypath, usersid);
485 lstrcatA(keypath, "\\Products\\");
486 lstrcatA(keypath, prod_squashed);
487
488 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
489 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
490
491 /* local product key exists */
492 state = MsiQueryProductStateA(prodcode);
493 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
494
495 res = RegCreateKeyA(localkey, "InstallProperties", &props);
496 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
497
498 /* install properties key exists */
499 state = MsiQueryProductStateA(prodcode);
500 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
501
502 data = 1;
503 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
504 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
505
506 /* WindowsInstaller value exists */
507 state = MsiQueryProductStateA(prodcode);
508 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
509
510 data = 2;
511 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
512 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
513
514 /* WindowsInstaller value is not 1 */
515 state = MsiQueryProductStateA(prodcode);
516 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
517
518 RegDeleteKeyA(userkey, "");
519
520 /* user product key does not exist */
521 state = MsiQueryProductStateA(prodcode);
522 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
523
524 RegDeleteValueA(props, "WindowsInstaller");
525 RegDeleteKeyA(props, "");
526 RegCloseKey(props);
527 RegDeleteKeyA(localkey, "");
528 RegCloseKey(localkey);
529 RegDeleteKeyA(userkey, "");
530 RegCloseKey(userkey);
531
532 /* MSIINSTALLCONTEXT_USERMANAGED */
533
534 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
535 lstrcatA(keypath, usersid);
536 lstrcatA(keypath, "\\Installer\\Products\\");
537 lstrcatA(keypath, prod_squashed);
538
539 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
541
542 state = MsiQueryProductStateA(prodcode);
543 ok(state == INSTALLSTATE_ADVERTISED,
544 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
545
546 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
547 lstrcatA(keypath, usersid);
548 lstrcatA(keypath, "\\Products\\");
549 lstrcatA(keypath, prod_squashed);
550
551 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
552 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
553
554 state = MsiQueryProductStateA(prodcode);
555 ok(state == INSTALLSTATE_ADVERTISED,
556 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
557
558 res = RegCreateKeyA(localkey, "InstallProperties", &props);
559 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
560
561 state = MsiQueryProductStateA(prodcode);
562 ok(state == INSTALLSTATE_ADVERTISED,
563 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
564
565 data = 1;
566 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
567 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
568
569 /* WindowsInstaller value exists */
570 state = MsiQueryProductStateA(prodcode);
571 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
572
573 RegDeleteValueA(props, "WindowsInstaller");
574 RegDeleteKeyA(props, "");
575 RegCloseKey(props);
576 RegDeleteKeyA(localkey, "");
577 RegCloseKey(localkey);
578 RegDeleteKeyA(prodkey, "");
579 RegCloseKey(prodkey);
580
581 /* MSIINSTALLCONTEXT_MACHINE */
582
583 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
584 lstrcatA(keypath, prod_squashed);
585
586 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
587 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
588
589 state = MsiQueryProductStateA(prodcode);
590 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
591
592 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
593 lstrcatA(keypath, "S-1-5-18\\Products\\");
594 lstrcatA(keypath, prod_squashed);
595
596 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
597 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
598
599 state = MsiQueryProductStateA(prodcode);
600 ok(state == INSTALLSTATE_ADVERTISED,
601 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
602
603 res = RegCreateKeyA(localkey, "InstallProperties", &props);
604 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
605
606 state = MsiQueryProductStateA(prodcode);
607 ok(state == INSTALLSTATE_ADVERTISED,
608 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
609
610 data = 1;
611 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
612 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
613
614 /* WindowsInstaller value exists */
615 state = MsiQueryProductStateA(prodcode);
616 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
617
618 RegDeleteValueA(props, "WindowsInstaller");
619 RegDeleteKeyA(props, "");
620 RegCloseKey(props);
621 RegDeleteKeyA(localkey, "");
622 RegCloseKey(localkey);
623 RegDeleteKeyA(prodkey, "");
624 RegCloseKey(prodkey);
625
626 LocalFree(usersid);
627 }
628
629 static const char table_enc85[] =
630 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
631 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
632 "yz{}~";
633
634 /*
635 * Encodes a base85 guid given a GUID pointer
636 * Caller should provide a 21 character buffer for the encoded string.
637 *
638 * returns TRUE if successful, FALSE if not
639 */
640 static BOOL encode_base85_guid( GUID *guid, LPWSTR str )
641 {
642 unsigned int x, *p, i;
643
644 p = (unsigned int*) guid;
645 for( i=0; i<4; i++ )
646 {
647 x = p[i];
648 *str++ = table_enc85[x%85];
649 x = x/85;
650 *str++ = table_enc85[x%85];
651 x = x/85;
652 *str++ = table_enc85[x%85];
653 x = x/85;
654 *str++ = table_enc85[x%85];
655 x = x/85;
656 *str++ = table_enc85[x%85];
657 }
658 *str = 0;
659
660 return TRUE;
661 }
662
663 static void compose_base85_guid(LPSTR component, LPSTR comp_base85, LPSTR squashed)
664 {
665 WCHAR guidW[MAX_PATH];
666 WCHAR base85W[MAX_PATH];
667 WCHAR squashedW[MAX_PATH];
668 GUID guid;
669 HRESULT hr;
670 int size;
671
672 hr = CoCreateGuid(&guid);
673 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
674
675 size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
676 ok(size == 39, "Expected 39, got %d\n", hr);
677
678 WideCharToMultiByte(CP_ACP, 0, guidW, size, component, MAX_PATH, NULL, NULL);
679 encode_base85_guid(&guid, base85W);
680 WideCharToMultiByte(CP_ACP, 0, base85W, -1, comp_base85, MAX_PATH, NULL, NULL);
681 squash_guid(guidW, squashedW);
682 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
683 }
684
685 static void test_MsiQueryFeatureState(void)
686 {
687 HKEY userkey, localkey, compkey;
688 CHAR prodcode[MAX_PATH];
689 CHAR prod_squashed[MAX_PATH];
690 CHAR component[MAX_PATH];
691 CHAR comp_base85[MAX_PATH];
692 CHAR comp_squashed[MAX_PATH];
693 CHAR keypath[MAX_PATH*2];
694 INSTALLSTATE state;
695 LPSTR usersid;
696 LONG res;
697
698 create_test_guid(prodcode, prod_squashed);
699 compose_base85_guid(component, comp_base85, comp_squashed);
700 get_user_sid(&usersid);
701
702 /* NULL prodcode */
703 state = MsiQueryFeatureStateA(NULL, "feature");
704 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
705
706 /* empty prodcode */
707 state = MsiQueryFeatureStateA("", "feature");
708 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
709
710 /* garbage prodcode */
711 state = MsiQueryFeatureStateA("garbage", "feature");
712 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
713
714 /* guid without brackets */
715 state = MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
716 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
717
718 /* guid with brackets */
719 state = MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
720 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
721
722 /* same length as guid, but random */
723 state = MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
724 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
725
726 /* NULL szFeature */
727 state = MsiQueryFeatureStateA(prodcode, NULL);
728 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
729
730 /* empty szFeature */
731 state = MsiQueryFeatureStateA(prodcode, "");
732 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
733
734 /* feature key does not exist yet */
735 state = MsiQueryFeatureStateA(prodcode, "feature");
736 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
737
738 /* MSIINSTALLCONTEXT_USERUNMANAGED */
739
740 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Features\\");
741 lstrcatA(keypath, prod_squashed);
742
743 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
744 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
745
746 /* feature key exists */
747 state = MsiQueryFeatureStateA(prodcode, "feature");
748 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
749
750 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
751 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
752
753 /* feature value exists */
754 state = MsiQueryFeatureStateA(prodcode, "feature");
755 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
756
757 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
758 lstrcatA(keypath, usersid);
759 lstrcatA(keypath, "\\Products\\");
760 lstrcatA(keypath, prod_squashed);
761 lstrcatA(keypath, "\\Features");
762
763 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
764 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
765
766 /* userdata features key exists */
767 state = MsiQueryFeatureStateA(prodcode, "feature");
768 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
769
770 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
771 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
772
773 state = MsiQueryFeatureStateA(prodcode, "feature");
774 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
775
776 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
777 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
778
779 state = MsiQueryFeatureStateA(prodcode, "feature");
780 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
781
782 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
783 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
784
785 state = MsiQueryFeatureStateA(prodcode, "feature");
786 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
787
788 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
789 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
790
791 state = MsiQueryFeatureStateA(prodcode, "feature");
792 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
793
794 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
795 lstrcatA(keypath, usersid);
796 lstrcatA(keypath, "\\Components\\");
797 lstrcatA(keypath, comp_squashed);
798
799 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
800 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
801
802 state = MsiQueryFeatureStateA(prodcode, "feature");
803 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
804
805 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
806 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
807
808 state = MsiQueryFeatureStateA(prodcode, "feature");
809 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
810
811 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
812 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
813
814 state = MsiQueryFeatureStateA(prodcode, "feature");
815 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
816
817 RegDeleteValueA(compkey, prod_squashed);
818 RegDeleteKeyA(compkey, "");
819 RegDeleteValueA(localkey, "feature");
820 RegDeleteValueA(userkey, "feature");
821 RegDeleteKeyA(userkey, "");
822 RegCloseKey(compkey);
823 RegCloseKey(localkey);
824 RegCloseKey(userkey);
825
826 /* MSIINSTALLCONTEXT_USERMANAGED */
827
828 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
829 lstrcatA(keypath, usersid);
830 lstrcatA(keypath, "\\Installer\\Features\\");
831 lstrcatA(keypath, prod_squashed);
832
833 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
834 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
835
836 /* feature key exists */
837 state = MsiQueryFeatureStateA(prodcode, "feature");
838 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
839
840 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
841 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
842
843 /* feature value exists */
844 state = MsiQueryFeatureStateA(prodcode, "feature");
845 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
846
847 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
848 lstrcatA(keypath, usersid);
849 lstrcatA(keypath, "\\Products\\");
850 lstrcatA(keypath, prod_squashed);
851 lstrcatA(keypath, "\\Features");
852
853 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
854 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
855
856 /* userdata features key exists */
857 state = MsiQueryFeatureStateA(prodcode, "feature");
858 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
859
860 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
861 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
862
863 state = MsiQueryFeatureStateA(prodcode, "feature");
864 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
865
866 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
867 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
868
869 state = MsiQueryFeatureStateA(prodcode, "feature");
870 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
871
872 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
873 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
874
875 state = MsiQueryFeatureStateA(prodcode, "feature");
876 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
877
878 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
879 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
880
881 state = MsiQueryFeatureStateA(prodcode, "feature");
882 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
883
884 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
885 lstrcatA(keypath, usersid);
886 lstrcatA(keypath, "\\Components\\");
887 lstrcatA(keypath, comp_squashed);
888
889 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
890 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
891
892 state = MsiQueryFeatureStateA(prodcode, "feature");
893 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
894
895 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
896 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
897
898 state = MsiQueryFeatureStateA(prodcode, "feature");
899 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
900
901 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
902 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
903
904 state = MsiQueryFeatureStateA(prodcode, "feature");
905 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
906
907 RegDeleteValueA(compkey, prod_squashed);
908 RegDeleteKeyA(compkey, "");
909 RegDeleteValueA(localkey, "feature");
910 RegDeleteValueA(userkey, "feature");
911 RegDeleteKeyA(userkey, "");
912 RegCloseKey(compkey);
913 RegCloseKey(localkey);
914 RegCloseKey(userkey);
915
916 /* MSIINSTALLCONTEXT_MACHINE */
917
918 lstrcpyA(keypath, "Software\\Classes\\Installer\\Features\\");
919 lstrcatA(keypath, prod_squashed);
920
921 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
922 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
923
924 /* feature key exists */
925 state = MsiQueryFeatureStateA(prodcode, "feature");
926 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
927
928 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
929 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
930
931 /* feature value exists */
932 state = MsiQueryFeatureStateA(prodcode, "feature");
933 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
934
935 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
936 lstrcatA(keypath, "S-1-5-18\\Products\\");
937 lstrcatA(keypath, prod_squashed);
938 lstrcatA(keypath, "\\Features");
939
940 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
941 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
942
943 /* userdata features key exists */
944 state = MsiQueryFeatureStateA(prodcode, "feature");
945 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
946
947 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
948 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
949
950 state = MsiQueryFeatureStateA(prodcode, "feature");
951 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
952
953 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
954 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
955
956 state = MsiQueryFeatureStateA(prodcode, "feature");
957 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
958
959 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
960 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
961
962 state = MsiQueryFeatureStateA(prodcode, "feature");
963 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
964
965 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
966 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
967
968 state = MsiQueryFeatureStateA(prodcode, "feature");
969 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
970
971 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
972 lstrcatA(keypath, "S-1-5-18\\Components\\");
973 lstrcatA(keypath, comp_squashed);
974
975 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
976 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
977
978 state = MsiQueryFeatureStateA(prodcode, "feature");
979 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
980
981 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
982 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
983
984 state = MsiQueryFeatureStateA(prodcode, "feature");
985 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
986
987 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
988 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
989
990 state = MsiQueryFeatureStateA(prodcode, "feature");
991 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
992
993 RegDeleteValueA(compkey, prod_squashed);
994 RegDeleteKeyA(compkey, "");
995 RegDeleteValueA(localkey, "feature");
996 RegDeleteValueA(userkey, "feature");
997 RegDeleteKeyA(userkey, "");
998 RegCloseKey(compkey);
999 RegCloseKey(localkey);
1000 RegCloseKey(userkey);
1001 }
1002
1003 static void test_MsiQueryComponentState(void)
1004 {
1005 HKEY compkey, prodkey;
1006 CHAR prodcode[MAX_PATH];
1007 CHAR prod_squashed[MAX_PATH];
1008 CHAR component[MAX_PATH];
1009 CHAR comp_base85[MAX_PATH];
1010 CHAR comp_squashed[MAX_PATH];
1011 CHAR keypath[MAX_PATH];
1012 INSTALLSTATE state;
1013 LPSTR usersid;
1014 LONG res;
1015 UINT r;
1016
1017 static const INSTALLSTATE MAGIC_ERROR = 0xdeadbeef;
1018
1019 if (!pMsiQueryComponentStateA)
1020 {
1021 skip("MsiQueryComponentStateA not implemented\n");
1022 return;
1023 }
1024
1025 create_test_guid(prodcode, prod_squashed);
1026 compose_base85_guid(component, comp_base85, comp_squashed);
1027 get_user_sid(&usersid);
1028
1029 /* NULL szProductCode */
1030 state = MAGIC_ERROR;
1031 r = pMsiQueryComponentStateA(NULL, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1032 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1033 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1034
1035 /* empty szProductCode */
1036 state = MAGIC_ERROR;
1037 r = pMsiQueryComponentStateA("", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1038 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1039 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1040
1041 /* random szProductCode */
1042 state = MAGIC_ERROR;
1043 r = pMsiQueryComponentStateA("random", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1044 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1045 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1046
1047 /* GUID-length szProductCode */
1048 state = MAGIC_ERROR;
1049 r = pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1050 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1051 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1052
1053 /* GUID-length with brackets */
1054 state = MAGIC_ERROR;
1055 r = pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1056 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1057 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1058
1059 /* actual GUID */
1060 state = MAGIC_ERROR;
1061 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1062 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1063 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1064
1065 state = MAGIC_ERROR;
1066 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1067 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1068 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1069
1070 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1071 lstrcatA(keypath, prod_squashed);
1072
1073 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1074 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1075
1076 state = MAGIC_ERROR;
1077 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1078 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1079 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1080
1081 RegDeleteKeyA(prodkey, "");
1082 RegCloseKey(prodkey);
1083
1084 /* create local system product key */
1085 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
1086 lstrcatA(keypath, prod_squashed);
1087 lstrcatA(keypath, "\\InstallProperties");
1088
1089 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1090 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1091
1092 /* local system product key exists */
1093 state = MAGIC_ERROR;
1094 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1095 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1096 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1097
1098 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1099 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1100
1101 /* LocalPackage value exists */
1102 state = MAGIC_ERROR;
1103 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1104 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1105 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1106
1107 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
1108 lstrcatA(keypath, comp_squashed);
1109
1110 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1111 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1112
1113 /* component key exists */
1114 state = MAGIC_ERROR;
1115 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1116 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1117 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1118
1119 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
1120 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1121
1122 /* component\product exists */
1123 state = MAGIC_ERROR;
1124 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1125 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1126 ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
1127
1128 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
1129 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1130
1131 state = MAGIC_ERROR;
1132 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1134 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1135
1136 RegDeleteValueA(prodkey, "LocalPackage");
1137 RegDeleteKeyA(prodkey, "");
1138 RegDeleteValueA(compkey, prod_squashed);
1139 RegDeleteKeyA(prodkey, "");
1140 RegCloseKey(prodkey);
1141 RegCloseKey(compkey);
1142
1143 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1144
1145 state = MAGIC_ERROR;
1146 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1147 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1148 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1149
1150 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1151 lstrcatA(keypath, prod_squashed);
1152
1153 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1154 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1155
1156 state = MAGIC_ERROR;
1157 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1158 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1159 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1160
1161 RegDeleteKeyA(prodkey, "");
1162 RegCloseKey(prodkey);
1163
1164 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1165 lstrcatA(keypath, usersid);
1166 lstrcatA(keypath, "\\Products\\");
1167 lstrcatA(keypath, prod_squashed);
1168 lstrcatA(keypath, "\\InstallProperties");
1169
1170 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1171 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1172
1173 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1174 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1175
1176 RegCloseKey(prodkey);
1177
1178 state = MAGIC_ERROR;
1179 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1180 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1181 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1182
1183 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1184 lstrcatA(keypath, usersid);
1185 lstrcatA(keypath, "\\Components\\");
1186 lstrcatA(keypath, comp_squashed);
1187
1188 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1189 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1190
1191 /* component key exists */
1192 state = MAGIC_ERROR;
1193 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1194 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1195 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1196
1197 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
1198 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1199
1200 /* component\product exists */
1201 state = MAGIC_ERROR;
1202 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1204 ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
1205
1206 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
1207 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1208
1209 state = MAGIC_ERROR;
1210 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1211 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1212 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1213
1214 /* MSIINSTALLCONTEXT_USERMANAGED */
1215
1216 state = MAGIC_ERROR;
1217 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1218 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1219 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1220
1221 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1222 lstrcatA(keypath, prod_squashed);
1223
1224 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1225 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1226
1227 state = MAGIC_ERROR;
1228 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1229 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1230 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1231
1232 RegDeleteKeyA(prodkey, "");
1233 RegCloseKey(prodkey);
1234
1235 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1236 lstrcatA(keypath, usersid);
1237 lstrcatA(keypath, "\\Installer\\Products\\");
1238 lstrcatA(keypath, prod_squashed);
1239
1240 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1241 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1242
1243 state = MAGIC_ERROR;
1244 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1245 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1246 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1247
1248 RegDeleteKeyA(prodkey, "");
1249 RegCloseKey(prodkey);
1250
1251 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1252 lstrcatA(keypath, usersid);
1253 lstrcatA(keypath, "\\Products\\");
1254 lstrcatA(keypath, prod_squashed);
1255 lstrcatA(keypath, "\\InstallProperties");
1256
1257 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1258 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1259
1260 res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1261 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1262
1263 state = MAGIC_ERROR;
1264 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1266 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1267
1268 RegDeleteValueA(prodkey, "LocalPackage");
1269 RegDeleteValueA(prodkey, "ManagedLocalPackage");
1270 RegDeleteKeyA(prodkey, "");
1271 RegDeleteValueA(compkey, prod_squashed);
1272 RegDeleteKeyA(compkey, "");
1273 RegCloseKey(prodkey);
1274 RegCloseKey(compkey);
1275 }
1276
1277 static void test_MsiGetComponentPath(void)
1278 {
1279 HKEY compkey, prodkey, installprop;
1280 CHAR prodcode[MAX_PATH];
1281 CHAR prod_squashed[MAX_PATH];
1282 CHAR component[MAX_PATH];
1283 CHAR comp_base85[MAX_PATH];
1284 CHAR comp_squashed[MAX_PATH];
1285 CHAR keypath[MAX_PATH];
1286 CHAR path[MAX_PATH];
1287 INSTALLSTATE state;
1288 LPSTR usersid;
1289 DWORD size, val;
1290 LONG res;
1291
1292 create_test_guid(prodcode, prod_squashed);
1293 compose_base85_guid(component, comp_base85, comp_squashed);
1294 get_user_sid(&usersid);
1295
1296 /* NULL szProduct */
1297 size = MAX_PATH;
1298 state = MsiGetComponentPathA(NULL, component, path, &size);
1299 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1300 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1301
1302 /* NULL szComponent */
1303 size = MAX_PATH;
1304 state = MsiGetComponentPathA(prodcode, NULL, path, &size);
1305 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1306 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1307
1308 /* NULL lpPathBuf */
1309 size = MAX_PATH;
1310 state = MsiGetComponentPathA(prodcode, component, NULL, &size);
1311 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1312 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1313
1314 /* NULL pcchBuf */
1315 size = MAX_PATH;
1316 state = MsiGetComponentPathA(prodcode, component, path, NULL);
1317 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1318 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1319
1320 /* all params valid */
1321 size = MAX_PATH;
1322 state = MsiGetComponentPathA(prodcode, component, path, &size);
1323 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1324 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1325
1326 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1327 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1328 lstrcatA(keypath, comp_squashed);
1329
1330 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1331 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1332
1333 /* local system component key exists */
1334 size = MAX_PATH;
1335 state = MsiGetComponentPathA(prodcode, component, path, &size);
1336 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1337 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1338
1339 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1340 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1341
1342 /* product value exists */
1343 size = MAX_PATH;
1344 state = MsiGetComponentPathA(prodcode, component, path, &size);
1345 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1346 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1347 ok(size == 10, "Expected 10, got %d\n", size);
1348
1349 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1350 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1351 lstrcatA(keypath, prod_squashed);
1352 lstrcatA(keypath, "\\InstallProperties");
1353
1354 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1355 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1356
1357 val = 1;
1358 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1359 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1360
1361 /* install properties key exists */
1362 size = MAX_PATH;
1363 state = MsiGetComponentPathA(prodcode, component, path, &size);
1364 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1365 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1366 ok(size == 10, "Expected 10, got %d\n", size);
1367
1368 create_file("C:\\imapath", "C:\\imapath", 11);
1369
1370 /* file exists */
1371 size = MAX_PATH;
1372 state = MsiGetComponentPathA(prodcode, component, path, &size);
1373 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1374 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1375 ok(size == 10, "Expected 10, got %d\n", size);
1376
1377 RegDeleteValueA(compkey, prod_squashed);
1378 RegDeleteKeyA(compkey, "");
1379 RegDeleteValueA(installprop, "WindowsInstaller");
1380 RegDeleteKeyA(installprop, "");
1381 RegCloseKey(compkey);
1382 RegCloseKey(installprop);
1383 DeleteFileA("C:\\imapath");
1384
1385 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1386 lstrcatA(keypath, "Installer\\UserData\\");
1387 lstrcatA(keypath, usersid);
1388 lstrcatA(keypath, "\\Components\\");
1389 lstrcatA(keypath, comp_squashed);
1390
1391 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1392 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1393
1394 /* user managed component key exists */
1395 size = MAX_PATH;
1396 state = MsiGetComponentPathA(prodcode, component, path, &size);
1397 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1398 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1399
1400 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1401 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1402
1403 /* product value exists */
1404 size = MAX_PATH;
1405 state = MsiGetComponentPathA(prodcode, component, path, &size);
1406 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1407 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1408 ok(size == 10, "Expected 10, got %d\n", size);
1409
1410 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1411 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1412 lstrcatA(keypath, prod_squashed);
1413 lstrcatA(keypath, "\\InstallProperties");
1414
1415 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1416 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1417
1418 val = 1;
1419 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1420 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1421
1422 /* install properties key exists */
1423 size = MAX_PATH;
1424 state = MsiGetComponentPathA(prodcode, component, path, &size);
1425 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1426 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1427 ok(size == 10, "Expected 10, got %d\n", size);
1428
1429 create_file("C:\\imapath", "C:\\imapath", 11);
1430
1431 /* file exists */
1432 size = MAX_PATH;
1433 state = MsiGetComponentPathA(prodcode, component, path, &size);
1434 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1435 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1436 ok(size == 10, "Expected 10, got %d\n", size);
1437
1438 RegDeleteValueA(compkey, prod_squashed);
1439 RegDeleteKeyA(compkey, "");
1440 RegDeleteValueA(installprop, "WindowsInstaller");
1441 RegDeleteKeyA(installprop, "");
1442 RegCloseKey(compkey);
1443 RegCloseKey(installprop);
1444 DeleteFileA("C:\\imapath");
1445
1446 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1447 lstrcatA(keypath, "Installer\\Managed\\");
1448 lstrcatA(keypath, usersid);
1449 lstrcatA(keypath, "\\Installer\\Products\\");
1450 lstrcatA(keypath, prod_squashed);
1451
1452 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1453 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1454
1455 /* user managed product key exists */
1456 size = MAX_PATH;
1457 state = MsiGetComponentPathA(prodcode, component, path, &size);
1458 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1459 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1460
1461 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1462 lstrcatA(keypath, "Installer\\UserData\\");
1463 lstrcatA(keypath, usersid);
1464 lstrcatA(keypath, "\\Components\\");
1465 lstrcatA(keypath, comp_squashed);
1466
1467 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1468 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1469
1470 /* user managed component key exists */
1471 size = MAX_PATH;
1472 state = MsiGetComponentPathA(prodcode, component, path, &size);
1473 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1474 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1475
1476 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1478
1479 /* product value exists */
1480 size = MAX_PATH;
1481 state = MsiGetComponentPathA(prodcode, component, path, &size);
1482 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1483 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1484 ok(size == 10, "Expected 10, got %d\n", size);
1485
1486 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1487 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1488 lstrcatA(keypath, prod_squashed);
1489 lstrcatA(keypath, "\\InstallProperties");
1490
1491 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1492 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1493
1494 val = 1;
1495 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1496 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1497
1498 /* install properties key exists */
1499 size = MAX_PATH;
1500 state = MsiGetComponentPathA(prodcode, component, path, &size);
1501 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1502 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1503 ok(size == 10, "Expected 10, got %d\n", size);
1504
1505 create_file("C:\\imapath", "C:\\imapath", 11);
1506
1507 /* file exists */
1508 size = MAX_PATH;
1509 state = MsiGetComponentPathA(prodcode, component, path, &size);
1510 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1511 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1512 ok(size == 10, "Expected 10, got %d\n", size);
1513
1514 RegDeleteValueA(compkey, prod_squashed);
1515 RegDeleteKeyA(prodkey, "");
1516 RegDeleteKeyA(compkey, "");
1517 RegDeleteValueA(installprop, "WindowsInstaller");
1518 RegDeleteKeyA(installprop, "");
1519 RegCloseKey(prodkey);
1520 RegCloseKey(compkey);
1521 RegCloseKey(installprop);
1522 DeleteFileA("C:\\imapath");
1523
1524 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1525 lstrcatA(keypath, prod_squashed);
1526
1527 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1528 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1529
1530 /* user unmanaged product key exists */
1531 size = MAX_PATH;
1532 state = MsiGetComponentPathA(prodcode, component, path, &size);
1533 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1534 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1535
1536 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1537 lstrcatA(keypath, "Installer\\UserData\\");
1538 lstrcatA(keypath, usersid);
1539 lstrcatA(keypath, "\\Components\\");
1540 lstrcatA(keypath, comp_squashed);
1541
1542 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1543 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1544
1545 /* user unmanaged component key exists */
1546 size = MAX_PATH;
1547 state = MsiGetComponentPathA(prodcode, component, path, &size);
1548 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1549 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1550
1551 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1552 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1553
1554 /* product value exists */
1555 size = MAX_PATH;
1556 state = MsiGetComponentPathA(prodcode, component, path, &size);
1557 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1558 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1559 ok(size == 10, "Expected 10, got %d\n", size);
1560
1561 create_file("C:\\imapath", "C:\\imapath", 11);
1562
1563 /* file exists */
1564 size = MAX_PATH;
1565 state = MsiGetComponentPathA(prodcode, component, path, &size);
1566 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1567 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1568 ok(size == 10, "Expected 10, got %d\n", size);
1569
1570 RegDeleteValueA(compkey, prod_squashed);
1571 RegDeleteKeyA(prodkey, "");
1572 RegDeleteKeyA(compkey, "");
1573 RegCloseKey(prodkey);
1574 RegCloseKey(compkey);
1575 RegCloseKey(installprop);
1576 DeleteFileA("C:\\imapath");
1577
1578 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1579 lstrcatA(keypath, prod_squashed);
1580
1581 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1582 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1583
1584 /* local classes product key exists */
1585 size = MAX_PATH;
1586 state = MsiGetComponentPathA(prodcode, component, path, &size);
1587 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1588 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1589
1590 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1591 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1592 lstrcatA(keypath, comp_squashed);
1593
1594 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1595 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1596
1597 /* local user component key exists */
1598 size = MAX_PATH;
1599 state = MsiGetComponentPathA(prodcode, component, path, &size);
1600 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1601 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1602
1603 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1604 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1605
1606 /* product value exists */
1607 size = MAX_PATH;
1608 state = MsiGetComponentPathA(prodcode, component, path, &size);
1609 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1610 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1611 ok(size == 10, "Expected 10, got %d\n", size);
1612
1613 create_file("C:\\imapath", "C:\\imapath", 11);
1614
1615 /* file exists */
1616 size = MAX_PATH;
1617 state = MsiGetComponentPathA(prodcode, component, path, &size);
1618 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1619 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1620 ok(size == 10, "Expected 10, got %d\n", size);
1621
1622 RegDeleteValueA(compkey, prod_squashed);
1623 RegDeleteKeyA(prodkey, "");
1624 RegDeleteKeyA(compkey, "");
1625 RegCloseKey(prodkey);
1626 RegCloseKey(compkey);
1627 DeleteFileA("C:\\imapath");
1628 }
1629
1630 static void test_MsiGetProductCode(void)
1631 {
1632 HKEY compkey, prodkey;
1633 CHAR prodcode[MAX_PATH];
1634 CHAR prod_squashed[MAX_PATH];
1635 CHAR prodcode2[MAX_PATH];
1636 CHAR prod2_squashed[MAX_PATH];
1637 CHAR component[MAX_PATH];
1638 CHAR comp_base85[MAX_PATH];
1639 CHAR comp_squashed[MAX_PATH];
1640 CHAR keypath[MAX_PATH];
1641 CHAR product[MAX_PATH];
1642 LPSTR usersid;
1643 LONG res;
1644 UINT r;
1645
1646 create_test_guid(prodcode, prod_squashed);
1647 create_test_guid(prodcode2, prod2_squashed);
1648 compose_base85_guid(component, comp_base85, comp_squashed);
1649 get_user_sid(&usersid);
1650
1651 /* szComponent is NULL */
1652 lstrcpyA(product, "prod");
1653 r = MsiGetProductCodeA(NULL, product);
1654 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1655 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1656
1657 /* szComponent is empty */
1658 lstrcpyA(product, "prod");
1659 r = MsiGetProductCodeA("", product);
1660 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1661 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1662
1663 /* garbage szComponent */
1664 lstrcpyA(product, "prod");
1665 r = MsiGetProductCodeA("garbage", product);
1666 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1667 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1668
1669 /* guid without brackets */
1670 lstrcpyA(product, "prod");
1671 r = MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product);
1672 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1673 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1674
1675 /* guid with brackets */
1676 lstrcpyA(product, "prod");
1677 r = MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product);
1678 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1679 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1680
1681 /* same length as guid, but random */
1682 lstrcpyA(product, "prod");
1683 r = MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product);
1684 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1685 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1686
1687 /* all params correct, szComponent not published */
1688 lstrcpyA(product, "prod");
1689 r = MsiGetProductCodeA(component, product);
1690 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1691 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1692
1693 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1694 lstrcatA(keypath, "Installer\\UserData\\");
1695 lstrcatA(keypath, usersid);
1696 lstrcatA(keypath, "\\Components\\");
1697 lstrcatA(keypath, comp_squashed);
1698
1699 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1700 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1701
1702 /* user unmanaged component key exists */
1703 lstrcpyA(product, "prod");
1704 r = MsiGetProductCodeA(component, product);
1705 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1706 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1707
1708 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1709 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1710
1711 /* product value exists */
1712 lstrcpyA(product, "prod");
1713 r = MsiGetProductCodeA(component, product);
1714 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1715 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1716
1717 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1718 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1719
1720 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1721 lstrcatA(keypath, "Installer\\Managed\\");
1722 lstrcatA(keypath, usersid);
1723 lstrcatA(keypath, "\\Installer\\Products\\");
1724 lstrcatA(keypath, prod_squashed);
1725
1726 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1727 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1728
1729 /* user managed product key of first product exists */
1730 lstrcpyA(product, "prod");
1731 r = MsiGetProductCodeA(component, product);
1732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1733 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1734
1735 RegDeleteKeyA(prodkey, "");
1736 RegCloseKey(prodkey);
1737
1738 RegDeleteKeyA(prodkey, "");
1739 RegCloseKey(prodkey);
1740
1741 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1742 lstrcatA(keypath, prod_squashed);
1743
1744 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1745 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1746
1747 /* user unmanaged product key exists */
1748 lstrcpyA(product, "prod");
1749 r = MsiGetProductCodeA(component, product);
1750 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1751 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1752
1753 RegDeleteKeyA(prodkey, "");
1754 RegCloseKey(prodkey);
1755
1756 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1757 lstrcatA(keypath, prod_squashed);
1758
1759 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1760 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1761
1762 /* local classes product key exists */
1763 lstrcpyA(product, "prod");
1764 r = MsiGetProductCodeA(component, product);
1765 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1766 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1767
1768 RegDeleteKeyA(prodkey, "");
1769 RegCloseKey(prodkey);
1770
1771 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1772 lstrcatA(keypath, "Installer\\Managed\\");
1773 lstrcatA(keypath, usersid);
1774 lstrcatA(keypath, "\\Installer\\Products\\");
1775 lstrcatA(keypath, prod2_squashed);
1776
1777 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1778 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1779
1780 /* user managed product key of second product exists */
1781 lstrcpyA(product, "prod");
1782 r = MsiGetProductCodeA(component, product);
1783 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1784 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
1785
1786 RegDeleteKeyA(prodkey, "");
1787 RegCloseKey(prodkey);
1788 RegDeleteValueA(compkey, prod_squashed);
1789 RegDeleteValueA(compkey, prod2_squashed);
1790 RegDeleteKeyA(compkey, "");
1791 RegCloseKey(compkey);
1792
1793 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1794 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1795 lstrcatA(keypath, comp_squashed);
1796
1797 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1798 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1799
1800 /* local user component key exists */
1801 lstrcpyA(product, "prod");
1802 r = MsiGetProductCodeA(component, product);
1803 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1804 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1805
1806 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1807 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1808
1809 /* product value exists */
1810 lstrcpyA(product, "prod");
1811 r = MsiGetProductCodeA(component, product);
1812 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1813 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1814
1815 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1816 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1817
1818 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1819 lstrcatA(keypath, "Installer\\Managed\\");
1820 lstrcatA(keypath, usersid);
1821 lstrcatA(keypath, "\\Installer\\Products\\");
1822 lstrcatA(keypath, prod_squashed);
1823
1824 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1825 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1826
1827 /* user managed product key of first product exists */
1828 lstrcpyA(product, "prod");
1829 r = MsiGetProductCodeA(component, product);
1830 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1831 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1832
1833 RegDeleteKeyA(prodkey, "");
1834 RegCloseKey(prodkey);
1835
1836 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1837 lstrcatA(keypath, prod_squashed);
1838
1839 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1840 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1841
1842 /* user unmanaged product key exists */
1843 lstrcpyA(product, "prod");
1844 r = MsiGetProductCodeA(component, product);
1845 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1846 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1847
1848 RegDeleteKeyA(prodkey, "");
1849 RegCloseKey(prodkey);
1850
1851 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1852 lstrcatA(keypath, prod_squashed);
1853
1854 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1855 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1856
1857 /* local classes product key exists */
1858 lstrcpyA(product, "prod");
1859 r = MsiGetProductCodeA(component, product);
1860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1861 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1862
1863 RegDeleteKeyA(prodkey, "");
1864 RegCloseKey(prodkey);
1865
1866 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1867 lstrcatA(keypath, "Installer\\Managed\\");
1868 lstrcatA(keypath, usersid);
1869 lstrcatA(keypath, "\\Installer\\Products\\");
1870 lstrcatA(keypath, prod2_squashed);
1871
1872 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1873 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1874
1875 /* user managed product key of second product exists */
1876 lstrcpyA(product, "prod");
1877 r = MsiGetProductCodeA(component, product);
1878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1879 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
1880
1881 RegDeleteKeyA(prodkey, "");
1882 RegCloseKey(prodkey);
1883 RegDeleteValueA(compkey, prod_squashed);
1884 RegDeleteValueA(compkey, prod2_squashed);
1885 RegDeleteKeyA(compkey, "");
1886 RegCloseKey(compkey);
1887 }
1888
1889 static void test_MsiEnumClients(void)
1890 {
1891 HKEY compkey;
1892 CHAR prodcode[MAX_PATH];
1893 CHAR prod_squashed[MAX_PATH];
1894 CHAR prodcode2[MAX_PATH];
1895 CHAR prod2_squashed[MAX_PATH];
1896 CHAR component[MAX_PATH];
1897 CHAR comp_base85[MAX_PATH];
1898 CHAR comp_squashed[MAX_PATH];
1899 CHAR product[MAX_PATH];
1900 CHAR keypath[MAX_PATH];
1901 LPSTR usersid;
1902 LONG res;
1903 UINT r;
1904
1905 create_test_guid(prodcode, prod_squashed);
1906 create_test_guid(prodcode2, prod2_squashed);
1907 compose_base85_guid(component, comp_base85, comp_squashed);
1908 get_user_sid(&usersid);
1909
1910 /* NULL szComponent */
1911 product[0] = '\0';
1912 r = MsiEnumClientsA(NULL, 0, product);
1913 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1914 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1915
1916 /* empty szComponent */
1917 product[0] = '\0';
1918 r = MsiEnumClientsA("", 0, product);
1919 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1920 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1921
1922 /* NULL lpProductBuf */
1923 r = MsiEnumClientsA(component, 0, NULL);
1924 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1925
1926 /* all params correct, component missing */
1927 product[0] = '\0';
1928 r = MsiEnumClientsA(component, 0, product);
1929 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1930 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1931
1932 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1933 lstrcatA(keypath, "Installer\\UserData\\");
1934 lstrcatA(keypath, usersid);
1935 lstrcatA(keypath, "\\Components\\");
1936 lstrcatA(keypath, comp_squashed);
1937
1938 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1939 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1940
1941 /* user unmanaged component key exists */
1942 product[0] = '\0';
1943 r = MsiEnumClientsA(component, 0, product);
1944 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1945 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1946
1947 /* index > 0, no products exist */
1948 product[0] = '\0';
1949 r = MsiEnumClientsA(component, 1, product);
1950 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1951 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1952
1953 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1954 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1955
1956 /* product value exists */
1957 r = MsiEnumClientsA(component, 0, product);
1958 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1959 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1960
1961 /* try index 0 again */
1962 product[0] = '\0';
1963 r = MsiEnumClientsA(component, 0, product);
1964 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1965 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1966
1967 /* try index 1, second product value does not exist */
1968 product[0] = '\0';
1969 r = MsiEnumClientsA(component, 1, product);
1970 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1971 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1972
1973 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1974 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1975
1976 /* try index 1, second product value does exist */
1977 product[0] = '\0';
1978 r = MsiEnumClientsA(component, 1, product);
1979 todo_wine
1980 {
1981 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1982 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1983 }
1984
1985 /* start the enumeration over */
1986 product[0] = '\0';
1987 r = MsiEnumClientsA(component, 0, product);
1988 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1989 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
1990 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
1991
1992 /* correctly query second product */
1993 product[0] = '\0';
1994 r = MsiEnumClientsA(component, 1, product);
1995 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1996 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
1997 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
1998
1999 RegDeleteValueA(compkey, prod_squashed);
2000 RegDeleteValueA(compkey, prod2_squashed);
2001 RegDeleteKeyA(compkey, "");
2002 RegCloseKey(compkey);
2003
2004 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2005 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
2006 lstrcatA(keypath, comp_squashed);
2007
2008 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
2009 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2010
2011 /* user local component key exists */
2012 product[0] = '\0';
2013 r = MsiEnumClientsA(component, 0, product);
2014 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2015 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2016
2017 /* index > 0, no products exist */
2018 product[0] = '\0';
2019 r = MsiEnumClientsA(component, 1, product);
2020 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2021 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2022
2023 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2024 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2025
2026 /* product value exists */
2027 product[0] = '\0';
2028 r = MsiEnumClientsA(component, 0, product);
2029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2030 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2031
2032 /* try index 0 again */
2033 product[0] = '\0';
2034 r = MsiEnumClientsA(component, 0, product);
2035 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2036
2037 /* try index 1, second product value does not exist */
2038 product[0] = '\0';
2039 r = MsiEnumClientsA(component, 1, product);
2040 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2041 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2042
2043 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
2044 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2045
2046 /* try index 1, second product value does exist */
2047 product[0] = '\0';
2048 r = MsiEnumClientsA(component, 1, product);
2049 todo_wine
2050 {
2051 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2052 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2053 }
2054
2055 /* start the enumeration over */
2056 product[0] = '\0';
2057 r = MsiEnumClientsA(component, 0, product);
2058 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2059 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2060 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2061
2062 /* correctly query second product */
2063 product[0] = '\0';
2064 r = MsiEnumClientsA(component, 1, product);
2065 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2066 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2067 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2068
2069 RegDeleteValueA(compkey, prod_squashed);
2070 RegDeleteValueA(compkey, prod2_squashed);
2071 RegDeleteKeyA(compkey, "");
2072 RegCloseKey(compkey);
2073 }
2074
2075 static void get_version_info(LPSTR path, LPSTR *vercheck, LPDWORD verchecksz,
2076 LPSTR *langcheck, LPDWORD langchecksz)
2077 {
2078 LPSTR version;
2079 VS_FIXEDFILEINFO *ffi;
2080 DWORD size = GetFileVersionInfoSizeA(path, NULL);
2081 USHORT *lang;
2082
2083 version = HeapAlloc(GetProcessHeap(), 0, size);
2084 GetFileVersionInfoA(path, 0, size, version);
2085
2086 VerQueryValueA(version, "\\", (LPVOID *)&ffi, &size);
2087 *vercheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
2088 sprintf(*vercheck, "%d.%d.%d.%d", HIWORD(ffi->dwFileVersionMS),
2089 LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionLS),
2090 LOWORD(ffi->dwFileVersionLS));
2091 *verchecksz = lstrlenA(*vercheck);
2092
2093 VerQueryValue(version, "\\VarFileInfo\\Translation", (void **)&lang, &size);
2094 *langcheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
2095 sprintf(*langcheck, "%d", *lang);
2096 *langchecksz = lstrlenA(*langcheck);
2097
2098 HeapFree(GetProcessHeap(), 0, version);
2099 }
2100
2101 static void test_MsiGetFileVersion(void)
2102 {
2103 UINT r;
2104 DWORD versz, langsz;
2105 char version[MAX_PATH];
2106 char lang[MAX_PATH];
2107 char path[MAX_PATH];
2108 LPSTR vercheck, langcheck;
2109 DWORD verchecksz, langchecksz;
2110
2111 /* NULL szFilePath */
2112 versz = MAX_PATH;
2113 langsz = MAX_PATH;
2114 lstrcpyA(version, "version");
2115 lstrcpyA(lang, "lang");
2116 r = MsiGetFileVersionA(NULL, version, &versz, lang, &langsz);
2117 ok(r == ERROR_INVALID_PARAMETER,
2118 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2119 ok(!lstrcmpA(version, "version"),
2120 "Expected version to be unchanged, got %s\n", version);
2121 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2122 ok(!lstrcmpA(lang, "lang"),
2123 "Expected lang to be unchanged, got %s\n", lang);
2124 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2125
2126 /* empty szFilePath */
2127 versz = MAX_PATH;
2128 langsz = MAX_PATH;
2129 lstrcpyA(version, "version");
2130 lstrcpyA(lang, "lang");
2131 r = MsiGetFileVersionA("", version, &versz, lang, &langsz);
2132 ok(r == ERROR_FILE_NOT_FOUND,
2133 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2134 ok(!lstrcmpA(version, "version"),
2135 "Expected version to be unchanged, got %s\n", version);
2136 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2137 ok(!lstrcmpA(lang, "lang"),
2138 "Expected lang to be unchanged, got %s\n", lang);
2139 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2140
2141 /* nonexistent szFilePath */
2142 versz = MAX_PATH;
2143 langsz = MAX_PATH;
2144 lstrcpyA(version, "version");
2145 lstrcpyA(lang, "lang");
2146 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2147 ok(r == ERROR_FILE_NOT_FOUND,
2148 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2149 ok(!lstrcmpA(version, "version"),
2150 "Expected version to be unchanged, got %s\n", version);
2151 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2152 ok(!lstrcmpA(lang, "lang"),
2153 "Expected lang to be unchanged, got %s\n", lang);
2154 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2155
2156 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
2157 versz = MAX_PATH;
2158 langsz = MAX_PATH;
2159 lstrcpyA(version, "version");
2160 lstrcpyA(lang, "lang");
2161 r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz);
2162 ok(r == ERROR_INVALID_PARAMETER,
2163 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2164 ok(!lstrcmpA(version, "version"),
2165 "Expected version to be unchanged, got %s\n", version);
2166 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2167 ok(!lstrcmpA(lang, "lang"),
2168 "Expected lang to be unchanged, got %s\n", lang);
2169 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2170
2171 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
2172 versz = MAX_PATH;
2173 langsz = MAX_PATH;
2174 lstrcpyA(version, "version");
2175 lstrcpyA(lang, "lang");
2176 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL);
2177 ok(r == ERROR_INVALID_PARAMETER,
2178 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2179 ok(!lstrcmpA(version, "version"),
2180 "Expected version to be unchanged, got %s\n", version);
2181 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2182 ok(!lstrcmpA(lang, "lang"),
2183 "Expected lang to be unchanged, got %s\n", lang);
2184 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2185
2186 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
2187 versz = 0;
2188 langsz = MAX_PATH;
2189 lstrcpyA(version, "version");
2190 lstrcpyA(lang, "lang");
2191 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2192 ok(r == ERROR_FILE_NOT_FOUND,
2193 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2194 ok(!lstrcmpA(version, "version"),
2195 "Expected version to be unchanged, got %s\n", version);
2196 ok(versz == 0, "Expected 0, got %d\n", versz);
2197 ok(!lstrcmpA(lang, "lang"),
2198 "Expected lang to be unchanged, got %s\n", lang);
2199 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2200
2201 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
2202 versz = MAX_PATH;
2203 langsz = 0;
2204 lstrcpyA(version, "version");
2205 lstrcpyA(lang, "lang");
2206 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2207 ok(r == ERROR_FILE_NOT_FOUND,
2208 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2209 ok(!lstrcmpA(version, "version"),
2210 "Expected version to be unchanged, got %s\n", version);
2211 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2212 ok(!lstrcmpA(lang, "lang"),
2213 "Expected lang to be unchanged, got %s\n", lang);
2214 ok(langsz == 0, "Expected 0, got %d\n", langsz);
2215
2216 /* nonexistent szFilePath, rest NULL */
2217 r = MsiGetFileVersionA("nonexistent", NULL, NULL, NULL, NULL);
2218 ok(r == ERROR_FILE_NOT_FOUND,
2219 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2220
2221 create_file("ver.txt", "ver.txt", 20);
2222
2223 /* file exists, no version information */
2224 versz = MAX_PATH;
2225 langsz = MAX_PATH;
2226 lstrcpyA(version, "version");
2227 lstrcpyA(lang, "lang");
2228 r = MsiGetFileVersionA("ver.txt", version, &versz, lang, &langsz);
2229 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2230 ok(!lstrcmpA(version, "version"),
2231 "Expected version to be unchanged, got %s\n", version);
2232 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2233 ok(!lstrcmpA(lang, "lang"),
2234 "Expected lang to be unchanged, got %s\n", lang);
2235 ok(r == ERROR_FILE_INVALID,
2236 "Expected ERROR_FILE_INVALID, got %d\n", r);
2237
2238 DeleteFileA("ver.txt");
2239
2240 /* relative path, has version information */
2241 versz = MAX_PATH;
2242 langsz = MAX_PATH;
2243 lstrcpyA(version, "version");
2244 lstrcpyA(lang, "lang");
2245 r = MsiGetFileVersionA("kernel32.dll", version, &versz, lang, &langsz);
2246 todo_wine
2247 {
2248 ok(r == ERROR_FILE_NOT_FOUND,
2249 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2250 ok(!lstrcmpA(version, "version"),
2251 "Expected version to be unchanged, got %s\n", version);
2252 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2253 ok(!lstrcmpA(lang, "lang"),
2254 "Expected lang to be unchanged, got %s\n", lang);
2255 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2256 }
2257
2258 GetSystemDirectoryA(path, MAX_PATH);
2259 lstrcatA(path, "\\kernel32.dll");
2260
2261 get_version_info(path, &vercheck, &verchecksz, &langcheck, &langchecksz);
2262
2263 /* absolute path, has version information */
2264 versz = MAX_PATH;
2265 langsz = MAX_PATH;
2266 lstrcpyA(version, "version");
2267 lstrcpyA(lang, "lang");
2268 r = MsiGetFileVersionA(path, version, &versz, lang, &langsz);
2269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2270 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2271 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
2272 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2273 ok(!lstrcmpA(version, vercheck),
2274 "Expected %s, got %s\n", vercheck, version);
2275
2276 /* only check version */
2277 versz = MAX_PATH;
2278 lstrcpyA(version, "version");
2279 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
2280 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2281 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2282 ok(!lstrcmpA(version, vercheck),
2283 "Expected %s, got %s\n", vercheck, version);
2284
2285 /* only check language */
2286 langsz = MAX_PATH;
2287 lstrcpyA(lang, "lang");
2288 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2289 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2290 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
2291 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2292
2293 /* check neither version nor language */
2294 r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
2295 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2296
2297 /* get pcchVersionBuf */
2298 versz = MAX_PATH;
2299 r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL);
2300 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2301 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2302
2303 /* get pcchLangBuf */
2304 langsz = MAX_PATH;
2305 r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
2306 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2307 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2308
2309 /* pcchVersionBuf not big enough */
2310 versz = 5;
2311 lstrcpyA(version, "version");
2312 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
2313 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2314 ok(!strncmp(version, vercheck, 4),
2315 "Expected first 4 characters of %s, got %s\n", vercheck, version);
2316 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2317
2318 /* pcchLangBuf not big enough */
2319 langsz = 3;
2320 lstrcpyA(lang, "lang");
2321 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2322 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2323 ok(!strncmp(lang, langcheck, 2),
2324 "Expected first character of %s, got %s\n", langcheck, lang);
2325 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2326
2327 HeapFree(GetProcessHeap(), 0, vercheck);
2328 HeapFree(GetProcessHeap(), 0, langcheck);
2329 }
2330
2331 static void test_MsiGetProductInfo(void)
2332 {
2333 UINT r;
2334 LONG res;
2335 HKEY propkey, source;
2336 HKEY prodkey, localkey;
2337 CHAR prodcode[MAX_PATH];
2338 CHAR prod_squashed[MAX_PATH];
2339 CHAR packcode[MAX_PATH];
2340 CHAR pack_squashed[MAX_PATH];
2341 CHAR buf[MAX_PATH];
2342 CHAR keypath[MAX_PATH];
2343 LPSTR usersid;
2344 DWORD sz, val = 42;
2345
2346 create_test_guid(prodcode, prod_squashed);
2347 create_test_guid(packcode, pack_squashed);
2348 get_user_sid(&usersid);
2349
2350 /* NULL szProduct */
2351 sz = MAX_PATH;
2352 lstrcpyA(buf, "apple");
2353 r = MsiGetProductInfoA(NULL, INSTALLPROPERTY_HELPLINK, buf, &sz);
2354 ok(r == ERROR_INVALID_PARAMETER,
2355 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2356 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2357 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2358
2359 /* empty szProduct */
2360 sz = MAX_PATH;
2361 lstrcpyA(buf, "apple");
2362 r = MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINK, buf, &sz);
2363 ok(r == ERROR_INVALID_PARAMETER,
2364 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2365 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2366 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2367
2368 /* garbage szProduct */
2369 sz = MAX_PATH;
2370 lstrcpyA(buf, "apple");
2371 r = MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINK, buf, &sz);
2372 ok(r == ERROR_INVALID_PARAMETER,
2373 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2374 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2375 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2376
2377 /* guid without brackets */
2378 sz = MAX_PATH;
2379 lstrcpyA(buf, "apple");
2380 r = MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
2381 INSTALLPROPERTY_HELPLINK, buf, &sz);
2382 ok(r == ERROR_INVALID_PARAMETER,
2383 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2384 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2385 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2386
2387 /* guid with brackets */
2388 sz = MAX_PATH;
2389 lstrcpyA(buf, "apple");
2390 r = MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
2391 INSTALLPROPERTY_HELPLINK, buf, &sz);
2392 ok(r == ERROR_UNKNOWN_PRODUCT,
2393 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2394 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2395 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2396
2397 /* same length as guid, but random */
2398 sz = MAX_PATH;
2399 lstrcpyA(buf, "apple");
2400 r = MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
2401 INSTALLPROPERTY_HELPLINK, buf, &sz);
2402 ok(r == ERROR_INVALID_PARAMETER,
2403 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2404 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2405 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2406
2407 /* not installed, NULL szAttribute */
2408 sz = MAX_PATH;
2409 lstrcpyA(buf, "apple");
2410 r = MsiGetProductInfoA(prodcode, NULL, buf, &sz);
2411 ok(r == ERROR_INVALID_PARAMETER,
2412 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2413 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2414 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2415
2416 /* not installed, NULL lpValueBuf */
2417 sz = MAX_PATH;
2418 lstrcpyA(buf, "apple");
2419 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2420 ok(r == ERROR_UNKNOWN_PRODUCT,
2421 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2422 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2423 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2424
2425 /* not installed, NULL pcchValueBuf */
2426 sz = MAX_PATH;
2427 lstrcpyA(buf, "apple");
2428 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, NULL);
2429 ok(r == ERROR_INVALID_PARAMETER,
2430 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2431 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2432 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2433
2434 /* created guid cannot possibly be an installed product code */
2435 sz = MAX_PATH;
2436 lstrcpyA(buf, "apple");
2437 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2438 ok(r == ERROR_UNKNOWN_PRODUCT,
2439 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2440 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2441 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2442
2443 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2444 lstrcatA(keypath, usersid);
2445 lstrcatA(keypath, "\\Installer\\Products\\");
2446 lstrcatA(keypath, prod_squashed);
2447
2448 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2449 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2450
2451 /* managed product code exists */
2452 sz = MAX_PATH;
2453 lstrcpyA(buf, "apple");
2454 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2455 ok(r == ERROR_UNKNOWN_PROPERTY,
2456 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2457 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2458 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2459
2460 RegDeleteKeyA(prodkey, "");
2461 RegCloseKey(prodkey);
2462
2463 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2464 lstrcatA(keypath, usersid);
2465 lstrcatA(keypath, "\\Products\\");
2466 lstrcatA(keypath, prod_squashed);
2467
2468 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2469 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2470
2471 /* local user product code exists */
2472 sz = MAX_PATH;
2473 lstrcpyA(buf, "apple");
2474 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2475 ok(r == ERROR_UNKNOWN_PRODUCT,
2476 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2477 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2478 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2479
2480 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2481 lstrcatA(keypath, usersid);
2482 lstrcatA(keypath, "\\Installer\\Products\\");
2483 lstrcatA(keypath, prod_squashed);
2484
2485 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2486 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2487
2488 /* both local and managed product code exist */
2489 sz = MAX_PATH;
2490 lstrcpyA(buf, "apple");
2491 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2492 ok(r == ERROR_UNKNOWN_PROPERTY,
2493 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2494 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2495 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2496
2497 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2498 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2499
2500 /* InstallProperties key exists */
2501 sz = MAX_PATH;
2502 lstrcpyA(buf, "apple");
2503 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2504 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2505 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2506 ok(sz == 0, "Expected 0, got %d\n", sz);
2507
2508 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2509 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2510
2511 /* HelpLink value exists */
2512 sz = MAX_PATH;
2513 lstrcpyA(buf, "apple");
2514 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2515 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2516 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2517 ok(sz == 4, "Expected 4, got %d\n", sz);
2518
2519 /* pcchBuf is NULL */
2520 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, NULL);
2521 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2522
2523 /* lpValueBuf is NULL */
2524 sz = MAX_PATH;
2525 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2526 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2527 ok(sz == 4, "Expected 4, got %d\n", sz);
2528
2529 /* lpValueBuf is NULL, pcchValueBuf is too small */
2530 sz = 2;
2531 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2532 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2533 ok(sz == 4, "Expected 4, got %d\n", sz);
2534
2535 /* lpValueBuf is NULL, pcchValueBuf is too small */
2536 sz = 2;
2537 lstrcpyA(buf, "apple");
2538 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2539 ok(!lstrcmpA(buf, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf);
2540 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2541 ok(sz == 4, "Expected 4, got %d\n", sz);
2542
2543 /* lpValueBuf is NULL, pcchValueBuf is exactly 4 */
2544 sz = 4;
2545 lstrcpyA(buf, "apple");
2546 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2547 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2548 ok(!lstrcmpA(buf, "apple"),
2549 "Expected buf to remain unchanged, got \"%s\"\n", buf);
2550 ok(sz == 4, "Expected 4, got %d\n", sz);
2551
2552 res = RegSetValueExA(propkey, "IMadeThis", 0, REG_SZ, (LPBYTE)"random", 7);
2553 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2554
2555 /* random property not supported by MSI, value exists */
2556 sz = MAX_PATH;
2557 lstrcpyA(buf, "apple");
2558 r = MsiGetProductInfoA(prodcode, "IMadeThis", buf, &sz);
2559 ok(r == ERROR_UNKNOWN_PROPERTY,
2560 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2561 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2562 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2563
2564 RegDeleteValueA(propkey, "IMadeThis");
2565 RegDeleteValueA(propkey, "HelpLink");
2566 RegDeleteKeyA(propkey, "");
2567 RegDeleteKeyA(localkey, "");
2568 RegDeleteKeyA(prodkey, "");
2569 RegCloseKey(propkey);
2570 RegCloseKey(localkey);
2571 RegCloseKey(prodkey);
2572
2573 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2574 lstrcatA(keypath, prod_squashed);
2575
2576 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2577 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2578
2579 /* user product key exists */
2580 sz = MAX_PATH;
2581 lstrcpyA(buf, "apple");
2582 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2583 ok(r == ERROR_UNKNOWN_PROPERTY,
2584 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2585 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2586 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2587
2588 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2589 lstrcatA(keypath, usersid);
2590 lstrcatA(keypath, "\\Products\\");
2591 lstrcatA(keypath, prod_squashed);
2592
2593 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2594 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2595
2596 /* local user product key exists */
2597 sz = MAX_PATH;
2598 lstrcpyA(buf, "apple");
2599 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2600 ok(r == ERROR_UNKNOWN_PROPERTY,
2601 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2602 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2603 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2604
2605 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2606 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2607
2608 /* InstallProperties key exists */
2609 sz = MAX_PATH;
2610 lstrcpyA(buf, "apple");
2611 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2612 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2613 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2614 ok(sz == 0, "Expected 0, got %d\n", sz);
2615
2616 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2617 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2618
2619 /* HelpLink value exists */
2620 sz = MAX_PATH;
2621 lstrcpyA(buf, "apple");
2622 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2623 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2624 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2625 ok(sz == 4, "Expected 4, got %d\n", sz);
2626
2627 RegDeleteValueA(propkey, "HelpLink");
2628 RegDeleteKeyA(propkey, "");
2629 RegDeleteKeyA(localkey, "");
2630 RegDeleteKeyA(prodkey, "");
2631 RegCloseKey(propkey);
2632 RegCloseKey(localkey);
2633 RegCloseKey(prodkey);
2634
2635 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2636 lstrcatA(keypath, prod_squashed);
2637
2638 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2639 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2640
2641 /* classes product key exists */
2642 sz = MAX_PATH;
2643 lstrcpyA(buf, "apple");
2644 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2645 ok(r == ERROR_UNKNOWN_PROPERTY,
2646 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2647 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2648 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2649
2650 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2651 lstrcatA(keypath, usersid);
2652 lstrcatA(keypath, "\\Products\\");
2653 lstrcatA(keypath, prod_squashed);
2654
2655 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2656 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2657
2658 /* local user product key exists */
2659 sz = MAX_PATH;
2660 lstrcpyA(buf, "apple");
2661 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2662 ok(r == ERROR_UNKNOWN_PROPERTY,
2663 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2664 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2665 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2666
2667 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2668 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2669
2670 /* InstallProperties key exists */
2671 sz = MAX_PATH;
2672 lstrcpyA(buf, "apple");
2673 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2674 ok(r == ERROR_UNKNOWN_PROPERTY,
2675 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2676 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2677 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2678
2679 RegDeleteKeyA(propkey, "");
2680 RegDeleteKeyA(localkey, "");
2681 RegCloseKey(propkey);
2682 RegCloseKey(localkey);
2683
2684 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2685 lstrcatA(keypath, "S-1-5-18\\\\Products\\");
2686 lstrcatA(keypath, prod_squashed);
2687
2688 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2689 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2690
2691 /* Local System product key exists */
2692 sz = MAX_PATH;
2693 lstrcpyA(buf, "apple");
2694 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2695 ok(r == ERROR_UNKNOWN_PROPERTY,
2696 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2697 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2698 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2699
2700 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2701 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2702
2703 /* InstallProperties key exists */
2704 sz = MAX_PATH;
2705 lstrcpyA(buf, "apple");
2706 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2707 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2708 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2709 ok(sz == 0, "Expected 0, got %d\n", sz);
2710
2711 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2712 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2713
2714 /* HelpLink value exists */
2715 sz = MAX_PATH;
2716 lstrcpyA(buf, "apple");
2717 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2718 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2719 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2720 ok(sz == 4, "Expected 4, got %d\n", sz);
2721
2722 res = RegSetValueExA(propkey, "HelpLink", 0, REG_DWORD,
2723 (const BYTE *)&val, sizeof(DWORD));
2724 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2725
2726 /* HelpLink type is REG_DWORD */
2727 sz = MAX_PATH;
2728 lstrcpyA(buf, "apple");
2729 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2731 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2732 ok(sz == 2, "Expected 2, got %d\n", sz);
2733
2734 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
2735 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2736
2737 /* DisplayName value exists */
2738 sz = MAX_PATH;
2739 lstrcpyA(buf, "apple");
2740 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
2741 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2742 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
2743 ok(sz == 4, "Expected 4, got %d\n", sz);
2744
2745 res = RegSetValueExA(propkey, "DisplayName", 0, REG_DWORD,
2746 (const BYTE *)&val, sizeof(DWORD));
2747 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2748
2749 /* DisplayName type is REG_DWORD */
2750 sz = MAX_PATH;
2751 lstrcpyA(buf, "apple");
2752 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
2753 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2754 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2755 ok(sz == 2, "Expected 2, got %d\n", sz);
2756
2757 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"1.1.1", 6);
2758 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2759
2760 /* DisplayVersion value exists */
2761 sz = MAX_PATH;
2762 lstrcpyA(buf, "apple");
2763 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
2764 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2765 ok(!lstrcmpA(buf, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf);
2766 ok(sz == 5, "Expected 5, got %d\n", sz);
2767
2768 res = RegSetValueExA(propkey, "DisplayVersion", 0,
2769 REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
2770 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2771
2772 /* DisplayVersion type is REG_DWORD */
2773 sz = MAX_PATH;
2774 lstrcpyA(buf, "apple");
2775 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
2776 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2777 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2778 ok(sz == 2, "Expected 2, got %d\n", sz);
2779
2780 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"tele", 5);
2781 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2782
2783 /* HelpTelephone value exists */
2784 sz = MAX_PATH;
2785 lstrcpyA(buf, "apple");
2786 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
2787 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2788 ok(!lstrcmpA(buf, "tele"), "Expected \"tele\", got \"%s\"\n", buf);
2789 ok(sz == 4, "Expected 4, got %d\n", sz);
2790
2791 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_DWORD,
2792 (const BYTE *)&val, sizeof(DWORD));
2793 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2794
2795 /* HelpTelephone type is REG_DWORD */
2796 sz = MAX_PATH;
2797 lstrcpyA(buf, "apple");
2798 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
2799 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2800 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2801 ok(sz == 2, "Expected 2, got %d\n", sz);
2802
2803 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
2804 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2805
2806 /* InstallLocation value exists */
2807 sz = MAX_PATH;
2808 lstrcpyA(buf, "apple");
2809 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
2810 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2811 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
2812 ok(sz == 3, "Expected 3, got %d\n", sz);
2813
2814 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_DWORD,
2815 (const BYTE *)&val, sizeof(DWORD));
2816 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2817
2818 /* InstallLocation type is REG_DWORD */
2819 sz = MAX_PATH;
2820 lstrcpyA(buf, "apple");
2821 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
2822 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2823 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2824 ok(sz == 2, "Expected 2, got %d\n", sz);
2825
2826 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
2827 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2828
2829 /* InstallSource value exists */
2830 sz = MAX_PATH;
2831 lstrcpyA(buf, "apple");
2832 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
2833 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2834 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
2835 ok(sz == 6, "Expected 6, got %d\n", sz);
2836
2837 res = RegSetValueExA(propkey, "InstallSource", 0, REG_DWORD,
2838 (const BYTE *)&val, sizeof(DWORD));
2839 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2840
2841 /* InstallSource type is REG_DWORD */
2842 sz = MAX_PATH;
2843 lstrcpyA(buf, "apple");
2844 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
2845 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2846 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2847 ok(sz == 2, "Expected 2, got %d\n", sz);
2848
2849 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
2850 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2851
2852 /* InstallDate value exists */
2853 sz = MAX_PATH;
2854 lstrcpyA(buf, "apple");
2855 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATE, buf, &sz);
2856 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2857 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
2858 ok(sz == 4, "Expected 4, got %d\n", sz);
2859
2860 res = RegSetValueExA(propkey, "InstallDate", 0, REG_DWORD,
2861 (const BYTE *)&val, sizeof(DWORD));
2862 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2863
2864 /* InstallDate type is REG_DWORD */
2865 sz = MAX_PATH;
2866 lstrcpyA(buf, "apple");
2867 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATE, buf, &sz);
2868 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2869 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2870 ok(sz == 2, "Expected 2, got %d\n", sz);
2871
2872 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
2873 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2874
2875 /* Publisher value exists */
2876 sz = MAX_PATH;
2877 lstrcpyA(buf, "apple");
2878 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHER, buf, &sz);
2879 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2880 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
2881 ok(sz == 3, "Expected 3, got %d\n", sz);
2882
2883 res = RegSetValueExA(propkey, "Publisher", 0, REG_DWORD,
2884 (const BYTE *)&val, sizeof(DWORD));
2885 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2886
2887 /* Publisher type is REG_DWORD */
2888 sz = MAX_PATH;
2889 lstrcpyA(buf, "apple");
2890 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHER, buf, &sz);
2891 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2892 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2893 ok(sz == 2, "Expected 2, got %d\n", sz);
2894
2895 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"pack", 5);
2896 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2897
2898 /* LocalPackage value exists */
2899 sz = MAX_PATH;
2900 lstrcpyA(buf, "apple");
2901 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
2902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2903 ok(!lstrcmpA(buf, "pack"), "Expected \"pack\", got \"%s\"\n", buf);
2904 ok(sz == 4, "Expected 4, got %d\n", sz);
2905
2906 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_DWORD,
2907 (const BYTE *)&val, sizeof(DWORD));
2908 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2909
2910 /* LocalPackage type is REG_DWORD */
2911 sz = MAX_PATH;
2912 lstrcpyA(buf, "apple");
2913 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
2914 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2915 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2916 ok(sz == 2, "Expected 2, got %d\n", sz);
2917
2918 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
2919 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2920
2921 /* UrlInfoAbout value exists */
2922 sz = MAX_PATH;
2923 lstrcpyA(buf, "apple");
2924 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
2925 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2926 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
2927 ok(sz == 5, "Expected 5, got %d\n", sz);
2928
2929 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_DWORD,
2930 (const BYTE *)&val, sizeof(DWORD));
2931 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2932
2933 /* UrlInfoAbout type is REG_DWORD */
2934 sz = MAX_PATH;
2935 lstrcpyA(buf, "apple");
2936 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
2937 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2938 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2939 ok(sz == 2, "Expected 2, got %d\n", sz);
2940
2941 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_SZ, (LPBYTE)"info", 5);
2942 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2943
2944 /* UrlUpdateInfo value exists */
2945 sz = MAX_PATH;
2946 lstrcpyA(buf, "apple");
2947 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
2948 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2949 ok(!lstrcmpA(buf, "info"), "Expected \"info\", got \"%s\"\n", buf);
2950 ok(sz == 4, "Expected 4, got %d\n", sz);
2951
2952 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_DWORD,
2953 (const BYTE *)&val, sizeof(DWORD));
2954 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2955
2956 /* UrlUpdateInfo type is REG_DWORD */
2957 sz = MAX_PATH;
2958 lstrcpyA(buf, "apple");
2959 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
2960 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2961 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2962 ok(sz == 2, "Expected 2, got %d\n", sz);
2963
2964 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"1", 2);
2965 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2966
2967 /* VersionMinor value exists */
2968 sz = MAX_PATH;
2969 lstrcpyA(buf, "apple");
2970 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
2971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2972 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
2973 ok(sz == 1, "Expected 1, got %d\n", sz);
2974
2975 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_DWORD,
2976 (const BYTE *)&val, sizeof(DWORD));
2977 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2978
2979 /* VersionMinor type is REG_DWORD */
2980 sz = MAX_PATH;
2981 lstrcpyA(buf, "apple");
2982 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
2983 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2984 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2985 ok(sz == 2, "Expected 2, got %d\n", sz);
2986
2987 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"1", 2);
2988 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2989
2990 /* VersionMajor value exists */
2991 sz = MAX_PATH;
2992 lstrcpyA(buf, "apple");
2993 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
2994 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2995 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
2996 ok(sz == 1, "Expected 1, got %d\n", sz);
2997
2998 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_DWORD,
2999 (const BYTE *)&val, sizeof(DWORD));
3000 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3001
3002 /* VersionMajor type is REG_DWORD */
3003 sz = MAX_PATH;
3004 lstrcpyA(buf, "apple");
3005 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
3006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3007 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3008 ok(sz == 2, "Expected 2, got %d\n", sz);
3009
3010 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
3011 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3012
3013 /* ProductID value exists */
3014 sz = MAX_PATH;
3015 lstrcpyA(buf, "apple");
3016 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTID, buf, &sz);
3017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3018 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
3019 ok(sz == 2, "Expected 2, got %d\n", sz);
3020
3021 res = RegSetValueExA(propkey, "ProductID", 0, REG_DWORD,
3022 (const BYTE *)&val, sizeof(DWORD));
3023 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3024
3025 /* ProductID type is REG_DWORD */
3026 sz = MAX_PATH;
3027 lstrcpyA(buf, "apple");
3028 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTID, buf, &sz);
3029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3030 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3031 ok(sz == 2, "Expected 2, got %d\n", sz);
3032
3033 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
3034 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3035
3036 /* RegCompany value exists */
3037 sz = MAX_PATH;
3038 lstrcpyA(buf, "apple");
3039 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANY, buf, &sz);
3040 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3041 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
3042 ok(sz == 4, "Expected 4, got %d\n", sz);
3043
3044 res = RegSetValueExA(propkey, "RegCompany", 0, REG_DWORD,
3045 (const BYTE *)&val, sizeof(DWORD));
3046 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3047
3048 /* RegCompany type is REG_DWORD */
3049 sz = MAX_PATH;
3050 lstrcpyA(buf, "apple");
3051 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANY, buf, &sz);
3052 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3053 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3054 ok(sz == 2, "Expected 2, got %d\n", sz);
3055
3056 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"own", 4);
3057 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3058
3059 /* RegOwner value exists */
3060 sz = MAX_PATH;
3061 lstrcpyA(buf, "apple");
3062 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNER, buf, &sz);
3063 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3064 ok(!lstrcmpA(buf, "own"), "Expected \"own\", got \"%s\"\n", buf);
3065 ok(sz == 3, "Expected 3, got %d\n", sz);
3066
3067 res = RegSetValueExA(propkey, "RegOwner", 0, REG_DWORD,
3068 (const BYTE *)&val, sizeof(DWORD));
3069 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3070
3071 /* RegOwner type is REG_DWORD */
3072 sz = MAX_PATH;
3073 lstrcpyA(buf, "apple");
3074 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNER, buf, &sz);
3075 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3076 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3077 ok(sz == 2, "Expected 2, got %d\n", sz);
3078
3079 res = RegSetValueExA(propkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
3080 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3081
3082 /* InstanceType value exists */
3083 sz = MAX_PATH;
3084 lstrcpyA(buf, "apple");
3085 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3086 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3087 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3088 ok(sz == 0, "Expected 0, got %d\n", sz);
3089
3090 res = RegSetValueExA(propkey, "InstanceType", 0, REG_DWORD,
3091 (const BYTE *)&val, sizeof(DWORD));
3092 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3093
3094 /* InstanceType type is REG_DWORD */
3095 sz = MAX_PATH;
3096 lstrcpyA(buf, "apple");
3097 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3098 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3099 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3100 ok(sz == 0, "Expected 0, got %d\n", sz);
3101
3102 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
3103 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3104
3105 /* InstanceType value exists */
3106 sz = MAX_PATH;
3107 lstrcpyA(buf, "apple");
3108 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3109 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3110 ok(!lstrcmpA(buf, "type"), "Expected \"type\", got \"%s\"\n", buf);
3111 ok(sz == 4, "Expected 4, got %d\n", sz);
3112
3113 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_DWORD,
3114 (const BYTE *)&val, sizeof(DWORD));
3115 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3116
3117 /* InstanceType type is REG_DWORD */
3118 sz = MAX_PATH;
3119 lstrcpyA(buf, "apple");
3120 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3121 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3122 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3123 ok(sz == 2, "Expected 2, got %d\n", sz);
3124
3125 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
3126 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3127
3128 /* Transforms value exists */
3129 sz = MAX_PATH;
3130 lstrcpyA(buf, "apple");
3131 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3132 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3133 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3134 ok(sz == 0, "Expected 0, got %d\n", sz);
3135
3136 res = RegSetValueExA(propkey, "Transforms", 0, REG_DWORD,
3137 (const BYTE *)&val, sizeof(DWORD));
3138 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3139
3140 /* Transforms type is REG_DWORD */
3141 sz = MAX_PATH;
3142 lstrcpyA(buf, "apple");
3143 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3144 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3145 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3146 ok(sz == 0, "Expected 0, got %d\n", sz);
3147
3148 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
3149 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3150
3151 /* Transforms value exists */
3152 sz = MAX_PATH;
3153 lstrcpyA(buf, "apple");
3154 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3155 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3156 ok(!lstrcmpA(buf, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf);
3157 ok(sz == 6, "Expected 6, got %d\n", sz);
3158
3159 res = RegSetValueExA(prodkey, "Transforms", 0, REG_DWORD,
3160 (const BYTE *)&val, sizeof(DWORD));
3161 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3162
3163 /* Transforms type is REG_DWORD */
3164 sz = MAX_PATH;
3165 lstrcpyA(buf, "apple");
3166 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3168 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3169 ok(sz == 2, "Expected 2, got %d\n", sz);
3170
3171 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
3172 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3173
3174 /* Language value exists */
3175 sz = MAX_PATH;
3176 lstrcpyA(buf, "apple");
3177 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3178 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3179 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3180 ok(sz == 0, "Expected 0, got %d\n", sz);
3181
3182 res = RegSetValueExA(propkey, "Language", 0, REG_DWORD,
3183 (const BYTE *)&val, sizeof(DWORD));
3184 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3185
3186 /* Language type is REG_DWORD */
3187 sz = MAX_PATH;
3188 lstrcpyA(buf, "apple");
3189 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3190 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3191 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3192 ok(sz == 0, "Expected 0, got %d\n", sz);
3193
3194 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
3195 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3196
3197 /* Language value exists */
3198 sz = MAX_PATH;
3199 lstrcpyA(buf, "apple");
3200 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3201 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3202 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
3203 ok(sz == 4, "Expected 4, got %d\n", sz);
3204
3205 res = RegSetValueExA(prodkey, "Language", 0, REG_DWORD,
3206 (const BYTE *)&val, sizeof(DWORD));
3207 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3208
3209 /* Language type is REG_DWORD */
3210 sz = MAX_PATH;
3211 lstrcpyA(buf, "apple");
3212 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3213 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3214 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3215 ok(sz == 2, "Expected 2, got %d\n", sz);
3216
3217 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
3218 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3219
3220 /* ProductName value exists */
3221 sz = MAX_PATH;
3222 lstrcpyA(buf, "apple");
3223 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3224 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3225 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3226 ok(sz == 0, "Expected 0, got %d\n", sz);
3227
3228 res = RegSetValueExA(propkey, "ProductName", 0, REG_DWORD,
3229 (const BYTE *)&val, sizeof(DWORD));
3230 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3231
3232 /* ProductName type is REG_DWORD */
3233 sz = MAX_PATH;
3234 lstrcpyA(buf, "apple");
3235 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3237 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3238 ok(sz == 0, "Expected 0, got %d\n", sz);
3239
3240 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
3241 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3242
3243 /* ProductName value exists */
3244 sz = MAX_PATH;
3245 lstrcpyA(buf, "apple");
3246 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3248 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
3249 ok(sz == 4, "Expected 4, got %d\n", sz);
3250
3251 res = RegSetValueExA(prodkey, "ProductName", 0, REG_DWORD,
3252 (const BYTE *)&val, sizeof(DWORD));
3253 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3254
3255 /* ProductName type is REG_DWORD */
3256 sz = MAX_PATH;
3257 lstrcpyA(buf, "apple");
3258 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3260 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3261 ok(sz == 2, "Expected 2, got %d\n", sz);
3262
3263 res = RegSetValueExA(propkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
3264 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3265
3266 /* Assignment value exists */
3267 sz = MAX_PATH;
3268 lstrcpyA(buf, "apple");
3269 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3270 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3271 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3272 ok(sz == 0, "Expected 0, got %d\n", sz);
3273
3274 res = RegSetValueExA(propkey, "Assignment", 0, REG_DWORD,
3275 (const BYTE *)&val, sizeof(DWORD));
3276 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3277
3278 /* Assignment type is REG_DWORD */
3279 sz = MAX_PATH;
3280 lstrcpyA(buf, "apple");
3281 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3282 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3283 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3284 ok(sz == 0, "Expected 0, got %d\n", sz);
3285
3286 res = RegSetValueExA(prodkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
3287 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3288
3289 /* Assignment value exists */
3290 sz = MAX_PATH;
3291 lstrcpyA(buf, "apple");
3292 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3294 ok(!lstrcmpA(buf, "at"), "Expected \"at\", got \"%s\"\n", buf);
3295 ok(sz == 2, "Expected 2, got %d\n", sz);
3296
3297 res = RegSetValueExA(prodkey, "Assignment", 0, REG_DWORD,
3298 (const BYTE *)&val, sizeof(DWORD));
3299 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3300
3301 /* Assignment type is REG_DWORD */
3302 sz = MAX_PATH;
3303 lstrcpyA(buf, "apple");
3304 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3305 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3306 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3307 ok(sz == 2, "Expected 2, got %d\n", sz);
3308
3309 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
3310 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3311
3312 /* PackageCode value exists */
3313 sz = MAX_PATH;
3314 lstrcpyA(buf, "apple");
3315 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3317 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3318 ok(sz == 0, "Expected 0, got %d\n", sz);
3319
3320 res = RegSetValueExA(propkey, "PackageCode", 0, REG_DWORD,
3321 (const BYTE *)&val, sizeof(DWORD));
3322 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3323
3324 /* PackageCode type is REG_DWORD */
3325 sz = MAX_PATH;
3326 lstrcpyA(buf, "apple");
3327 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3328 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3329 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3330 ok(sz == 0, "Expected 0, got %d\n", sz);
3331
3332 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
3333 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3334
3335 /* PackageCode value exists */
3336 sz = MAX_PATH;
3337 lstrcpyA(buf, "apple");
3338 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3339 ok(r == ERROR_BAD_CONFIGURATION,
3340 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3341 ok(!lstrcmpA(buf, "code"), "Expected \"code\", got \"%s\"\n", buf);
3342 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3343
3344 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_DWORD,
3345 (const BYTE *)&val, sizeof(DWORD));
3346 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3347
3348 /* PackageCode type is REG_DWORD */
3349 sz = MAX_PATH;
3350 lstrcpyA(buf, "apple");
3351 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3353 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3354 ok(sz == 2, "Expected 2, got %d\n", sz);
3355
3356 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)pack_squashed, 33);
3357 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3358
3359 /* PackageCode value exists */
3360 sz = MAX_PATH;
3361 lstrcpyA(buf, "apple");
3362 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3364 ok(!lstrcmpA(buf, packcode), "Expected \"%s\", got \"%s\"\n", packcode, buf);
3365 ok(sz == 38, "Expected 38, got %d\n", sz);
3366
3367 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
3368 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3369
3370 /* Version value exists */
3371 sz = MAX_PATH;
3372 lstrcpyA(buf, "apple");
3373 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3375 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3376 ok(sz == 0, "Expected 0, got %d\n", sz);
3377
3378 res = RegSetValueExA(propkey, "Version", 0, REG_DWORD,
3379 (const BYTE *)&val, sizeof(DWORD));
3380 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3381
3382 /* Version type is REG_DWORD */
3383 sz = MAX_PATH;
3384 lstrcpyA(buf, "apple");
3385 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3387 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3388 ok(sz == 0, "Expected 0, got %d\n", sz);
3389
3390 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
3391 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3392
3393 /* Version value exists */
3394 sz = MAX_PATH;
3395 lstrcpyA(buf, "apple");
3396 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3397 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3398 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
3399 ok(sz == 3, "Expected 3, got %d\n", sz);
3400
3401 res = RegSetValueExA(prodkey, "Version", 0, REG_DWORD,
3402 (const BYTE *)&val, sizeof(DWORD));
3403 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3404
3405 /* Version type is REG_DWORD */
3406 sz = MAX_PATH;
3407 lstrcpyA(buf, "apple");
3408 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3409 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3410 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3411 ok(sz == 2, "Expected 2, got %d\n", sz);
3412
3413 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
3414 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3415
3416 /* ProductIcon value exists */
3417 sz = MAX_PATH;
3418 lstrcpyA(buf, "apple");
3419 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3420 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3421 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3422 ok(sz == 0, "Expected 0, got %d\n", sz);
3423
3424 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_DWORD,
3425 (const BYTE *)&val, sizeof(DWORD));
3426 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3427
3428 /* ProductIcon type is REG_DWORD */
3429 sz = MAX_PATH;
3430 lstrcpyA(buf, "apple");
3431 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3432 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3433 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3434 ok(sz == 0, "Expected 0, got %d\n", sz);
3435
3436 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
3437 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3438
3439 /* ProductIcon value exists */
3440 sz = MAX_PATH;
3441 lstrcpyA(buf, "apple");
3442 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3443 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3444 ok(!lstrcmpA(buf, "ico"), "Expected \"ico\", got \"%s\"\n", buf);
3445 ok(sz == 3, "Expected 3, got %d\n", sz);
3446
3447 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_DWORD,
3448 (const BYTE *)&val, sizeof(DWORD));
3449 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3450
3451 /* ProductIcon type is REG_DWORD */
3452 sz = MAX_PATH;
3453 lstrcpyA(buf, "apple");
3454 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3455 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3456 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3457 ok(sz == 2, "Expected 2, got %d\n", sz);
3458
3459 res = RegCreateKeyA(prodkey, "SourceList", &source);
3460 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3461
3462 res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
3463 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3464
3465 sz = MAX_PATH;
3466 lstrcpyA(buf, "apple");
3467 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
3468 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3469 ok(!lstrcmpA(buf, "packname"), "Expected \"packname\", got \"%s\"\n", buf);
3470 ok(sz == 8, "Expected 8, got %d\n", sz);
3471
3472 res = RegSetValueExA(source, "PackageName", 0, REG_DWORD,
3473 (const BYTE *)&val, sizeof(DWORD));
3474 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3475
3476 /* PackageName type is REG_DWORD */
3477 sz = MAX_PATH;
3478 lstrcpyA(buf, "apple");
3479 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
3480 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3481 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3482 ok(sz == 2, "Expected 2, got %d\n", sz);
3483
3484 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3485 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3486
3487 /* Authorized value exists */
3488 sz = MAX_PATH;
3489 lstrcpyA(buf, "apple");
3490 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3491 if (r != ERROR_UNKNOWN_PROPERTY)
3492 {
3493 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3494 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3495 ok(sz == 0, "Expected 0, got %d\n", sz);
3496 }
3497
3498 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_DWORD,
3499 (const BYTE *)&val, sizeof(DWORD));
3500 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3501
3502 /* AuthorizedLUAApp type is REG_DWORD */
3503 sz = MAX_PATH;
3504 lstrcpyA(buf, "apple");
3505 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3506 if (r != ERROR_UNKNOWN_PROPERTY)
3507 {
3508 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3509 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3510 ok(sz == 0, "Expected 0, got %d\n", sz);
3511 }
3512
3513 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3514 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3515
3516 /* Authorized value exists */
3517 sz = MAX_PATH;
3518 lstrcpyA(buf, "apple");
3519 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3520 if (r != ERROR_UNKNOWN_PROPERTY)
3521 {
3522 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3523 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
3524 ok(sz == 4, "Expected 4, got %d\n", sz);
3525 }
3526
3527 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_DWORD,
3528 (const BYTE *)&val, sizeof(DWORD));
3529 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3530
3531 /* AuthorizedLUAApp type is REG_DWORD */
3532 sz = MAX_PATH;
3533 lstrcpyA(buf, "apple");
3534 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3535 if (r != ERROR_UNKNOWN_PROPERTY)
3536 {
3537 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3538 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3539 ok(sz == 2, "Expected 2, got %d\n", sz);
3540 }
3541
3542 RegDeleteValueA(propkey, "HelpLink");
3543 RegDeleteValueA(propkey, "DisplayName");
3544 RegDeleteValueA(propkey, "DisplayVersion");
3545 RegDeleteValueA(propkey, "HelpTelephone");
3546 RegDeleteValueA(propkey, "InstallLocation");
3547 RegDeleteValueA(propkey, "InstallSource");
3548 RegDeleteValueA(propkey, "InstallDate");
3549 RegDeleteValueA(propkey, "Publisher");
3550 RegDeleteValueA(propkey, "LocalPackage");
3551 RegDeleteValueA(propkey, "UrlInfoAbout");
3552 RegDeleteValueA(propkey, "UrlUpdateInfo");
3553 RegDeleteValueA(propkey, "VersionMinor");
3554 RegDeleteValueA(propkey, "VersionMajor");
3555 RegDeleteValueA(propkey, "ProductID");
3556 RegDeleteValueA(propkey, "RegCompany");
3557 RegDeleteValueA(propkey, "RegOwner");
3558 RegDeleteValueA(propkey, "InstanceType");
3559 RegDeleteValueA(propkey, "Transforms");
3560 RegDeleteValueA(propkey, "Language");
3561 RegDeleteValueA(propkey, "ProductName");
3562 RegDeleteValueA(propkey, "Assignment");
3563 RegDeleteValueA(propkey, "PackageCode");
3564 RegDeleteValueA(propkey, "Version");
3565 RegDeleteValueA(propkey, "ProductIcon");
3566 RegDeleteValueA(propkey, "AuthorizedLUAApp");
3567 RegDeleteKeyA(propkey, "");
3568 RegDeleteKeyA(localkey, "");
3569 RegDeleteValueA(prodkey, "InstanceType");
3570 RegDeleteValueA(prodkey, "Transforms");
3571 RegDeleteValueA(prodkey, "Language");
3572 RegDeleteValueA(prodkey, "ProductName");
3573 RegDeleteValueA(prodkey, "Assignment");
3574 RegDeleteValueA(prodkey, "PackageCode");
3575 RegDeleteValueA(prodkey, "Version");
3576 RegDeleteValueA(prodkey, "ProductIcon");
3577 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
3578 RegDeleteValueA(source, "PackageName");
3579 RegDeleteKeyA(source, "");
3580 RegDeleteKeyA(prodkey, "");
3581 RegCloseKey(propkey);
3582 RegCloseKey(localkey);
3583 RegCloseKey(source);
3584 RegCloseKey(prodkey);
3585 }
3586
3587 static void test_MsiGetProductInfoEx(void)
3588 {
3589 UINT r;
3590 LONG res;
3591 HKEY propkey, userkey;
3592 HKEY prodkey, localkey;
3593 CHAR prodcode[MAX_PATH];
3594 CHAR prod_squashed[MAX_PATH];
3595 CHAR packcode[MAX_PATH];
3596 CHAR pack_squashed[MAX_PATH];
3597 CHAR buf[MAX_PATH];
3598 CHAR keypath[MAX_PATH];
3599 LPSTR usersid;
3600 DWORD sz;
3601
3602 if (!pMsiGetProductInfoExA)
3603 {
3604 skip("MsiGetProductInfoExA is not available\n");
3605 return;
3606 }
3607
3608 create_test_guid(prodcode, prod_squashed);
3609 create_test_guid(packcode, pack_squashed);
3610 get_user_sid(&usersid);
3611
3612 /* NULL szProductCode */
3613 sz = MAX_PATH;
3614 lstrcpyA(buf, "apple");
3615 r = pMsiGetProductInfoExA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3616 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3617 ok(r == ERROR_INVALID_PARAMETER,
3618 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3619 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3620 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3621
3622 /* empty szProductCode */
3623 sz = MAX_PATH;
3624 lstrcpyA(buf, "apple");
3625 r = pMsiGetProductInfoExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3626 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3627 ok(r == ERROR_INVALID_PARAMETER,
3628 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3629 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3630 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3631
3632 /* garbage szProductCode */
3633 sz = MAX_PATH;
3634 lstrcpyA(buf, "apple");
3635 r = pMsiGetProductInfoExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3636 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3637 ok(r == ERROR_INVALID_PARAMETER,
3638 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3639 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3640 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3641
3642 /* guid without brackets */
3643 sz = MAX_PATH;
3644 lstrcpyA(buf, "apple");
3645 r = pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
3646 MSIINSTALLCONTEXT_USERUNMANAGED,
3647 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3648 ok(r == ERROR_INVALID_PARAMETER,
3649 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3650 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3651 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3652
3653 /* guid with brackets */
3654 sz = MAX_PATH;
3655 lstrcpyA(buf, "apple");
3656 r = pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid,
3657 MSIINSTALLCONTEXT_USERUNMANAGED,
3658 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3659 ok(r == ERROR_UNKNOWN_PRODUCT,
3660 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3661 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3662 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3663
3664 /* szValue is non-NULL while pcchValue is NULL */
3665 lstrcpyA(buf, "apple");
3666 r = pMsiGetProductInfoExA(prodcode, usersid,
3667 MSIINSTALLCONTEXT_USERUNMANAGED,
3668 INSTALLPROPERTY_PRODUCTSTATE, buf, NULL);
3669 ok(r == ERROR_INVALID_PARAMETER,
3670 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3671 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3672
3673 /* dwContext is out of range */
3674 sz = MAX_PATH;
3675 lstrcpyA(buf, "apple");
3676 r = pMsiGetProductInfoExA(prodcode, usersid, 42,
3677 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3678 ok(r == ERROR_INVALID_PARAMETER,
3679 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3680 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3681 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3682
3683 /* szProperty is NULL */
3684 sz = MAX_PATH;
3685 lstrcpyA(buf, "apple");
3686 r = pMsiGetProductInfoExA(prodcode, usersid,
3687 MSIINSTALLCONTEXT_USERUNMANAGED,
3688 NULL, buf, &sz);
3689 ok(r == ERROR_INVALID_PARAMETER,
3690 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3691 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3692 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3693
3694 /* szProperty is empty */
3695 sz = MAX_PATH;
3696 lstrcpyA(buf, "apple");
3697 r = pMsiGetProductInfoExA(prodcode, usersid,
3698 MSIINSTALLCONTEXT_USERUNMANAGED,
3699 "", buf, &sz);
3700 ok(r == ERROR_INVALID_PARAMETER,
3701 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3702 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3703 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3704
3705 /* szProperty is not a valid property */
3706 sz = MAX_PATH;
3707 lstrcpyA(buf, "apple");
3708 r = pMsiGetProductInfoExA(prodcode, usersid,
3709 MSIINSTALLCONTEXT_USERUNMANAGED,
3710 "notvalid", buf, &sz);
3711 ok(r == ERROR_UNKNOWN_PRODUCT,
3712 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3713 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3714 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3715
3716 /* same length as guid, but random */
3717 sz = MAX_PATH;
3718 lstrcpyA(buf, "apple");
3719 r = pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid,
3720 MSIINSTALLCONTEXT_USERUNMANAGED,
3721 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3722 ok(r == ERROR_INVALID_PARAMETER,
3723 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3724 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3725 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3726
3727 /* MSIINSTALLCONTEXT_USERUNMANAGED */
3728
3729 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
3730 lstrcatA(keypath, usersid);
3731 lstrcatA(keypath, "\\Products\\");
3732 lstrcatA(keypath, prod_squashed);
3733
3734 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
3735 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3736
3737 /* local user product key exists */
3738 sz = MAX_PATH;
3739 lstrcpyA(buf, "apple");
3740 r = pMsiGetProductInfoExA(prodcode, usersid,
3741 MSIINSTALLCONTEXT_USERUNMANAGED,
3742 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3743 ok(r == ERROR_UNKNOWN_PRODUCT,
3744 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3745 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3746 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3747
3748 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
3749 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3750
3751 /* InstallProperties key exists */
3752 sz = MAX_PATH;
3753 lstrcpyA(buf, "apple");
3754 r = pMsiGetProductInfoExA(prodcode, usersid,
3755 MSIINSTALLCONTEXT_USERUNMANAGED,
3756 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3757 ok(r == ERROR_UNKNOWN_PRODUCT,
3758 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3759 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3760 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3761
3762 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3763 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3764
3765 /* LocalPackage value exists */
3766 sz = MAX_PATH;
3767 lstrcpyA(buf, "apple");
3768 r = pMsiGetProductInfoExA(prodcode, usersid,
3769 MSIINSTALLCONTEXT_USERUNMANAGED,
3770 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3771 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3772 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
3773 ok(sz == 1, "Expected 1, got %d\n", sz);
3774
3775 RegDeleteValueA(propkey, "LocalPackage");
3776
3777 /* LocalPackage value must exist */
3778 sz = MAX_PATH;
3779 lstrcpyA(buf, "apple");
3780 r = pMsiGetProductInfoExA(prodcode, usersid,
3781 MSIINSTALLCONTEXT_USERUNMANAGED,
3782 INSTALLPROPERTY_HELPLINK, buf, &sz);
3783 ok(r == ERROR_UNKNOWN_PRODUCT,
3784 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3785 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3786 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3787
3788 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3789 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3790
3791 /* LocalPackage exists, but HelpLink does not exist */
3792 sz = MAX_PATH;
3793 lstrcpyA(buf, "apple");
3794 r = pMsiGetProductInfoExA(prodcode, usersid,
3795 MSIINSTALLCONTEXT_USERUNMANAGED,
3796 INSTALLPROPERTY_HELPLINK, buf, &sz);
3797 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3798 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3799 ok(sz == 0, "Expected 0, got %d\n", sz);
3800
3801 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
3802 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3803
3804 /* HelpLink value exists */
3805 sz = MAX_PATH;
3806 lstrcpyA(buf, "apple");
3807 r = pMsiGetProductInfoExA(prodcode, usersid,
3808 MSIINSTALLCONTEXT_USERUNMANAGED,
3809 INSTALLPROPERTY_HELPLINK, buf, &sz);
3810 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3811 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
3812 ok(sz == 4, "Expected 4, got %d\n", sz);
3813
3814 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
3815 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3816
3817 /* HelpTelephone value exists */
3818 sz = MAX_PATH;
3819 lstrcpyA(buf, "apple");
3820 r = pMsiGetProductInfoExA(prodcode, usersid,
3821 MSIINSTALLCONTEXT_USERUNMANAGED,
3822 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3824 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
3825 ok(sz == 5, "Expected 5, got %d\n", sz);
3826
3827 /* szValue and pcchValue are NULL */
3828 r = pMsiGetProductInfoExA(prodcode, usersid,
3829 MSIINSTALLCONTEXT_USERUNMANAGED,
3830 INSTALLPROPERTY_HELPTELEPHONE, NULL, NULL);
3831 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3832
3833 /* pcchValue is exactly 5 */
3834 sz = 5;
3835 lstrcpyA(buf, "apple");
3836 r = pMsiGetProductInfoExA(prodcode, usersid,
3837 MSIINSTALLCONTEXT_USERUNMANAGED,
3838 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3839 ok(r == ERROR_MORE_DATA,
3840 "Expected ERROR_MORE_DATA, got %d\n", r);
3841 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3842 ok(sz == 10, "Expected 10, got %d\n", sz);
3843
3844 /* szValue is NULL, pcchValue is exactly 5 */
3845 sz = 5;
3846 r = pMsiGetProductInfoExA(prodcode, usersid,
3847 MSIINSTALLCONTEXT_USERUNMANAGED,
3848 INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
3849 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3850 ok(sz == 10, "Expected 10, got %d\n", sz);
3851
3852 /* szValue is NULL, pcchValue is MAX_PATH */
3853 sz = MAX_PATH;
3854 r = pMsiGetProductInfoExA(prodcode, usersid,
3855 MSIINSTALLCONTEXT_USERUNMANAGED,
3856 INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
3857 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3858 ok(sz == 10, "Expected 10, got %d\n", sz);
3859
3860 /* pcchValue is exactly 0 */
3861 sz = 0;
3862 lstrcpyA(buf, "apple");
3863 r = pMsiGetProductInfoExA(prodcode, usersid,
3864 MSIINSTALLCONTEXT_USERUNMANAGED,
3865 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3866 ok(r == ERROR_MORE_DATA,
3867 "Expected ERROR_MORE_DATA, got %d\n", r);
3868 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
3869 ok(sz == 10, "Expected 10, got %d\n", sz);
3870
3871 res = RegSetValueExA(propkey, "notvalid", 0, REG_SZ, (LPBYTE)"invalid", 8);
3872 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3873
3874 /* szProperty is not a valid property */
3875 sz = MAX_PATH;
3876 lstrcpyA(buf, "apple");
3877 r = pMsiGetProductInfoExA(prodcode, usersid,
3878 MSIINSTALLCONTEXT_USERUNMANAGED,
3879 "notvalid", buf, &sz);
3880 ok(r == ERROR_UNKNOWN_PROPERTY,
3881 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
3882 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3883 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3884
3885 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
3886 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3887
3888 /* InstallDate value exists */
3889 sz = MAX_PATH;
3890 lstrcpyA(buf, "apple");
3891 r = pMsiGetProductInfoExA(prodcode, usersid,
3892 MSIINSTALLCONTEXT_USERUNMANAGED,
3893 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
3894 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3895 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
3896 ok(sz == 4, "Expected 4, got %d\n", sz);
3897
3898 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
3899 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3900
3901 /* DisplayName value exists */
3902 sz = MAX_PATH;
3903 lstrcpyA(buf, "apple");
3904 r = pMsiGetProductInfoExA(prodcode, usersid,
3905 MSIINSTALLCONTEXT_USERUNMANAGED,
3906 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
3907 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3908 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
3909 ok(sz == 4, "Expected 4, got %d\n", sz);
3910
3911 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
3912 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3913
3914 /* InstallLocation value exists */
3915 sz = MAX_PATH;
3916 lstrcpyA(buf, "apple");
3917 r = pMsiGetProductInfoExA(prodcode, usersid,
3918 MSIINSTALLCONTEXT_USERUNMANAGED,
3919 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
3920 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3921 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
3922 ok(sz == 3, "Expected 3, got %d\n", sz);
3923
3924 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
3925 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3926
3927 /* InstallSource value exists */
3928 sz = MAX_PATH;
3929 lstrcpyA(buf, "apple");
3930 r = pMsiGetProductInfoExA(prodcode, usersid,
3931 MSIINSTALLCONTEXT_USERUNMANAGED,
3932 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
3933 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3934 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
3935 ok(sz == 6, "Expected 6, got %d\n", sz);
3936
3937 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3938 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3939
3940 /* LocalPackage value exists */
3941 sz = MAX_PATH;
3942 lstrcpyA(buf, "apple");
3943 r = pMsiGetProductInfoExA(prodcode, usersid,
3944 MSIINSTALLCONTEXT_USERUNMANAGED,
3945 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
3946 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3947 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
3948 ok(sz == 5, "Expected 5, got %d\n", sz);
3949
3950 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
3951 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3952
3953 /* Publisher value exists */
3954 sz = MAX_PATH;
3955 lstrcpyA(buf, "apple");
3956 r = pMsiGetProductInfoExA(prodcode, usersid,
3957 MSIINSTALLCONTEXT_USERUNMANAGED,
3958 INSTALLPROPERTY_PUBLISHER, buf, &sz);
3959 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3960 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
3961 ok(sz == 3, "Expected 3, got %d\n", sz);
3962
3963 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
3964 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3965
3966 /* URLInfoAbout value exists */
3967 sz = MAX_PATH;
3968 lstrcpyA(buf, "apple");
3969 r = pMsiGetProductInfoExA(prodcode, usersid,
3970 MSIINSTALLCONTEXT_USERUNMANAGED,
3971 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
3972 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3973 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
3974 ok(sz == 5, "Expected 5, got %d\n", sz);
3975
3976 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
3977 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3978
3979 /* URLUpdateInfo value exists */
3980 sz = MAX_PATH;
3981 lstrcpyA(buf, "apple");
3982 r = pMsiGetProductInfoExA(prodcode, usersid,
3983 MSIINSTALLCONTEXT_USERUNMANAGED,
3984 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
3985 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3986 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
3987 ok(sz == 6, "Expected 6, got %d\n", sz);
3988
3989 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
3990 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3991
3992 /* VersionMinor value exists */
3993 sz = MAX_PATH;
3994 lstrcpyA(buf, "apple");
3995 r = pMsiGetProductInfoExA(prodcode, usersid,
3996 MSIINSTALLCONTEXT_USERUNMANAGED,
3997 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
3998 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3999 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
4000 ok(sz == 1, "Expected 1, got %d\n", sz);
4001
4002 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4003 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4004
4005 /* VersionMajor value exists */
4006 sz = MAX_PATH;
4007 lstrcpyA(buf, "apple");
4008 r = pMsiGetProductInfoExA(prodcode, usersid,
4009 MSIINSTALLCONTEXT_USERUNMANAGED,
4010 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4011 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4012 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
4013 ok(sz == 1, "Expected 1, got %d\n", sz);
4014
4015 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4016 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4017
4018 /* DisplayVersion value exists */
4019 sz = MAX_PATH;
4020 lstrcpyA(buf, "apple");
4021 r = pMsiGetProductInfoExA(prodcode, usersid,
4022 MSIINSTALLCONTEXT_USERUNMANAGED,
4023 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4025 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
4026 ok(sz == 5, "Expected 5, got %d\n", sz);
4027
4028 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4029 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4030
4031 /* ProductID value exists */
4032 sz = MAX_PATH;
4033 lstrcpyA(buf, "apple");
4034 r = pMsiGetProductInfoExA(prodcode, usersid,
4035 MSIINSTALLCONTEXT_USERUNMANAGED,
4036 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4037 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4038 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
4039 ok(sz == 2, "Expected 2, got %d\n", sz);
4040
4041 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4042 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4043
4044 /* RegCompany value exists */
4045 sz = MAX_PATH;
4046 lstrcpyA(buf, "apple");
4047 r = pMsiGetProductInfoExA(prodcode, usersid,
4048 MSIINSTALLCONTEXT_USERUNMANAGED,
4049 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4050 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4051 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
4052 ok(sz == 4, "Expected 4, got %d\n", sz);
4053
4054 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4055 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4056
4057 /* RegOwner value exists */
4058 sz = MAX_PATH;
4059 lstrcpyA(buf, "apple");
4060 r = pMsiGetProductInfoExA(prodcode, usersid,
4061 MSIINSTALLCONTEXT_USERUNMANAGED,
4062 INSTALLPROPERTY_REGOWNER, buf, &sz);
4063 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4064 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
4065 ok(sz == 5, "Expected 5, got %d\n", sz);
4066
4067 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4068 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4069
4070 /* Transforms value exists */
4071 sz = MAX_PATH;
4072 lstrcpyA(buf, "apple");
4073 r = pMsiGetProductInfoExA(prodcode, usersid,
4074 MSIINSTALLCONTEXT_USERUNMANAGED,
4075 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4076 ok(r == ERROR_UNKNOWN_PRODUCT,
4077 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4078 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4079 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4080
4081 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4082 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4083
4084 /* Language value exists */
4085 sz = MAX_PATH;
4086 lstrcpyA(buf, "apple");
4087 r = pMsiGetProductInfoExA(prodcode, usersid,
4088 MSIINSTALLCONTEXT_USERUNMANAGED,
4089 INSTALLPROPERTY_LANGUAGE, buf, &sz);
4090 ok(r == ERROR_UNKNOWN_PRODUCT,
4091 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4092 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4093 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4094
4095 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4096 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4097
4098 /* ProductName value exists */
4099 sz = MAX_PATH;
4100 lstrcpyA(buf, "apple");
4101 r = pMsiGetProductInfoExA(prodcode, usersid,
4102 MSIINSTALLCONTEXT_USERUNMANAGED,
4103 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4104 ok(r == ERROR_UNKNOWN_PRODUCT,
4105 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4106 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4107 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4108
4109 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4110 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4111
4112 /* FIXME */
4113
4114 /* AssignmentType value exists */
4115 sz = MAX_PATH;
4116 lstrcpyA(buf, "apple");
4117 r = pMsiGetProductInfoExA(prodcode, usersid,
4118 MSIINSTALLCONTEXT_USERUNMANAGED,
4119 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4120 ok(r == ERROR_UNKNOWN_PRODUCT,
4121 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4122 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4123 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4124
4125 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4126 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4127
4128 /* PackageCode value exists */
4129 sz = MAX_PATH;
4130 lstrcpyA(buf, "apple");
4131 r = pMsiGetProductInfoExA(prodcode, usersid,
4132 MSIINSTALLCONTEXT_USERUNMANAGED,
4133 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4134 ok(r == ERROR_UNKNOWN_PRODUCT,
4135 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4136 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4137 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4138
4139 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4140 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4141
4142 /* Version value exists */
4143 sz = MAX_PATH;
4144 lstrcpyA(buf, "apple");
4145 r = pMsiGetProductInfoExA(prodcode, usersid,
4146 MSIINSTALLCONTEXT_USERUNMANAGED,
4147 INSTALLPROPERTY_VERSION, buf, &sz);
4148 ok(r == ERROR_UNKNOWN_PRODUCT,
4149 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4150 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4151 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4152
4153 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4154 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4155
4156 /* ProductIcon value exists */
4157 sz = MAX_PATH;
4158 lstrcpyA(buf, "apple");
4159 r = pMsiGetProductInfoExA(prodcode, usersid,
4160 MSIINSTALLCONTEXT_USERUNMANAGED,
4161 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4162 ok(r == ERROR_UNKNOWN_PRODUCT,
4163 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4164 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4165 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4166
4167 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4168 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4169
4170 /* PackageName value exists */
4171 sz = MAX_PATH;
4172 lstrcpyA(buf, "apple");
4173 r = pMsiGetProductInfoExA(prodcode, usersid,
4174 MSIINSTALLCONTEXT_USERUNMANAGED,
4175 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4176 ok(r == ERROR_UNKNOWN_PRODUCT,
4177 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4178 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4179 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4180
4181 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4182 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4183
4184 /* AuthorizedLUAApp value exists */
4185 sz = MAX_PATH;
4186 lstrcpyA(buf, "apple");
4187 r = pMsiGetProductInfoExA(prodcode, usersid,
4188 MSIINSTALLCONTEXT_USERUNMANAGED,
4189 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4190 ok(r == ERROR_UNKNOWN_PRODUCT,
4191 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4192 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4193 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4194
4195 RegDeleteValueA(propkey, "AuthorizedLUAApp");
4196 RegDeleteValueA(propkey, "PackageName");
4197 RegDeleteValueA(propkey, "ProductIcon");
4198 RegDeleteValueA(propkey, "Version");
4199 RegDeleteValueA(propkey, "PackageCode");
4200 RegDeleteValueA(propkey, "AssignmentType");
4201 RegDeleteValueA(propkey, "ProductName");
4202 RegDeleteValueA(propkey, "Language");
4203 RegDeleteValueA(propkey, "Transforms");
4204 RegDeleteValueA(propkey, "RegOwner");
4205 RegDeleteValueA(propkey, "RegCompany");
4206 RegDeleteValueA(propkey, "ProductID");
4207 RegDeleteValueA(propkey, "DisplayVersion");
4208 RegDeleteValueA(propkey, "VersionMajor");
4209 RegDeleteValueA(propkey, "VersionMinor");
4210 RegDeleteValueA(propkey, "URLUpdateInfo");
4211 RegDeleteValueA(propkey, "URLInfoAbout");
4212 RegDeleteValueA(propkey, "Publisher");
4213 RegDeleteValueA(propkey, "LocalPackage");
4214 RegDeleteValueA(propkey, "InstallSource");
4215 RegDeleteValueA(propkey, "InstallLocation");
4216 RegDeleteValueA(propkey, "DisplayName");
4217 RegDeleteValueA(propkey, "InstallDate");
4218 RegDeleteValueA(propkey, "HelpTelephone");
4219 RegDeleteValueA(propkey, "HelpLink");
4220 RegDeleteValueA(propkey, "LocalPackage");
4221 RegDeleteKeyA(propkey, "");
4222 RegCloseKey(propkey);
4223 RegDeleteKeyA(localkey, "");
4224 RegCloseKey(localkey);
4225
4226 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4227 lstrcatA(keypath, usersid);
4228 lstrcatA(keypath, "\\Installer\\Products\\");
4229 lstrcatA(keypath, prod_squashed);
4230
4231 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
4232 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4233
4234 /* user product key exists */
4235 sz = MAX_PATH;
4236 lstrcpyA(buf, "apple");
4237 r = pMsiGetProductInfoExA(prodcode, usersid,
4238 MSIINSTALLCONTEXT_USERUNMANAGED,
4239 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4240 ok(r == ERROR_UNKNOWN_PRODUCT,
4241 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4242 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4243 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4244
4245 RegDeleteKeyA(userkey, "");
4246 RegCloseKey(userkey);
4247
4248 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
4249 lstrcatA(keypath, prod_squashed);
4250
4251 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
4252 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4253
4254 sz = MAX_PATH;
4255 lstrcpyA(buf, "apple");
4256 r = pMsiGetProductInfoExA(prodcode, usersid,
4257 MSIINSTALLCONTEXT_USERUNMANAGED,
4258 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4260 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
4261 ok(sz == 1, "Expected 1, got %d\n", sz);
4262
4263 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4264 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4265
4266 /* HelpLink value exists */
4267 sz = MAX_PATH;
4268 lstrcpyA(buf, "apple");
4269 r = pMsiGetProductInfoExA(prodcode, usersid,
4270 MSIINSTALLCONTEXT_USERUNMANAGED,
4271 INSTALLPROPERTY_HELPLINK, buf, &sz);
4272 ok(r == ERROR_UNKNOWN_PROPERTY,
4273 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4274 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4275 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4276
4277 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4278 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4279
4280 /* HelpTelephone value exists */
4281 sz = MAX_PATH;
4282 lstrcpyA(buf, "apple");
4283 r = pMsiGetProductInfoExA(prodcode, usersid,
4284 MSIINSTALLCONTEXT_USERUNMANAGED,
4285 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4286 ok(r == ERROR_UNKNOWN_PROPERTY,
4287 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4288 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4289 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4290
4291 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4292 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4293
4294 /* InstallDate value exists */
4295 sz = MAX_PATH;
4296 lstrcpyA(buf, "apple");
4297 r = pMsiGetProductInfoExA(prodcode, usersid,
4298 MSIINSTALLCONTEXT_USERUNMANAGED,
4299 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4300 ok(r == ERROR_UNKNOWN_PROPERTY,
4301 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4302 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4303 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4304
4305 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4306 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4307
4308 /* DisplayName value exists */
4309 sz = MAX_PATH;
4310 lstrcpyA(buf, "apple");
4311 r = pMsiGetProductInfoExA(prodcode, usersid,
4312 MSIINSTALLCONTEXT_USERUNMANAGED,
4313 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4314 ok(r == ERROR_UNKNOWN_PROPERTY,
4315 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4316 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4317 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4318
4319 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4320 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4321
4322 /* InstallLocation value exists */
4323 sz = MAX_PATH;
4324 lstrcpyA(buf, "apple");
4325 r = pMsiGetProductInfoExA(prodcode, usersid,
4326 MSIINSTALLCONTEXT_USERUNMANAGED,
4327 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4328 ok(r == ERROR_UNKNOWN_PROPERTY,
4329 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4330 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4331 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4332
4333 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4334 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4335
4336 /* InstallSource value exists */
4337 sz = MAX_PATH;
4338 lstrcpyA(buf, "apple");
4339 r = pMsiGetProductInfoExA(prodcode, usersid,
4340 MSIINSTALLCONTEXT_USERUNMANAGED,
4341 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4342 ok(r == ERROR_UNKNOWN_PROPERTY,
4343 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4344 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4345 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4346
4347 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4348 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4349
4350 /* LocalPackage value exists */
4351 sz = MAX_PATH;
4352 lstrcpyA(buf, "apple");
4353 r = pMsiGetProductInfoExA(prodcode, usersid,
4354 MSIINSTALLCONTEXT_USERUNMANAGED,
4355 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4356 ok(r == ERROR_UNKNOWN_PROPERTY,
4357 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4358 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4359 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4360
4361 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4362 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4363
4364 /* Publisher value exists */
4365 sz = MAX_PATH;
4366 lstrcpyA(buf, "apple");
4367 r = pMsiGetProductInfoExA(prodcode, usersid,
4368 MSIINSTALLCONTEXT_USERUNMANAGED,
4369 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4370 ok(r == ERROR_UNKNOWN_PROPERTY,
4371 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4372 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4373 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4374
4375 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4376 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4377
4378 /* URLInfoAbout value exists */
4379 sz = MAX_PATH;
4380 lstrcpyA(buf, "apple");
4381 r = pMsiGetProductInfoExA(prodcode, usersid,
4382 MSIINSTALLCONTEXT_USERUNMANAGED,
4383 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4384 ok(r == ERROR_UNKNOWN_PROPERTY,
4385 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4386 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4387 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4388
4389 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4390 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4391
4392 /* URLUpdateInfo value exists */
4393 sz = MAX_PATH;
4394 lstrcpyA(buf, "apple");
4395 r = pMsiGetProductInfoExA(prodcode, usersid,
4396 MSIINSTALLCONTEXT_USERUNMANAGED,
4397 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4398 ok(r == ERROR_UNKNOWN_PROPERTY,
4399 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4400 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4401 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4402
4403 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4404 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4405
4406 /* VersionMinor value exists */
4407 sz = MAX_PATH;
4408 lstrcpyA(buf, "apple");
4409 r = pMsiGetProductInfoExA(prodcode, usersid,
4410 MSIINSTALLCONTEXT_USERUNMANAGED,
4411 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4412 ok(r == ERROR_UNKNOWN_PROPERTY,
4413 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4414 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4415 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4416
4417 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4418 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4419
4420 /* VersionMajor value exists */
4421 sz = MAX_PATH;
4422 lstrcpyA(buf, "apple");
4423 r = pMsiGetProductInfoExA(prodcode, usersid,
4424 MSIINSTALLCONTEXT_USERUNMANAGED,
4425 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4426 ok(r == ERROR_UNKNOWN_PROPERTY,
4427 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4428 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4429 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4430
4431 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4432 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4433
4434 /* DisplayVersion value exists */
4435 sz = MAX_PATH;
4436 lstrcpyA(buf, "apple");
4437 r = pMsiGetProductInfoExA(prodcode, usersid,
4438 MSIINSTALLCONTEXT_USERUNMANAGED,
4439 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4440 ok(r == ERROR_UNKNOWN_PROPERTY,
4441 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4442 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4443 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4444
4445 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4446 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4447
4448 /* ProductID value exists */
4449 sz = MAX_PATH;
4450 lstrcpyA(buf, "apple");
4451 r = pMsiGetProductInfoExA(prodcode, usersid,
4452 MSIINSTALLCONTEXT_USERUNMANAGED,
4453 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4454 ok(r == ERROR_UNKNOWN_PROPERTY,
4455 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4456 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4457 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4458
4459 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4460 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4461
4462 /* RegCompany value exists */
4463 sz = MAX_PATH;
4464 lstrcpyA(buf, "apple");
4465 r = pMsiGetProductInfoExA(prodcode, usersid,
4466 MSIINSTALLCONTEXT_USERUNMANAGED,
4467 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4468 ok(r == ERROR_UNKNOWN_PROPERTY,
4469 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4470 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4471 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4472
4473 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4474 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4475
4476 /* RegOwner value exists */
4477 sz = MAX_PATH;
4478 lstrcpyA(buf, "apple");
4479 r = pMsiGetProductInfoExA(prodcode, usersid,
4480 MSIINSTALLCONTEXT_USERUNMANAGED,
4481 INSTALLPROPERTY_REGOWNER, buf, &sz);
4482 ok(r == ERROR_UNKNOWN_PROPERTY,
4483 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4484 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4485 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4486
4487 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4488 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4489
4490 /* Transforms value exists */
4491 sz = MAX_PATH;
4492 lstrcpyA(buf, "apple");
4493 r = pMsiGetProductInfoExA(prodcode, usersid,
4494 MSIINSTALLCONTEXT_USERUNMANAGED,
4495 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4496 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4497 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
4498 ok(sz == 5, "Expected 5, got %d\n", sz);
4499
4500 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4501 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4502
4503 /* Language value exists */
4504 sz = MAX_PATH;
4505 lstrcpyA(buf, "apple");
4506 r = pMsiGetProductInfoExA(prodcode, usersid,
4507 MSIINSTALLCONTEXT_USERUNMANAGED,
4508 INSTALLPROPERTY_LANGUAGE, buf, &sz);
4509 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4510 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
4511 ok(sz == 4, "Expected 4, got %d\n", sz);
4512
4513 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4514 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4515
4516 /* ProductName value exists */
4517 sz = MAX_PATH;
4518 lstrcpyA(buf, "apple");
4519 r = pMsiGetProductInfoExA(prodcode, usersid,
4520 MSIINSTALLCONTEXT_USERUNMANAGED,
4521 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4522 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4523 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4524 ok(sz == 4, "Expected 4, got %d\n", sz);
4525
4526 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4527 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4528
4529 /* FIXME */
4530
4531 /* AssignmentType value exists */
4532 sz = MAX_PATH;
4533 lstrcpyA(buf, "apple");
4534 r = pMsiGetProductInfoExA(prodcode, usersid,
4535 MSIINSTALLCONTEXT_USERUNMANAGED,
4536 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4537 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4538 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4539 ok(sz == 0, "Expected 0, got %d\n", sz);
4540
4541 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4542 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4543
4544 /* FIXME */
4545
4546 /* PackageCode value exists */
4547 sz = MAX_PATH;
4548 lstrcpyA(buf, "apple");
4549 r = pMsiGetProductInfoExA(prodcode, usersid,
4550 MSIINSTALLCONTEXT_USERUNMANAGED,
4551 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4552 todo_wine
4553 {
4554 ok(r == ERROR_BAD_CONFIGURATION,
4555 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
4556 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4557 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4558 }
4559
4560 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4561 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4562
4563 /* Version value exists */
4564 sz = MAX_PATH;
4565 lstrcpyA(buf, "apple");
4566 r = pMsiGetProductInfoExA(prodcode, usersid,
4567 MSIINSTALLCONTEXT_USERUNMANAGED,
4568 INSTALLPROPERTY_VERSION, buf, &sz);
4569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4570 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
4571 ok(sz == 3, "Expected 3, got %d\n", sz);
4572
4573 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4574 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4575
4576 /* ProductIcon value exists */
4577 sz = MAX_PATH;
4578 lstrcpyA(buf, "apple");
4579 r = pMsiGetProductInfoExA(prodcode, usersid,
4580 MSIINSTALLCONTEXT_USERUNMANAGED,
4581 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4583 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
4584 ok(sz == 4, "Expected 4, got %d\n", sz);
4585
4586 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4587 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4588
4589 /* PackageName value exists */
4590 sz = MAX_PATH;
4591 lstrcpyA(buf, "apple");
4592 r = pMsiGetProductInfoExA(prodcode, usersid,
4593 MSIINSTALLCONTEXT_USERUNMANAGED,
4594 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4595 todo_wine
4596 {
4597 ok(r == ERROR_UNKNOWN_PRODUCT,
4598 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4599 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4600 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4601 }
4602
4603 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4604 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4605
4606 /* AuthorizedLUAApp value exists */
4607 sz = MAX_PATH;
4608 lstrcpyA(buf, "apple");
4609 r = pMsiGetProductInfoExA(prodcode, usersid,
4610 MSIINSTALLCONTEXT_USERUNMANAGED,
4611 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4612 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4613 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
4614 ok(sz == 4, "Expected 4, got %d\n", sz);
4615
4616 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
4617 RegDeleteValueA(prodkey, "PackageName");
4618 RegDeleteValueA(prodkey, "ProductIcon");
4619 RegDeleteValueA(prodkey, "Version");
4620 RegDeleteValueA(prodkey, "PackageCode");
4621 RegDeleteValueA(prodkey, "AssignmentType");
4622 RegDeleteValueA(prodkey, "ProductName");
4623 RegDeleteValueA(prodkey, "Language");
4624 RegDeleteValueA(prodkey, "Transforms");
4625 RegDeleteValueA(prodkey, "RegOwner");
4626 RegDeleteValueA(prodkey, "RegCompany");
4627 RegDeleteValueA(prodkey, "ProductID");
4628 RegDeleteValueA(prodkey, "DisplayVersion");
4629 RegDeleteValueA(prodkey, "VersionMajor");
4630 RegDeleteValueA(prodkey, "VersionMinor");
4631 RegDeleteValueA(prodkey, "URLUpdateInfo");
4632 RegDeleteValueA(prodkey, "URLInfoAbout");
4633 RegDeleteValueA(prodkey, "Publisher");
4634 RegDeleteValueA(prodkey, "LocalPackage");
4635 RegDeleteValueA(prodkey, "InstallSource");
4636 RegDeleteValueA(prodkey, "InstallLocation");
4637 RegDeleteValueA(prodkey, "DisplayName");
4638 RegDeleteValueA(prodkey, "InstallDate");
4639 RegDeleteValueA(prodkey, "HelpTelephone");
4640 RegDeleteValueA(prodkey, "HelpLink");
4641 RegDeleteValueA(prodkey, "LocalPackage");
4642 RegDeleteKeyA(prodkey, "");
4643 RegCloseKey(prodkey);
4644
4645 /* MSIINSTALLCONTEXT_USERMANAGED */
4646
4647 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4648 lstrcatA(keypath, usersid);
4649 lstrcatA(keypath, "\\Products\\");
4650 lstrcatA(keypath, prod_squashed);
4651
4652 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
4653 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4654
4655 /* local user product key exists */
4656 sz = MAX_PATH;
4657 lstrcpyA(buf, "apple");
4658 r = pMsiGetProductInfoExA(prodcode, usersid,
4659 MSIINSTALLCONTEXT_USERMANAGED,
4660 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4661 ok(r == ERROR_UNKNOWN_PRODUCT,
4662 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4663 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4664 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4665
4666 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
4667 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4668
4669 /* InstallProperties key exists */
4670 sz = MAX_PATH;
4671 lstrcpyA(buf, "apple");
4672 r = pMsiGetProductInfoExA(prodcode, usersid,
4673 MSIINSTALLCONTEXT_USERMANAGED,
4674 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4675 ok(r == ERROR_UNKNOWN_PRODUCT,
4676 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4677 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4678 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4679
4680 res = RegSetValueExA(propkey, "ManagedLocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4681 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4682
4683 /* ManagedLocalPackage value exists */
4684 sz = MAX_PATH;
4685 lstrcpyA(buf, "apple");
4686 r = pMsiGetProductInfoExA(prodcode, usersid,
4687 MSIINSTALLCONTEXT_USERMANAGED,
4688 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4689 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4690 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
4691 ok(sz == 1, "Expected 1, got %d\n", sz);
4692
4693 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4694 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4695
4696 /* HelpLink value exists */
4697 sz = MAX_PATH;
4698 lstrcpyA(buf, "apple");
4699 r = pMsiGetProductInfoExA(prodcode, usersid,
4700 MSIINSTALLCONTEXT_USERMANAGED,
4701 INSTALLPROPERTY_HELPLINK, buf, &sz);
4702 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4703 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4704 ok(sz == 4, "Expected 4, got %d\n", sz);
4705
4706 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4707 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4708
4709 /* HelpTelephone value exists */
4710 sz = MAX_PATH;
4711 lstrcpyA(buf, "apple");
4712 r = pMsiGetProductInfoExA(prodcode, usersid,
4713 MSIINSTALLCONTEXT_USERMANAGED,
4714 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4715 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4716 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
4717 ok(sz == 5, "Expected 5, got %d\n", sz);
4718
4719 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4720 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4721
4722 /* InstallDate value exists */
4723 sz = MAX_PATH;
4724 lstrcpyA(buf, "apple");
4725 r = pMsiGetProductInfoExA(prodcode, usersid,
4726 MSIINSTALLCONTEXT_USERMANAGED,
4727 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4729 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4730 ok(sz == 4, "Expected 4, got %d\n", sz);
4731
4732 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4733 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4734
4735 /* DisplayName value exists */
4736 sz = MAX_PATH;
4737 lstrcpyA(buf, "apple");
4738 r = pMsiGetProductInfoExA(prodcode, usersid,
4739 MSIINSTALLCONTEXT_USERMANAGED,
4740 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4741 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4742 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4743 ok(sz == 4, "Expected 4, got %d\n", sz);
4744
4745 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4746 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4747
4748 /* InstallLocation value exists */
4749 sz = MAX_PATH;
4750 lstrcpyA(buf, "apple");
4751 r = pMsiGetProductInfoExA(prodcode, usersid,
4752 MSIINSTALLCONTEXT_USERMANAGED,
4753 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4754 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4755 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4756 ok(sz == 3, "Expected 3, got %d\n", sz);
4757
4758 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4759 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4760
4761 /* InstallSource value exists */
4762 sz = MAX_PATH;
4763 lstrcpyA(buf, "apple");
4764 r = pMsiGetProductInfoExA(prodcode, usersid,
4765 MSIINSTALLCONTEXT_USERMANAGED,
4766 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4768 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4769 ok(sz == 6, "Expected 6, got %d\n", sz);
4770
4771 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4772 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4773
4774 /* LocalPackage value exists */
4775 sz = MAX_PATH;
4776 lstrcpyA(buf, "apple");
4777 r = pMsiGetProductInfoExA(prodcode, usersid,
4778 MSIINSTALLCONTEXT_USERMANAGED,
4779 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4780 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4781 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
4782 ok(sz == 5, "Expected 5, got %d\n", sz);
4783
4784 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4785 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4786
4787 /* Publisher value exists */
4788 sz = MAX_PATH;
4789 lstrcpyA(buf, "apple");
4790 r = pMsiGetProductInfoExA(prodcode, usersid,
4791 MSIINSTALLCONTEXT_USERMANAGED,
4792 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4793 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4794 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4795 ok(sz == 3, "Expected 3, got %d\n", sz);
4796
4797 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4798 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4799
4800 /* URLInfoAbout value exists */
4801 sz = MAX_PATH;
4802 lstrcpyA(buf, "apple");
4803 r = pMsiGetProductInfoExA(prodcode, usersid,
4804 MSIINSTALLCONTEXT_USERMANAGED,
4805 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4807 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4808 ok(sz == 5, "Expected 5, got %d\n", sz);
4809
4810 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4811 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4812
4813 /* URLUpdateInfo value exists */
4814 sz = MAX_PATH;
4815 lstrcpyA(buf, "apple");
4816 r = pMsiGetProductInfoExA(prodcode, usersid,
4817 MSIINSTALLCONTEXT_USERMANAGED,
4818 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4819 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4820 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
4821 ok(sz == 6, "Expected 6, got %d\n", sz);
4822
4823 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4824 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4825
4826 /* VersionMinor value exists */
4827 sz = MAX_PATH;
4828 lstrcpyA(buf, "apple");
4829 r = pMsiGetProductInfoExA(prodcode, usersid,
4830 MSIINSTALLCONTEXT_USERMANAGED,
4831 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4832 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4833 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
4834 ok(sz == 1, "Expected 1, got %d\n", sz);
4835
4836 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4837 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4838
4839 /* VersionMajor value exists */
4840 sz = MAX_PATH;
4841 lstrcpyA(buf, "apple");
4842 r = pMsiGetProductInfoExA(prodcode, usersid,
4843 MSIINSTALLCONTEXT_USERMANAGED,
4844 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4845 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4846 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
4847 ok(sz == 1, "Expected 1, got %d\n", sz);
4848
4849 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4850 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4851
4852 /* DisplayVersion value exists */
4853 sz = MAX_PATH;
4854 lstrcpyA(buf, "apple");
4855 r = pMsiGetProductInfoExA(prodcode, usersid,
4856 MSIINSTALLCONTEXT_USERMANAGED,
4857 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4859 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
4860 ok(sz == 5, "Expected 5, got %d\n", sz);
4861
4862 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4863 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4864
4865 /* ProductID value exists */
4866 sz = MAX_PATH;
4867 lstrcpyA(buf, "apple");
4868 r = pMsiGetProductInfoExA(prodcode, usersid,
4869 MSIINSTALLCONTEXT_USERMANAGED,
4870 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4871 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4872 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
4873 ok(sz == 2, "Expected 2, got %d\n", sz);
4874
4875 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4876 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4877
4878 /* RegCompany value exists */
4879 sz = MAX_PATH;
4880 lstrcpyA(buf, "apple");
4881 r = pMsiGetProductInfoExA(prodcode, usersid,
4882 MSIINSTALLCONTEXT_USERMANAGED,
4883 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4885 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
4886 ok(sz == 4, "Expected 4, got %d\n", sz);
4887
4888 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4889 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4890
4891 /* RegOwner value exists */
4892 sz = MAX_PATH;
4893 lstrcpyA(buf, "apple");
4894 r = pMsiGetProductInfoExA(prodcode, usersid,
4895 MSIINSTALLCONTEXT_USERMANAGED,
4896 INSTALLPROPERTY_REGOWNER, buf, &sz);
4897 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4898 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
4899 ok(sz == 5, "Expected 5, got %d\n", sz);
4900
4901 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4902 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4903
4904 /* Transforms value exists */
4905 sz = MAX_PATH;
4906 lstrcpyA(buf, "apple");
4907 r = pMsiGetProductInfoExA(prodcode, usersid,
4908 MSIINSTALLCONTEXT_USERMANAGED,
4909 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4910 ok(r == ERROR_UNKNOWN_PRODUCT,
4911 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4912 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4913 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4914
4915 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4916 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4917
4918 /* Language value exists */
4919 sz = MAX_PATH;
4920 lstrcpyA(buf, "apple");
4921 r = pMsiGetProductInfoExA(prodcode, usersid,
4922 MSIINSTALLCONTEXT_USERMANAGED,
4923 INSTALLPROPERTY_LANGUAGE, buf, &sz);
4924 ok(r == ERROR_UNKNOWN_PRODUCT,
4925 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4926 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4927 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4928
4929 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4930 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4931
4932 /* ProductName value exists */
4933 sz = MAX_PATH;
4934 lstrcpyA(buf, "apple");
4935 r = pMsiGetProductInfoExA(prodcode, usersid,
4936 MSIINSTALLCONTEXT_USERMANAGED,
4937 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4938 ok(r == ERROR_UNKNOWN_PRODUCT,
4939 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4940 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4941 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4942
4943 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4944 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4945
4946 /* FIXME */
4947
4948 /* AssignmentType value exists */
4949 sz = MAX_PATH;
4950 lstrcpyA(buf, "apple");
4951 r = pMsiGetProductInfoExA(prodcode, usersid,
4952 MSIINSTALLCONTEXT_USERMANAGED,
4953 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4954 ok(r == ERROR_UNKNOWN_PRODUCT,
4955 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4956 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4957 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4958
4959 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4960 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4961
4962 /* PackageCode value exists */
4963 sz = MAX_PATH;
4964 lstrcpyA(buf, "apple");
4965 r = pMsiGetProductInfoExA(prodcode, usersid,
4966 MSIINSTALLCONTEXT_USERMANAGED,
4967 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4968 ok(r == ERROR_UNKNOWN_PRODUCT,
4969 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4970 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4971 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4972
4973 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4974 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4975
4976 /* Version value exists */
4977 sz = MAX_PATH;
4978 lstrcpyA(buf, "apple");
4979 r = pMsiGetProductInfoExA(prodcode, usersid,
4980 MSIINSTALLCONTEXT_USERMANAGED,
4981 INSTALLPROPERTY_VERSION, buf, &sz);
4982 ok(r == ERROR_UNKNOWN_PRODUCT,
4983 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4984 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4985 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4986
4987 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4988 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4989
4990 /* ProductIcon value exists */
4991 sz = MAX_PATH;
4992 lstrcpyA(buf, "apple");
4993 r = pMsiGetProductInfoExA(prodcode, usersid,
4994 MSIINSTALLCONTEXT_USERMANAGED,
4995 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4996 ok(r == ERROR_UNKNOWN_PRODUCT,
4997 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4998 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4999 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5000
5001 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5002 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5003
5004 /* PackageName value exists */
5005 sz = MAX_PATH;
5006 lstrcpyA(buf, "apple");
5007 r = pMsiGetProductInfoExA(prodcode, usersid,
5008 MSIINSTALLCONTEXT_USERMANAGED,
5009 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5010 ok(r == ERROR_UNKNOWN_PRODUCT,
5011 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5012 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5013 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5014
5015 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5016 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5017
5018 /* AuthorizedLUAApp value exists */
5019 sz = MAX_PATH;
5020 lstrcpyA(buf, "apple");
5021 r = pMsiGetProductInfoExA(prodcode, usersid,
5022 MSIINSTALLCONTEXT_USERMANAGED,
5023 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5024 ok(r == ERROR_UNKNOWN_PRODUCT,
5025 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5026 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5027 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5028
5029 RegDeleteValueA(propkey, "AuthorizedLUAApp");
5030 RegDeleteValueA(propkey, "PackageName");
5031 RegDeleteValueA(propkey, "ProductIcon");
5032 RegDeleteValueA(propkey, "Version");
5033 RegDeleteValueA(propkey, "PackageCode");
5034 RegDeleteValueA(propkey, "AssignmentType");
5035 RegDeleteValueA(propkey, "ProductName");
5036 RegDeleteValueA(propkey, "Language");
5037 RegDeleteValueA(propkey, "Transforms");
5038 RegDeleteValueA(propkey, "RegOwner");
5039 RegDeleteValueA(propkey, "RegCompany");
5040 RegDeleteValueA(propkey, "ProductID");
5041 RegDeleteValueA(propkey, "DisplayVersion");
5042 RegDeleteValueA(propkey, "VersionMajor");
5043 RegDeleteValueA(propkey, "VersionMinor");
5044 RegDeleteValueA(propkey, "URLUpdateInfo");
5045 RegDeleteValueA(propkey, "URLInfoAbout");
5046 RegDeleteValueA(propkey, "Publisher");
5047 RegDeleteValueA(propkey, "LocalPackage");
5048 RegDeleteValueA(propkey, "InstallSource");
5049 RegDeleteValueA(propkey, "InstallLocation");
5050 RegDeleteValueA(propkey, "DisplayName");
5051 RegDeleteValueA(propkey, "InstallDate");
5052 RegDeleteValueA(propkey, "HelpTelephone");
5053 RegDeleteValueA(propkey, "HelpLink");
5054 RegDeleteValueA(propkey, "ManagedLocalPackage");
5055 RegDeleteKeyA(propkey, "");
5056 RegCloseKey(propkey);
5057 RegDeleteKeyA(localkey, "");
5058 RegCloseKey(localkey);
5059
5060 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
5061 lstrcatA(keypath, usersid);
5062 lstrcatA(keypath, "\\Installer\\Products\\");
5063 lstrcatA(keypath, prod_squashed);
5064
5065 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
5066 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5067
5068 /* user product key exists */
5069 sz = MAX_PATH;
5070 lstrcpyA(buf, "apple");
5071 r = pMsiGetProductInfoExA(prodcode, usersid,
5072 MSIINSTALLCONTEXT_USERMANAGED,
5073 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5075 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
5076 ok(sz == 1, "Expected 1, got %d\n", sz);
5077
5078 RegDeleteKeyA(userkey, "");
5079 RegCloseKey(userkey);
5080
5081 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
5082 lstrcatA(keypath, prod_squashed);
5083
5084 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
5085 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5086
5087 /* current user product key exists */
5088 sz = MAX_PATH;
5089 lstrcpyA(buf, "apple");
5090 r = pMsiGetProductInfoExA(prodcode, usersid,
5091 MSIINSTALLCONTEXT_USERMANAGED,
5092 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5093 ok(r == ERROR_UNKNOWN_PRODUCT,
5094 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5095 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5096 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5097
5098 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5099 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5100
5101 /* HelpLink value exists, user product key does not exist */
5102 sz = MAX_PATH;
5103 lstrcpyA(buf, "apple");
5104 r = pMsiGetProductInfoExA(prodcode, usersid,
5105 MSIINSTALLCONTEXT_USERMANAGED,
5106 INSTALLPROPERTY_HELPLINK, buf, &sz);
5107 ok(r == ERROR_UNKNOWN_PRODUCT,
5108 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5109 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5110 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5111
5112 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
5113 lstrcatA(keypath, usersid);
5114 lstrcatA(keypath, "\\Installer\\Products\\");
5115 lstrcatA(keypath, prod_squashed);
5116
5117 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
5118 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5119
5120 res = RegSetValueExA(userkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5121 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5122
5123 /* HelpLink value exists, user product key does exist */
5124 sz = MAX_PATH;
5125 lstrcpyA(buf, "apple");
5126 r = pMsiGetProductInfoExA(prodcode, usersid,
5127 MSIINSTALLCONTEXT_USERMANAGED,
5128 INSTALLPROPERTY_HELPLINK, buf, &sz);
5129 ok(r == ERROR_UNKNOWN_PROPERTY,
5130 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5131 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5132 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5133
5134 res = RegSetValueExA(userkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5135 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5136
5137 /* HelpTelephone value exists */
5138 sz = MAX_PATH;
5139 lstrcpyA(buf, "apple");
5140 r = pMsiGetProductInfoExA(prodcode, usersid,
5141 MSIINSTALLCONTEXT_USERMANAGED,
5142 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5143 ok(r == ERROR_UNKNOWN_PROPERTY,
5144 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5145 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5146 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5147
5148 res = RegSetValueExA(userkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5149 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5150
5151 /* InstallDate value exists */
5152 sz = MAX_PATH;
5153 lstrcpyA(buf, "apple");
5154 r = pMsiGetProductInfoExA(prodcode, usersid,
5155 MSIINSTALLCONTEXT_USERMANAGED,
5156 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5157 ok(r == ERROR_UNKNOWN_PROPERTY,
5158 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5159 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5160 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5161
5162 res = RegSetValueExA(userkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5163 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5164
5165 /* DisplayName value exists */
5166 sz = MAX_PATH;
5167 lstrcpyA(buf, "apple");
5168 r = pMsiGetProductInfoExA(prodcode, usersid,
5169 MSIINSTALLCONTEXT_USERMANAGED,
5170 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5171 ok(r == ERROR_UNKNOWN_PROPERTY,
5172 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5173 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5174 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5175
5176 res = RegSetValueExA(userkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5177 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5178
5179 /* InstallLocation value exists */
5180 sz = MAX_PATH;
5181 lstrcpyA(buf, "apple");
5182 r = pMsiGetProductInfoExA(prodcode, usersid,
5183 MSIINSTALLCONTEXT_USERMANAGED,
5184 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5185 ok(r == ERROR_UNKNOWN_PROPERTY,
5186 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5187 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5188 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5189
5190 res = RegSetValueExA(userkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5191 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5192
5193 /* InstallSource value exists */
5194 sz = MAX_PATH;
5195 lstrcpyA(buf, "apple");
5196 r = pMsiGetProductInfoExA(prodcode, usersid,
5197 MSIINSTALLCONTEXT_USERMANAGED,
5198 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5199 ok(r == ERROR_UNKNOWN_PROPERTY,
5200 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5201 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5202 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5203
5204 res = RegSetValueExA(userkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5205 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5206
5207 /* LocalPackage value exists */
5208 sz = MAX_PATH;
5209 lstrcpyA(buf, "apple");
5210 r = pMsiGetProductInfoExA(prodcode, usersid,
5211 MSIINSTALLCONTEXT_USERMANAGED,
5212 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5213 ok(r == ERROR_UNKNOWN_PROPERTY,
5214 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5215 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5216 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5217
5218 res = RegSetValueExA(userkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5219 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5220
5221 /* Publisher value exists */
5222 sz = MAX_PATH;
5223 lstrcpyA(buf, "apple");
5224 r = pMsiGetProductInfoExA(prodcode, usersid,
5225 MSIINSTALLCONTEXT_USERMANAGED,
5226 INSTALLPROPERTY_PUBLISHER, buf, &sz);
5227 ok(r == ERROR_UNKNOWN_PROPERTY,
5228 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5229 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5230 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5231
5232 res = RegSetValueExA(userkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5233 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5234
5235 /* URLInfoAbout value exists */
5236 sz = MAX_PATH;
5237 lstrcpyA(buf, "apple");
5238 r = pMsiGetProductInfoExA(prodcode, usersid,
5239 MSIINSTALLCONTEXT_USERMANAGED,
5240 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5241 ok(r == ERROR_UNKNOWN_PROPERTY,
5242 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5243 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5244 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5245
5246 res = RegSetValueExA(userkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5247 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5248
5249 /* URLUpdateInfo value exists */
5250 sz = MAX_PATH;
5251 lstrcpyA(buf, "apple");
5252 r = pMsiGetProductInfoExA(prodcode, usersid,
5253 MSIINSTALLCONTEXT_USERMANAGED,
5254 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5255 ok(r == ERROR_UNKNOWN_PROPERTY,
5256 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5257 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5258 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5259
5260 res = RegSetValueExA(userkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5261 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5262
5263 /* VersionMinor value exists */
5264 sz = MAX_PATH;
5265 lstrcpyA(buf, "apple");
5266 r = pMsiGetProductInfoExA(prodcode, usersid,
5267 MSIINSTALLCONTEXT_USERMANAGED,
5268 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5269 ok(r == ERROR_UNKNOWN_PROPERTY,
5270 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5271 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5272 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5273
5274 res = RegSetValueExA(userkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5275 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5276
5277 /* VersionMajor value exists */
5278 sz = MAX_PATH;
5279 lstrcpyA(buf, "apple");
5280 r = pMsiGetProductInfoExA(prodcode, usersid,
5281 MSIINSTALLCONTEXT_USERMANAGED,
5282 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5283 ok(r == ERROR_UNKNOWN_PROPERTY,
5284 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5285 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5286 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5287
5288 res = RegSetValueExA(userkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5289 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5290
5291 /* DisplayVersion value exists */
5292 sz = MAX_PATH;
5293 lstrcpyA(buf, "apple");
5294 r = pMsiGetProductInfoExA(prodcode, usersid,
5295 MSIINSTALLCONTEXT_USERMANAGED,
5296 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5297 ok(r == ERROR_UNKNOWN_PROPERTY,
5298 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5299 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5300 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5301
5302 res = RegSetValueExA(userkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5303 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5304
5305 /* ProductID value exists */
5306 sz = MAX_PATH;
5307 lstrcpyA(buf, "apple");
5308 r = pMsiGetProductInfoExA(prodcode, usersid,
5309 MSIINSTALLCONTEXT_USERMANAGED,
5310 INSTALLPROPERTY_PRODUCTID, buf, &sz);
5311 ok(r == ERROR_UNKNOWN_PROPERTY,
5312 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5313 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5314 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5315
5316 res = RegSetValueExA(userkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5317 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5318
5319 /* RegCompany value exists */
5320 sz = MAX_PATH;
5321 lstrcpyA(buf, "apple");
5322 r = pMsiGetProductInfoExA(prodcode, usersid,
5323 MSIINSTALLCONTEXT_USERMANAGED,
5324 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5325 ok(r == ERROR_UNKNOWN_PROPERTY,
5326 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5327 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5328 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5329
5330 res = RegSetValueExA(userkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5331 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5332
5333 /* RegOwner value exists */
5334 sz = MAX_PATH;
5335 lstrcpyA(buf, "apple");
5336 r = pMsiGetProductInfoExA(prodcode, usersid,
5337 MSIINSTALLCONTEXT_USERMANAGED,
5338 INSTALLPROPERTY_REGOWNER, buf, &sz);
5339 ok(r == ERROR_UNKNOWN_PROPERTY,
5340 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5341 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5342 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5343
5344 res = RegSetValueExA(userkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5345 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5346
5347 /* Transforms value exists */
5348 sz = MAX_PATH;
5349 lstrcpyA(buf, "apple");
5350 r = pMsiGetProductInfoExA(prodcode, usersid,
5351 MSIINSTALLCONTEXT_USERMANAGED,
5352 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5354 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
5355 ok(sz == 5, "Expected 5, got %d\n", sz);
5356
5357 res = RegSetValueExA(userkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5358 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5359
5360 /* Language value exists */
5361 sz = MAX_PATH;
5362 lstrcpyA(buf, "apple");
5363 r = pMsiGetProductInfoExA(prodcode, usersid,
5364 MSIINSTALLCONTEXT_USERMANAGED,
5365 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5366 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5367 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
5368 ok(sz == 4, "Expected 4, got %d\n", sz);
5369
5370 res = RegSetValueExA(userkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5371 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5372
5373 /* ProductName value exists */
5374 sz = MAX_PATH;
5375 lstrcpyA(buf, "apple");
5376 r = pMsiGetProductInfoExA(prodcode, usersid,
5377 MSIINSTALLCONTEXT_USERMANAGED,
5378 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5379 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5380 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5381 ok(sz == 4, "Expected 4, got %d\n", sz);
5382
5383 res = RegSetValueExA(userkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5384 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5385
5386 /* FIXME */
5387
5388 /* AssignmentType value exists */
5389 sz = MAX_PATH;
5390 lstrcpyA(buf, "apple");
5391 r = pMsiGetProductInfoExA(prodcode, usersid,
5392 MSIINSTALLCONTEXT_USERMANAGED,
5393 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5394 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5395 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5396 ok(sz == 0, "Expected 0, got %d\n", sz);
5397
5398 res = RegSetValueExA(userkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5399 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5400
5401 /* FIXME */
5402
5403 /* PackageCode value exists */
5404 sz = MAX_PATH;
5405 lstrcpyA(buf, "apple");
5406 r = pMsiGetProductInfoExA(prodcode, usersid,
5407 MSIINSTALLCONTEXT_USERMANAGED,
5408 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5409 todo_wine
5410 {
5411 ok(r == ERROR_BAD_CONFIGURATION,
5412 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
5413 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5414 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5415 }
5416
5417 res = RegSetValueExA(userkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5418 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5419
5420 /* Version value exists */
5421 sz = MAX_PATH;
5422 lstrcpyA(buf, "apple");
5423 r = pMsiGetProductInfoExA(prodcode, usersid,
5424 MSIINSTALLCONTEXT_USERMANAGED,
5425 INSTALLPROPERTY_VERSION, buf, &sz);
5426 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5427 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
5428 ok(sz == 3, "Expected 3, got %d\n", sz);
5429
5430 res = RegSetValueExA(userkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5431 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5432
5433 /* ProductIcon value exists */
5434 sz = MAX_PATH;
5435 lstrcpyA(buf, "apple");
5436 r = pMsiGetProductInfoExA(prodcode, usersid,
5437 MSIINSTALLCONTEXT_USERMANAGED,
5438 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5439 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5440 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
5441 ok(sz == 4, "Expected 4, got %d\n", sz);
5442
5443 res = RegSetValueExA(userkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5444 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5445
5446 /* PackageName value exists */
5447 sz = MAX_PATH;
5448 lstrcpyA(buf, "apple");
5449 r = pMsiGetProductInfoExA(prodcode, usersid,
5450 MSIINSTALLCONTEXT_USERMANAGED,
5451 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5452 todo_wine
5453 {
5454 ok(r == ERROR_UNKNOWN_PRODUCT,
5455 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5456 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5457 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5458 }
5459
5460 res = RegSetValueExA(userkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5461 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5462
5463 /* AuthorizedLUAApp value exists */
5464 sz = MAX_PATH;
5465 lstrcpyA(buf, "apple");
5466 r = pMsiGetProductInfoExA(prodcode, usersid,
5467 MSIINSTALLCONTEXT_USERMANAGED,
5468 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5469 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5470 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
5471 ok(sz == 4, "Expected 4, got %d\n", sz);
5472
5473 RegDeleteValueA(userkey, "AuthorizedLUAApp");
5474 RegDeleteValueA(userkey, "PackageName");
5475 RegDeleteValueA(userkey, "ProductIcon");
5476 RegDeleteValueA(userkey, "Version");
5477 RegDeleteValueA(userkey, "PackageCode");
5478 RegDeleteValueA(userkey, "AssignmentType");
5479 RegDeleteValueA(userkey, "ProductName");
5480 RegDeleteValueA(userkey, "Language");
5481 RegDeleteValueA(userkey, "Transforms");
5482 RegDeleteValueA(userkey, "RegOwner");
5483 RegDeleteValueA(userkey, "RegCompany");
5484 RegDeleteValueA(userkey, "ProductID");
5485 RegDeleteValueA(userkey, "DisplayVersion");
5486 RegDeleteValueA(userkey, "VersionMajor");
5487 RegDeleteValueA(userkey, "VersionMinor");
5488 RegDeleteValueA(userkey, "URLUpdateInfo");
5489 RegDeleteValueA(userkey, "URLInfoAbout");
5490 RegDeleteValueA(userkey, "Publisher");
5491 RegDeleteValueA(userkey, "LocalPackage");
5492 RegDeleteValueA(userkey, "InstallSource");
5493 RegDeleteValueA(userkey, "InstallLocation");
5494 RegDeleteValueA(userkey, "DisplayName");
5495 RegDeleteValueA(userkey, "InstallDate");
5496 RegDeleteValueA(userkey, "HelpTelephone");
5497 RegDeleteValueA(userkey, "HelpLink");
5498 RegDeleteKeyA(userkey, "");
5499 RegCloseKey(userkey);
5500 RegDeleteKeyA(prodkey, "");
5501 RegCloseKey(prodkey);
5502
5503 /* MSIINSTALLCONTEXT_MACHINE */
5504
5505 /* szUserSid is non-NULL */
5506 sz = MAX_PATH;
5507 lstrcpyA(buf, "apple");
5508 r = pMsiGetProductInfoExA(prodcode, usersid,
5509 MSIINSTALLCONTEXT_MACHINE,
5510 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5511 ok(r == ERROR_INVALID_PARAMETER,
5512 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5513 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5514 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5515
5516 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
5517 lstrcatA(keypath, prod_squashed);
5518
5519 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
5520 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5521
5522 /* local system product key exists */
5523 sz = MAX_PATH;
5524 lstrcpyA(buf, "apple");
5525 r = pMsiGetProductInfoExA(prodcode, NULL,
5526 MSIINSTALLCONTEXT_MACHINE,
5527 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5528 ok(r == ERROR_UNKNOWN_PRODUCT,
5529 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5530 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5531 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5532
5533 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
5534 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5535
5536 /* InstallProperties key exists */
5537 sz = MAX_PATH;
5538 lstrcpyA(buf, "apple");
5539 r = pMsiGetProductInfoExA(prodcode, NULL,
5540 MSIINSTALLCONTEXT_MACHINE,
5541 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5542 ok(r == ERROR_UNKNOWN_PRODUCT,
5543 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5544 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5545 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5546
5547 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5548 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5549
5550 /* LocalPackage value exists */
5551 sz = MAX_PATH;
5552 lstrcpyA(buf, "apple");
5553 r = pMsiGetProductInfoExA(prodcode, NULL,
5554 MSIINSTALLCONTEXT_MACHINE,
5555 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5556 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5557 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
5558 ok(sz == 1, "Expected 1, got %d\n", sz);
5559
5560 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5561 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5562
5563 /* HelpLink value exists */
5564 sz = MAX_PATH;
5565 lstrcpyA(buf, "apple");
5566 r = pMsiGetProductInfoExA(prodcode, NULL,
5567 MSIINSTALLCONTEXT_MACHINE,
5568 INSTALLPROPERTY_HELPLINK, buf, &sz);
5569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5570 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
5571 ok(sz == 4, "Expected 4, got %d\n", sz);
5572
5573 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5574 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5575
5576 /* HelpTelephone value exists */
5577 sz = MAX_PATH;
5578 lstrcpyA(buf, "apple");
5579 r = pMsiGetProductInfoExA(prodcode, NULL,
5580 MSIINSTALLCONTEXT_MACHINE,
5581 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5583 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
5584 ok(sz == 5, "Expected 5, got %d\n", sz);
5585
5586 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5587 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5588
5589 /* InstallDate value exists */
5590 sz = MAX_PATH;
5591 lstrcpyA(buf, "apple");
5592 r = pMsiGetProductInfoExA(prodcode, NULL,
5593 MSIINSTALLCONTEXT_MACHINE,
5594 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5595 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5596 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
5597 ok(sz == 4, "Expected 4, got %d\n", sz);
5598
5599 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5600 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5601
5602 /* DisplayName value exists */
5603 sz = MAX_PATH;
5604 lstrcpyA(buf, "apple");
5605 r = pMsiGetProductInfoExA(prodcode, NULL,
5606 MSIINSTALLCONTEXT_MACHINE,
5607 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5608 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5609 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5610 ok(sz == 4, "Expected 4, got %d\n", sz);
5611
5612 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5613 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5614
5615 /* InstallLocation value exists */
5616 sz = MAX_PATH;
5617 lstrcpyA(buf, "apple");
5618 r = pMsiGetProductInfoExA(prodcode, NULL,
5619 MSIINSTALLCONTEXT_MACHINE,
5620 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5621 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5622 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
5623 ok(sz == 3, "Expected 3, got %d\n", sz);
5624
5625 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5626 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5627
5628 /* InstallSource value exists */
5629 sz = MAX_PATH;
5630 lstrcpyA(buf, "apple");
5631 r = pMsiGetProductInfoExA(prodcode, NULL,
5632 MSIINSTALLCONTEXT_MACHINE,
5633 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5634 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5635 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
5636 ok(sz == 6, "Expected 6, got %d\n", sz);
5637
5638 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5639 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5640
5641 /* LocalPackage value exists */
5642 sz = MAX_PATH;
5643 lstrcpyA(buf, "apple");
5644 r = pMsiGetProductInfoExA(prodcode, NULL,
5645 MSIINSTALLCONTEXT_MACHINE,
5646 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5647 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5648 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
5649 ok(sz == 5, "Expected 5, got %d\n", sz);
5650
5651 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5652 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5653
5654 /* Publisher value exists */
5655 sz = MAX_PATH;
5656 lstrcpyA(buf, "apple");
5657 r = pMsiGetProductInfoExA(prodcode, NULL,
5658 MSIINSTALLCONTEXT_MACHINE,
5659 INSTALLPROPERTY_PUBLISHER, buf, &sz);
5660 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5661 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
5662 ok(sz == 3, "Expected 3, got %d\n", sz);
5663
5664 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5665 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5666
5667 /* URLInfoAbout value exists */
5668 sz = MAX_PATH;
5669 lstrcpyA(buf, "apple");
5670 r = pMsiGetProductInfoExA(prodcode, NULL,
5671 MSIINSTALLCONTEXT_MACHINE,
5672 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5673 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5674 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
5675 ok(sz == 5, "Expected 5, got %d\n", sz);
5676
5677 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5678 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5679
5680 /* URLUpdateInfo value exists */
5681 sz = MAX_PATH;
5682 lstrcpyA(buf, "apple");
5683 r = pMsiGetProductInfoExA(prodcode, NULL,
5684 MSIINSTALLCONTEXT_MACHINE,
5685 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5686 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5687 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
5688 ok(sz == 6, "Expected 6, got %d\n", sz);
5689
5690 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5691 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5692
5693 /* VersionMinor value exists */
5694 sz = MAX_PATH;
5695 lstrcpyA(buf, "apple");
5696 r = pMsiGetProductInfoExA(prodcode, NULL,
5697 MSIINSTALLCONTEXT_MACHINE,
5698 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5699 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5700 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
5701 ok(sz == 1, "Expected 1, got %d\n", sz);
5702
5703 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5704 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5705
5706 /* VersionMajor value exists */
5707 sz = MAX_PATH;
5708 lstrcpyA(buf, "apple");
5709 r = pMsiGetProductInfoExA(prodcode, NULL,
5710 MSIINSTALLCONTEXT_MACHINE,
5711 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5712 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5713 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5714 ok(sz == 1, "Expected 1, got %d\n", sz);
5715
5716 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5717 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5718
5719 /* DisplayVersion value exists */
5720 sz = MAX_PATH;
5721 lstrcpyA(buf, "apple");
5722 r = pMsiGetProductInfoExA(prodcode, NULL,
5723 MSIINSTALLCONTEXT_MACHINE,
5724 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5725 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5726 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
5727 ok(sz == 5, "Expected 5, got %d\n", sz);
5728
5729 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5730 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5731
5732 /* ProductID value exists */
5733 sz = MAX_PATH;
5734 lstrcpyA(buf, "apple");
5735 r = pMsiGetProductInfoExA(prodcode, NULL,
5736 MSIINSTALLCONTEXT_MACHINE,
5737 INSTALLPROPERTY_PRODUCTID, buf, &sz);
5738 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5739 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
5740 ok(sz == 2, "Expected 2, got %d\n", sz);
5741
5742 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5743 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5744
5745 /* RegCompany value exists */
5746 sz = MAX_PATH;
5747 lstrcpyA(buf, "apple");
5748 r = pMsiGetProductInfoExA(prodcode, NULL,
5749 MSIINSTALLCONTEXT_MACHINE,
5750 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5751 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5752 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
5753 ok(sz == 4, "Expected 4, got %d\n", sz);
5754
5755 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5756 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5757
5758 /* RegOwner value exists */
5759 sz = MAX_PATH;
5760 lstrcpyA(buf, "apple");
5761 r = pMsiGetProductInfoExA(prodcode, NULL,
5762 MSIINSTALLCONTEXT_MACHINE,
5763 INSTALLPROPERTY_REGOWNER, buf, &sz);
5764 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5765 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
5766 ok(sz == 5, "Expected 5, got %d\n", sz);
5767
5768 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5769 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5770
5771 /* Transforms value exists */
5772 sz = MAX_PATH;
5773 lstrcpyA(buf, "apple");
5774 r = pMsiGetProductInfoExA(prodcode, NULL,
5775 MSIINSTALLCONTEXT_MACHINE,
5776 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5777 ok(r == ERROR_UNKNOWN_PRODUCT,
5778 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5779 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5780 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5781
5782 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5783 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5784
5785 /* Language value exists */
5786 sz = MAX_PATH;
5787 lstrcpyA(buf, "apple");
5788 r = pMsiGetProductInfoExA(prodcode, NULL,
5789 MSIINSTALLCONTEXT_MACHINE,
5790 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5791 ok(r == ERROR_UNKNOWN_PRODUCT,
5792 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5793 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5794 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5795
5796 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5797 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5798
5799 /* ProductName value exists */
5800 sz = MAX_PATH;
5801 lstrcpyA(buf, "apple");
5802 r = pMsiGetProductInfoExA(prodcode, NULL,
5803 MSIINSTALLCONTEXT_MACHINE,
5804 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5805 ok(r == ERROR_UNKNOWN_PRODUCT,
5806 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5807 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5808 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5809
5810 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5811 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5812
5813 /* FIXME */
5814
5815 /* AssignmentType value exists */
5816 sz = MAX_PATH;
5817 lstrcpyA(buf, "apple");
5818 r = pMsiGetProductInfoExA(prodcode, NULL,
5819 MSIINSTALLCONTEXT_MACHINE,
5820 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5821 ok(r == ERROR_UNKNOWN_PRODUCT,
5822 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5823 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5824 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5825
5826 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5827 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5828
5829 /* PackageCode value exists */
5830 sz = MAX_PATH;
5831 lstrcpyA(buf, "apple");
5832 r = pMsiGetProductInfoExA(prodcode, NULL,
5833 MSIINSTALLCONTEXT_MACHINE,
5834 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5835 ok(r == ERROR_UNKNOWN_PRODUCT,
5836 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5837 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5838 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5839
5840 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5841 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5842
5843 /* Version value exists */
5844 sz = MAX_PATH;
5845 lstrcpyA(buf, "apple");
5846 r = pMsiGetProductInfoExA(prodcode, NULL,
5847 MSIINSTALLCONTEXT_MACHINE,
5848 INSTALLPROPERTY_VERSION, buf, &sz);
5849 ok(r == ERROR_UNKNOWN_PRODUCT,
5850 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5851 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5852 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5853
5854 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5855 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5856
5857 /* ProductIcon value exists */
5858 sz = MAX_PATH;
5859 lstrcpyA(buf, "apple");
5860 r = pMsiGetProductInfoExA(prodcode, NULL,
5861 MSIINSTALLCONTEXT_MACHINE,
5862 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5863 ok(r == ERROR_UNKNOWN_PRODUCT,
5864 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5865 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5866 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5867
5868 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5869 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5870
5871 /* PackageName value exists */
5872 sz = MAX_PATH;
5873 lstrcpyA(buf, "apple");
5874 r = pMsiGetProductInfoExA(prodcode, NULL,
5875 MSIINSTALLCONTEXT_MACHINE,
5876 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5877 ok(r == ERROR_UNKNOWN_PRODUCT,
5878 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5879 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5880 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5881
5882 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5883 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5884
5885 /* AuthorizedLUAApp value exists */
5886 sz = MAX_PATH;
5887 lstrcpyA(buf, "apple");
5888 r = pMsiGetProductInfoExA(prodcode, NULL,
5889 MSIINSTALLCONTEXT_MACHINE,
5890 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5891 ok(r == ERROR_UNKNOWN_PRODUCT,
5892 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5893 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5894 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5895
5896 RegDeleteValueA(propkey, "AuthorizedLUAApp");
5897 RegDeleteValueA(propkey, "PackageName");
5898 RegDeleteValueA(propkey, "ProductIcon");
5899 RegDeleteValueA(propkey, "Version");
5900 RegDeleteValueA(propkey, "PackageCode");
5901 RegDeleteValueA(propkey, "AssignmentType");
5902 RegDeleteValueA(propkey, "ProductName");
5903 RegDeleteValueA(propkey, "Language");
5904 RegDeleteValueA(propkey, "Transforms");
5905 RegDeleteValueA(propkey, "RegOwner");
5906 RegDeleteValueA(propkey, "RegCompany");
5907 RegDeleteValueA(propkey, "ProductID");
5908 RegDeleteValueA(propkey, "DisplayVersion");
5909 RegDeleteValueA(propkey, "VersionMajor");
5910 RegDeleteValueA(propkey, "VersionMinor");
5911 RegDeleteValueA(propkey, "URLUpdateInfo");
5912 RegDeleteValueA(propkey, "URLInfoAbout");
5913 RegDeleteValueA(propkey, "Publisher");
5914 RegDeleteValueA(propkey, "LocalPackage");
5915 RegDeleteValueA(propkey, "InstallSource");
5916 RegDeleteValueA(propkey, "InstallLocation");
5917 RegDeleteValueA(propkey, "DisplayName");
5918 RegDeleteValueA(propkey, "InstallDate");
5919 RegDeleteValueA(propkey, "HelpTelephone");
5920 RegDeleteValueA(propkey, "HelpLink");
5921 RegDeleteValueA(propkey, "LocalPackage");
5922 RegDeleteKeyA(propkey, "");
5923 RegCloseKey(propkey);
5924 RegDeleteKeyA(localkey, "");
5925 RegCloseKey(localkey);
5926
5927 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
5928 lstrcatA(keypath, prod_squashed);
5929
5930 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
5931 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5932
5933 /* local classes product key exists */
5934 sz = MAX_PATH;
5935 lstrcpyA(buf, "apple");
5936 r = pMsiGetProductInfoExA(prodcode, NULL,
5937 MSIINSTALLCONTEXT_MACHINE,
5938 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5939 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5940 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
5941 ok(sz == 1, "Expected 1, got %d\n", sz);
5942
5943 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5944 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5945
5946 /* HelpLink value exists */
5947 sz = MAX_PATH;
5948 lstrcpyA(buf, "apple");
5949 r = pMsiGetProductInfoExA(prodcode, NULL,
5950 MSIINSTALLCONTEXT_MACHINE,
5951 INSTALLPROPERTY_HELPLINK, buf, &sz);
5952 ok(r == ERROR_UNKNOWN_PROPERTY,
5953 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5954 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5955 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5956
5957 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5958 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5959
5960 /* HelpTelephone value exists */
5961 sz = MAX_PATH;
5962 lstrcpyA(buf, "apple");
5963 r = pMsiGetProductInfoExA(prodcode, NULL,
5964 MSIINSTALLCONTEXT_MACHINE,
5965 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5966 ok(r == ERROR_UNKNOWN_PROPERTY,
5967 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5968 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5969 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5970
5971 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5972 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5973
5974 /* InstallDate value exists */
5975 sz = MAX_PATH;
5976 lstrcpyA(buf, "apple");
5977 r = pMsiGetProductInfoExA(prodcode, NULL,
5978 MSIINSTALLCONTEXT_MACHINE,
5979 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5980 ok(r == ERROR_UNKNOWN_PROPERTY,
5981 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5982 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5983 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5984
5985 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5986 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5987
5988 /* DisplayName value exists */
5989 sz = MAX_PATH;
5990 lstrcpyA(buf, "apple");
5991 r = pMsiGetProductInfoExA(prodcode, NULL,
5992 MSIINSTALLCONTEXT_MACHINE,
5993 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5994 ok(r == ERROR_UNKNOWN_PROPERTY,
5995 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5996 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5997 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5998
5999 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6000 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6001
6002 /* InstallLocation value exists */
6003 sz = MAX_PATH;
6004 lstrcpyA(buf, "apple");
6005 r = pMsiGetProductInfoExA(prodcode, NULL,
6006 MSIINSTALLCONTEXT_MACHINE,
6007 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
6008 ok(r == ERROR_UNKNOWN_PROPERTY,
6009 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6010 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6011 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6012
6013 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6014 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6015
6016 /* InstallSource value exists */
6017 sz = MAX_PATH;
6018 lstrcpyA(buf, "apple");
6019 r = pMsiGetProductInfoExA(prodcode, NULL,
6020 MSIINSTALLCONTEXT_MACHINE,
6021 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
6022 ok(r == ERROR_UNKNOWN_PROPERTY,
6023 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6024 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6025 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6026
6027 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6028 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6029
6030 /* LocalPackage value exists */
6031 sz = MAX_PATH;
6032 lstrcpyA(buf, "apple");
6033 r = pMsiGetProductInfoExA(prodcode, NULL,
6034 MSIINSTALLCONTEXT_MACHINE,
6035 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
6036 ok(r == ERROR_UNKNOWN_PROPERTY,
6037 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6038 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6039 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6040
6041 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6042 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6043
6044 /* Publisher value exists */
6045 sz = MAX_PATH;
6046 lstrcpyA(buf, "apple");
6047 r = pMsiGetProductInfoExA(prodcode, NULL,
6048 MSIINSTALLCONTEXT_MACHINE,
6049 INSTALLPROPERTY_PUBLISHER, buf, &sz);
6050 ok(r == ERROR_UNKNOWN_PROPERTY,
6051 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6052 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6053 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6054
6055 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6056 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6057
6058 /* URLInfoAbout value exists */
6059 sz = MAX_PATH;
6060 lstrcpyA(buf, "apple");
6061 r = pMsiGetProductInfoExA(prodcode, NULL,
6062 MSIINSTALLCONTEXT_MACHINE,
6063 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
6064 ok(r == ERROR_UNKNOWN_PROPERTY,
6065 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6066 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6067 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6068
6069 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6070 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6071
6072 /* URLUpdateInfo value exists */
6073 sz = MAX_PATH;
6074 lstrcpyA(buf, "apple");
6075 r = pMsiGetProductInfoExA(prodcode, NULL,
6076 MSIINSTALLCONTEXT_MACHINE,
6077 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
6078 ok(r == ERROR_UNKNOWN_PROPERTY,
6079 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6080 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6081 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6082
6083 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6084 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6085
6086 /* VersionMinor value exists */
6087 sz = MAX_PATH;
6088 lstrcpyA(buf, "apple");
6089 r = pMsiGetProductInfoExA(prodcode, NULL,
6090 MSIINSTALLCONTEXT_MACHINE,
6091 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
6092 ok(r == ERROR_UNKNOWN_PROPERTY,
6093 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6094 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6095 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6096
6097 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6098 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6099
6100 /* VersionMajor value exists */
6101 sz = MAX_PATH;
6102 lstrcpyA(buf, "apple");
6103 r = pMsiGetProductInfoExA(prodcode, NULL,
6104 MSIINSTALLCONTEXT_MACHINE,
6105 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
6106 ok(r == ERROR_UNKNOWN_PROPERTY,
6107 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6108 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6109 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6110
6111 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6112 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6113
6114 /* DisplayVersion value exists */
6115 sz = MAX_PATH;
6116 lstrcpyA(buf, "apple");
6117 r = pMsiGetProductInfoExA(prodcode, NULL,
6118 MSIINSTALLCONTEXT_MACHINE,
6119 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
6120 ok(r == ERROR_UNKNOWN_PROPERTY,
6121 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6122 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6123 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6124
6125 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6126 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6127
6128 /* ProductID value exists */
6129 sz = MAX_PATH;
6130 lstrcpyA(buf, "apple");
6131 r = pMsiGetProductInfoExA(prodcode, NULL,
6132 MSIINSTALLCONTEXT_MACHINE,
6133 INSTALLPROPERTY_PRODUCTID, buf, &sz);
6134 ok(r == ERROR_UNKNOWN_PROPERTY,
6135 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6136 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6137 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6138
6139 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6140 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6141
6142 /* RegCompany value exists */
6143 sz = MAX_PATH;
6144 lstrcpyA(buf, "apple");
6145 r = pMsiGetProductInfoExA(prodcode, NULL,
6146 MSIINSTALLCONTEXT_MACHINE,
6147 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
6148 ok(r == ERROR_UNKNOWN_PROPERTY,
6149 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6150 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6151 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6152
6153 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6154 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6155
6156 /* RegOwner value exists */
6157 sz = MAX_PATH;
6158 lstrcpyA(buf, "apple");
6159 r = pMsiGetProductInfoExA(prodcode, NULL,
6160 MSIINSTALLCONTEXT_MACHINE,
6161 INSTALLPROPERTY_REGOWNER, buf, &sz);
6162 ok(r == ERROR_UNKNOWN_PROPERTY,
6163 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6164 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6165 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6166
6167 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6168 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6169
6170 /* Transforms value exists */
6171 sz = MAX_PATH;
6172 lstrcpyA(buf, "apple");
6173 r = pMsiGetProductInfoExA(prodcode, NULL,
6174 MSIINSTALLCONTEXT_MACHINE,
6175 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
6176 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6177 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
6178 ok(sz == 5, "Expected 5, got %d\n", sz);
6179
6180 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6181 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6182
6183 /* Language value exists */
6184 sz = MAX_PATH;
6185 lstrcpyA(buf, "apple");
6186 r = pMsiGetProductInfoExA(prodcode, NULL,
6187 MSIINSTALLCONTEXT_MACHINE,
6188 INSTALLPROPERTY_LANGUAGE, buf, &sz);
6189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6190 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
6191 ok(sz == 4, "Expected 4, got %d\n", sz);
6192
6193 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6194 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6195
6196 /* ProductName value exists */
6197 sz = MAX_PATH;
6198 lstrcpyA(buf, "apple");
6199 r = pMsiGetProductInfoExA(prodcode, NULL,
6200 MSIINSTALLCONTEXT_MACHINE,
6201 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
6202 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6203 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6204 ok(sz == 4, "Expected 4, got %d\n", sz);
6205
6206 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6207 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6208
6209 /* FIXME */
6210
6211 /* AssignmentType value exists */
6212 sz = MAX_PATH;
6213 lstrcpyA(buf, "apple");
6214 r = pMsiGetProductInfoExA(prodcode, NULL,
6215 MSIINSTALLCONTEXT_MACHINE,
6216 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
6217 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6218 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
6219 ok(sz == 0, "Expected 0, got %d\n", sz);
6220
6221 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6222 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6223
6224 /* FIXME */
6225
6226 /* PackageCode value exists */
6227 sz = MAX_PATH;
6228 lstrcpyA(buf, "apple");
6229 r = pMsiGetProductInfoExA(prodcode, NULL,
6230 MSIINSTALLCONTEXT_MACHINE,
6231 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
6232 todo_wine
6233 {
6234 ok(r == ERROR_BAD_CONFIGURATION,
6235 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
6236 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6237 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6238 }
6239
6240 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6241 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6242
6243 /* Version value exists */
6244 sz = MAX_PATH;
6245 lstrcpyA(buf, "apple");
6246 r = pMsiGetProductInfoExA(prodcode, NULL,
6247 MSIINSTALLCONTEXT_MACHINE,
6248 INSTALLPROPERTY_VERSION, buf, &sz);
6249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6250 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
6251 ok(sz == 3, "Expected 3, got %d\n", sz);
6252
6253 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6254 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6255
6256 /* ProductIcon value exists */
6257 sz = MAX_PATH;
6258 lstrcpyA(buf, "apple");
6259 r = pMsiGetProductInfoExA(prodcode, NULL,
6260 MSIINSTALLCONTEXT_MACHINE,
6261 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
6262 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6263 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
6264 ok(sz == 4, "Expected 4, got %d\n", sz);
6265
6266 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6267 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6268
6269 /* PackageName value exists */
6270 sz = MAX_PATH;
6271 lstrcpyA(buf, "apple");
6272 r = pMsiGetProductInfoExA(prodcode, NULL,
6273 MSIINSTALLCONTEXT_MACHINE,
6274 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
6275 todo_wine
6276 {
6277 ok(r == ERROR_UNKNOWN_PRODUCT,
6278 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6279 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6280 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6281 }
6282
6283 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6284 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6285
6286 /* AuthorizedLUAApp value exists */
6287 sz = MAX_PATH;
6288 lstrcpyA(buf, "apple");
6289 r = pMsiGetProductInfoExA(prodcode, NULL,
6290 MSIINSTALLCONTEXT_MACHINE,
6291 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
6292 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6293 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
6294 ok(sz == 4, "Expected 4, got %d\n", sz);
6295
6296 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
6297 RegDeleteValueA(prodkey, "PackageName");
6298 RegDeleteValueA(prodkey, "ProductIcon");
6299 RegDeleteValueA(prodkey, "Version");
6300 RegDeleteValueA(prodkey, "PackageCode");
6301 RegDeleteValueA(prodkey, "AssignmentType");
6302 RegDeleteValueA(prodkey, "ProductName");
6303 RegDeleteValueA(prodkey, "Language");
6304 RegDeleteValueA(prodkey, "Transforms");
6305 RegDeleteValueA(prodkey, "RegOwner");
6306 RegDeleteValueA(prodkey, "RegCompany");
6307 RegDeleteValueA(prodkey, "ProductID");
6308 RegDeleteValueA(prodkey, "DisplayVersion");
6309 RegDeleteValueA(prodkey, "VersionMajor");
6310 RegDeleteValueA(prodkey, "VersionMinor");
6311 RegDeleteValueA(prodkey, "URLUpdateInfo");
6312 RegDeleteValueA(prodkey, "URLInfoAbout");
6313 RegDeleteValueA(prodkey, "Publisher");
6314 RegDeleteValueA(prodkey, "LocalPackage");
6315 RegDeleteValueA(prodkey, "InstallSource");
6316 RegDeleteValueA(prodkey, "InstallLocation");
6317 RegDeleteValueA(prodkey, "DisplayName");
6318 RegDeleteValueA(prodkey, "InstallDate");
6319 RegDeleteValueA(prodkey, "HelpTelephone");
6320 RegDeleteValueA(prodkey, "HelpLink");
6321 RegDeleteKeyA(prodkey, "");
6322 RegCloseKey(prodkey);
6323 }
6324
6325 #define INIT_USERINFO() \
6326 lstrcpyA(user, "apple"); \
6327 lstrcpyA(org, "orange"); \
6328 lstrcpyA(serial, "banana"); \
6329 usersz = orgsz = serialsz = MAX_PATH;
6330
6331 static void test_MsiGetUserInfo(void)
6332 {
6333 USERINFOSTATE state;
6334 CHAR user[MAX_PATH];
6335 CHAR org[MAX_PATH];
6336 CHAR serial[MAX_PATH];
6337 DWORD usersz, orgsz, serialsz;
6338 CHAR keypath[MAX_PATH * 2];
6339 CHAR prodcode[MAX_PATH];
6340 CHAR prod_squashed[MAX_PATH];
6341 HKEY prodkey, userprod, props;
6342 LPSTR usersid;
6343 LONG res;
6344
6345 create_test_guid(prodcode, prod_squashed);
6346 get_user_sid(&usersid);
6347
6348 /* NULL szProduct */
6349 INIT_USERINFO();
6350 state = MsiGetUserInfoA(NULL, user, &usersz, org, &orgsz, serial, &serialsz);
6351 ok(state == USERINFOSTATE_INVALIDARG,
6352 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6353 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6354 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6355 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6356 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6357 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6358 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6359
6360 /* empty szProductCode */
6361 INIT_USERINFO();
6362 state = MsiGetUserInfoA("", user, &usersz, org, &orgsz, serial, &serialsz);
6363 ok(state == USERINFOSTATE_INVALIDARG,
6364 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6365 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6366 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6367 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6368 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6369 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6370 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6371
6372 /* garbage szProductCode */
6373 INIT_USERINFO();
6374 state = MsiGetUserInfoA("garbage", user, &usersz, org, &orgsz, serial, &serialsz);
6375 ok(state == USERINFOSTATE_INVALIDARG,
6376 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6377 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6378 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6379 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6380 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6381 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6382 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6383
6384 /* guid without brackets */
6385 INIT_USERINFO();
6386 state = MsiGetUserInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
6387 user, &usersz, org, &orgsz, serial, &serialsz);
6388 ok(state == USERINFOSTATE_INVALIDARG,
6389 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6390 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6391 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6392 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6393 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6394 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6395 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6396
6397 /* guid with brackets */
6398 INIT_USERINFO();
6399 state = MsiGetUserInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
6400 user, &usersz, org, &orgsz, serial, &serialsz);
6401 ok(state == USERINFOSTATE_UNKNOWN,
6402 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6403 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6404 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6405 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6406 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6407 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6408 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6409
6410 /* NULL lpUserNameBuf */
6411 INIT_USERINFO();
6412 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
6413 ok(state == USERINFOSTATE_UNKNOWN,
6414 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6415 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6416 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6417 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6418 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6419 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6420
6421 /* NULL pcchUserNameBuf */
6422 INIT_USERINFO();
6423 state = MsiGetUserInfoA(prodcode, user, NULL, org, &orgsz, serial, &serialsz);
6424 ok(state == USERINFOSTATE_INVALIDARG,
6425 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6426 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6427 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6428 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6429 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6430 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6431
6432 /* both lpUserNameBuf and pcchUserNameBuf NULL */
6433 INIT_USERINFO();
6434 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6435 ok(state == USERINFOSTATE_UNKNOWN,
6436 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6437 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6438 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6439 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6440 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6441
6442 /* NULL lpOrgNameBuf */
6443 INIT_USERINFO();
6444 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, &orgsz, serial, &serialsz);
6445 ok(state == USERINFOSTATE_UNKNOWN,
6446 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6447 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6448 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6449 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6450 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6451 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6452
6453 /* NULL pcchOrgNameBuf */
6454 INIT_USERINFO();
6455 state = MsiGetUserInfoA(prodcode, user, &usersz, org, NULL, serial, &serialsz);
6456 ok(state == USERINFOSTATE_INVALIDARG,
6457 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6458 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6459 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6460 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6461 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6462 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6463
6464 /* both lpOrgNameBuf and pcchOrgNameBuf NULL */
6465 INIT_USERINFO();
6466 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, NULL, serial, &serialsz);
6467 ok(state == USERINFOSTATE_UNKNOWN,
6468 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6469 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6470 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6471 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6472 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6473
6474 /* NULL lpSerialBuf */
6475 INIT_USERINFO();
6476 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, &serialsz);
6477 ok(state == USERINFOSTATE_UNKNOWN,
6478 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6479 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6480 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6481 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6482 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6483 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6484
6485 /* NULL pcchSerialBuf */
6486 INIT_USERINFO();
6487 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, NULL);
6488 ok(state == USERINFOSTATE_INVALIDARG,
6489 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6490 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6491 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6492 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6493 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6494 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6495
6496 /* both lpSerialBuf and pcchSerialBuf NULL */
6497 INIT_USERINFO();
6498 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, NULL);
6499 ok(state == USERINFOSTATE_UNKNOWN,
6500 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6501 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6502 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6503 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6504 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6505
6506 /* MSIINSTALLCONTEXT_USERMANAGED */
6507
6508 /* create local system product key */
6509 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6510 lstrcatA(keypath, usersid);
6511 lstrcatA(keypath, "\\Installer\\Products\\");
6512 lstrcatA(keypath, prod_squashed);
6513
6514 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6515 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6516
6517 /* managed product key exists */
6518 INIT_USERINFO();
6519 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6520 ok(state == USERINFOSTATE_ABSENT,
6521 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6522 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6523 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6524 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6525 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6526 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6527 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6528
6529 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6530 lstrcatA(keypath, "Installer\\UserData\\");
6531 lstrcatA(keypath, usersid);
6532 lstrcatA(keypath, "\\Products\\");
6533 lstrcatA(keypath, prod_squashed);
6534
6535 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6536 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6537
6538 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6539 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6540
6541 /* InstallProperties key exists */
6542 INIT_USERINFO();
6543 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6544 ok(state == USERINFOSTATE_ABSENT,
6545 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6546 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6547 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6548 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6549 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6550 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6551 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6552
6553 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6554 INIT_USERINFO();
6555 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6556 ok(state == USERINFOSTATE_ABSENT,
6557 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6558 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6559 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6560 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6561 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6562
6563 /* RegOwner, RegCompany don't exist, out params are NULL */
6564 INIT_USERINFO();
6565 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6566 ok(state == USERINFOSTATE_ABSENT,
6567 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6568 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6569 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6570
6571 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6572 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6573
6574 /* RegOwner value exists */
6575 INIT_USERINFO();
6576 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6577 ok(state == USERINFOSTATE_ABSENT,
6578 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6579 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6580 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6581 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6582 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6583 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6584 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6585
6586 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6587 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6588
6589 /* RegCompany value exists */
6590 INIT_USERINFO();
6591 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6592 ok(state == USERINFOSTATE_ABSENT,
6593 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6594 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6595 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6596 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6597 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6598 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6599 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6600
6601 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6602 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6603
6604 /* ProductID value exists */
6605 INIT_USERINFO();
6606 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6607 ok(state == USERINFOSTATE_PRESENT,
6608 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6609 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6610 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6611 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6612 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6613 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6614 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6615
6616 /* pcchUserNameBuf is too small */
6617 INIT_USERINFO();
6618 usersz = 0;
6619 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6620 ok(state == USERINFOSTATE_MOREDATA,
6621 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
6622 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6623 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6624 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6625 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6626 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6627 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6628
6629 /* pcchUserNameBuf has no room for NULL terminator */
6630 INIT_USERINFO();
6631 usersz = 5;
6632 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6633 ok(state == USERINFOSTATE_MOREDATA,
6634 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
6635 todo_wine
6636 {
6637 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6638 }
6639 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6640 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6641 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6642 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6643 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6644
6645 /* pcchUserNameBuf is too small, lpUserNameBuf is NULL */
6646 INIT_USERINFO();
6647 usersz = 0;
6648 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
6649 ok(state == USERINFOSTATE_PRESENT,
6650 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6651 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6652 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6653 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6654 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6655 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6656 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6657
6658 RegDeleteValueA(props, "ProductID");
6659 RegDeleteValueA(props, "RegCompany");
6660 RegDeleteValueA(props, "RegOwner");
6661 RegDeleteKeyA(props, "");
6662 RegCloseKey(props);
6663 RegDeleteKeyA(userprod, "");
6664 RegCloseKey(userprod);
6665 RegDeleteKeyA(prodkey, "");
6666 RegCloseKey(prodkey);
6667
6668 /* MSIINSTALLCONTEXT_USERUNMANAGED */
6669
6670 /* create local system product key */
6671 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
6672 lstrcatA(keypath, prod_squashed);
6673
6674 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
6675 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6676
6677 /* product key exists */
6678 INIT_USERINFO();
6679 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6680 ok(state == USERINFOSTATE_ABSENT,
6681 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6682 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6683 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6684 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6685 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6686 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6687 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6688
6689 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6690 lstrcatA(keypath, "Installer\\UserData\\");
6691 lstrcatA(keypath, usersid);
6692 lstrcatA(keypath, "\\Products\\");
6693 lstrcatA(keypath, prod_squashed);
6694
6695 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6696 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6697
6698 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6699 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6700
6701 /* InstallProperties key exists */
6702 INIT_USERINFO();
6703 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6704 ok(state == USERINFOSTATE_ABSENT,
6705 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6706 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6707 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6708 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6709 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6710 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6711 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6712
6713 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6714 INIT_USERINFO();
6715 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6716 ok(state == USERINFOSTATE_ABSENT,
6717 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6718 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6719 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6720 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6721 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6722
6723 /* RegOwner, RegCompany don't exist, out params are NULL */
6724 INIT_USERINFO();
6725 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6726 ok(state == USERINFOSTATE_ABSENT,
6727 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6728 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6729 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6730
6731 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6732 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6733
6734 /* RegOwner value exists */
6735 INIT_USERINFO();
6736 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6737 ok(state == USERINFOSTATE_ABSENT,
6738 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6739 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6740 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6741 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6742 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6743 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6744 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6745
6746 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6747 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6748
6749 /* RegCompany value exists */
6750 INIT_USERINFO();
6751 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6752 ok(state == USERINFOSTATE_ABSENT,
6753 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6754 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6755 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6756 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6757 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6758 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6759 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6760
6761 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6762 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6763
6764 /* ProductID value exists */
6765 INIT_USERINFO();
6766 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6767 ok(state == USERINFOSTATE_PRESENT,
6768 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6769 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6770 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6771 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6772 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6773 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6774 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6775
6776 RegDeleteValueA(props, "ProductID");
6777 RegDeleteValueA(props, "RegCompany");
6778 RegDeleteValueA(props, "RegOwner");
6779 RegDeleteKeyA(props, "");
6780 RegCloseKey(props);
6781 RegDeleteKeyA(userprod, "");
6782 RegCloseKey(userprod);
6783 RegDeleteKeyA(prodkey, "");
6784 RegCloseKey(prodkey);
6785
6786 /* MSIINSTALLCONTEXT_MACHINE */
6787
6788 /* create local system product key */
6789 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
6790 lstrcatA(keypath, prod_squashed);
6791
6792 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6793 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6794
6795 /* product key exists */
6796 INIT_USERINFO();
6797 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6798 ok(state == USERINFOSTATE_ABSENT,
6799 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6800 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6801 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6802 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6803 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6804 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6805 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6806
6807 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6808 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18");
6809 lstrcatA(keypath, "\\Products\\");
6810 lstrcatA(keypath, prod_squashed);
6811
6812 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6813 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6814
6815 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6816 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6817
6818 /* InstallProperties key exists */
6819 INIT_USERINFO();
6820 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6821 ok(state == USERINFOSTATE_ABSENT,
6822 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6823 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6824 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6825 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6826 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6827 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6828 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6829
6830 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6831 INIT_USERINFO();
6832 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6833 ok(state == USERINFOSTATE_ABSENT,
6834 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6835 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6836 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6837 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6838 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6839
6840 /* RegOwner, RegCompany don't exist, out params are NULL */
6841 INIT_USERINFO();
6842 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6843 ok(state == USERINFOSTATE_ABSENT,
6844 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6845 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6846 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6847
6848 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6849 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6850
6851 /* RegOwner value exists */
6852 INIT_USERINFO();
6853 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6854 ok(state == USERINFOSTATE_ABSENT,
6855 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6856 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6857 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6858 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6859 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6860 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6861 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6862
6863 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6864 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6865
6866 /* RegCompany value exists */
6867 INIT_USERINFO();
6868 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6869 ok(state == USERINFOSTATE_ABSENT,
6870 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6871 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6872 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6873 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6874 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6875 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6876 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6877
6878 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6879 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6880
6881 /* ProductID value exists */
6882 INIT_USERINFO();
6883 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6884 ok(state == USERINFOSTATE_PRESENT,
6885 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6886 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6887 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6888 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6889 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6890 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6891 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6892
6893 RegDeleteValueA(props, "ProductID");
6894 RegDeleteValueA(props, "RegCompany");
6895 RegDeleteValueA(props, "RegOwner");
6896 RegDeleteKeyA(props, "");
6897 RegCloseKey(props);
6898 RegDeleteKeyA(userprod, "");
6899 RegCloseKey(userprod);
6900 RegDeleteKeyA(prodkey, "");
6901 RegCloseKey(prodkey);
6902 }
6903
6904 START_TEST(msi)
6905 {
6906 init_functionpointers();
6907
6908 test_usefeature();
6909 test_null();
6910 test_getcomponentpath();
6911 test_MsiGetFileHash();
6912
6913 if (!pConvertSidToStringSidA)
6914 skip("ConvertSidToStringSidA not implemented\n");
6915 else
6916 {
6917 /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
6918 test_MsiQueryProductState();
6919 test_MsiQueryFeatureState();
6920 test_MsiQueryComponentState();
6921 test_MsiGetComponentPath();
6922 test_MsiGetProductCode();
6923 test_MsiEnumClients();
6924 test_MsiGetProductInfo();
6925 test_MsiGetProductInfoEx();
6926 test_MsiGetUserInfo();
6927 }
6928
6929 test_MsiGetFileVersion();
6930 }