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