advapi32: Create MachineGuid value if it doesn't exist.
[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     if (r != ERROR_UNKNOWN_PROPERTY)
3210     {
3211         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3212         ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3213         ok(sz == 0, "Expected 0, got %d\n", sz);
3214     }
3215
3216     res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_DWORD,
3217                          (const BYTE *)&val, sizeof(DWORD));
3218     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3219
3220     /* AuthorizedLUAApp type is REG_DWORD */
3221     sz = MAX_PATH;
3222     lstrcpyA(buf, "apple");
3223     r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3224     if (r != ERROR_UNKNOWN_PROPERTY)
3225     {
3226         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3227         ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3228         ok(sz == 0, "Expected 0, got %d\n", sz);
3229     }
3230
3231     res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3232     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3233
3234     /* Authorized value exists */
3235     sz = MAX_PATH;
3236     lstrcpyA(buf, "apple");
3237     r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3238     if (r != ERROR_UNKNOWN_PROPERTY)
3239     {
3240         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3241         ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
3242         ok(sz == 4, "Expected 4, got %d\n", sz);
3243     }
3244
3245     res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_DWORD,
3246                          (const BYTE *)&val, sizeof(DWORD));
3247     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3248
3249     /* AuthorizedLUAApp type is REG_DWORD */
3250     sz = MAX_PATH;
3251     lstrcpyA(buf, "apple");
3252     r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3253     if (r != ERROR_UNKNOWN_PROPERTY)
3254     {
3255         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3256         ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3257         ok(sz == 2, "Expected 2, got %d\n", sz);
3258     }
3259
3260     RegDeleteValueA(propkey, "HelpLink");
3261     RegDeleteValueA(propkey, "DisplayName");
3262     RegDeleteValueA(propkey, "DisplayVersion");
3263     RegDeleteValueA(propkey, "HelpTelephone");
3264     RegDeleteValueA(propkey, "InstallLocation");
3265     RegDeleteValueA(propkey, "InstallSource");
3266     RegDeleteValueA(propkey, "InstallDate");
3267     RegDeleteValueA(propkey, "Publisher");
3268     RegDeleteValueA(propkey, "LocalPackage");
3269     RegDeleteValueA(propkey, "UrlInfoAbout");
3270     RegDeleteValueA(propkey, "UrlUpdateInfo");
3271     RegDeleteValueA(propkey, "VersionMinor");
3272     RegDeleteValueA(propkey, "VersionMajor");
3273     RegDeleteValueA(propkey, "ProductID");
3274     RegDeleteValueA(propkey, "RegCompany");
3275     RegDeleteValueA(propkey, "RegOwner");
3276     RegDeleteValueA(propkey, "InstanceType");
3277     RegDeleteValueA(propkey, "Transforms");
3278     RegDeleteValueA(propkey, "Language");
3279     RegDeleteValueA(propkey, "ProductName");
3280     RegDeleteValueA(propkey, "Assignment");
3281     RegDeleteValueA(propkey, "PackageCode");
3282     RegDeleteValueA(propkey, "Version");
3283     RegDeleteValueA(propkey, "ProductIcon");
3284     RegDeleteValueA(propkey, "AuthorizedLUAApp");
3285     RegDeleteKeyA(propkey, "");
3286     RegDeleteKeyA(localkey, "");
3287     RegDeleteValueA(prodkey, "InstanceType");
3288     RegDeleteValueA(prodkey, "Transforms");
3289     RegDeleteValueA(prodkey, "Language");
3290     RegDeleteValueA(prodkey, "ProductName");
3291     RegDeleteValueA(prodkey, "Assignment");
3292     RegDeleteValueA(prodkey, "PackageCode");
3293     RegDeleteValueA(prodkey, "Version");
3294     RegDeleteValueA(prodkey, "ProductIcon");
3295     RegDeleteValueA(prodkey, "AuthorizedLUAApp");
3296     RegDeleteValueA(source, "PackageName");
3297     RegDeleteKeyA(source, "");
3298     RegDeleteKeyA(prodkey, "");
3299     RegCloseKey(propkey);
3300     RegCloseKey(localkey);
3301     RegCloseKey(source);
3302     RegCloseKey(prodkey);
3303 }
3304
3305 static void test_MsiGetProductInfoEx(void)
3306 {
3307     UINT r;
3308     LONG res;
3309     HKEY propkey, userkey;
3310     HKEY prodkey, localkey;
3311     CHAR prodcode[MAX_PATH];
3312     CHAR prod_squashed[MAX_PATH];
3313     CHAR packcode[MAX_PATH];
3314     CHAR pack_squashed[MAX_PATH];
3315     CHAR buf[MAX_PATH];
3316     CHAR keypath[MAX_PATH];
3317     LPSTR usersid;
3318     DWORD sz;
3319
3320     if (!pMsiGetProductInfoExA)
3321     {
3322         skip("MsiGetProductInfoExA is not available\n");
3323         return;
3324     }
3325
3326     create_test_guid(prodcode, prod_squashed);
3327     create_test_guid(packcode, pack_squashed);
3328     get_user_sid(&usersid);
3329
3330     /* NULL szProductCode */
3331     sz = MAX_PATH;
3332     lstrcpyA(buf, "apple");
3333     r = pMsiGetProductInfoExA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3334                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3335     ok(r == ERROR_INVALID_PARAMETER,
3336        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3337     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3338     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3339
3340     /* empty szProductCode */
3341     sz = MAX_PATH;
3342     lstrcpyA(buf, "apple");
3343     r = pMsiGetProductInfoExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3344                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3345     ok(r == ERROR_INVALID_PARAMETER,
3346        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3347     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3348     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3349
3350     /* garbage szProductCode */
3351     sz = MAX_PATH;
3352     lstrcpyA(buf, "apple");
3353     r = pMsiGetProductInfoExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3354                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3355     ok(r == ERROR_INVALID_PARAMETER,
3356        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3357     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3358     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3359
3360     /* guid without brackets */
3361     sz = MAX_PATH;
3362     lstrcpyA(buf, "apple");
3363     r = pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
3364                               MSIINSTALLCONTEXT_USERUNMANAGED,
3365                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3366     ok(r == ERROR_INVALID_PARAMETER,
3367        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3368     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3369     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3370
3371     /* guid with brackets */
3372     sz = MAX_PATH;
3373     lstrcpyA(buf, "apple");
3374     r = pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid,
3375                               MSIINSTALLCONTEXT_USERUNMANAGED,
3376                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3377     ok(r == ERROR_UNKNOWN_PRODUCT,
3378        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3379     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3380     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3381
3382     /* szValue is non-NULL while pcchValue is NULL */
3383     lstrcpyA(buf, "apple");
3384     r = pMsiGetProductInfoExA(prodcode, usersid,
3385                               MSIINSTALLCONTEXT_USERUNMANAGED,
3386                               INSTALLPROPERTY_PRODUCTSTATE, buf, NULL);
3387     ok(r == ERROR_INVALID_PARAMETER,
3388        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3389     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3390
3391     /* dwContext is out of range */
3392     sz = MAX_PATH;
3393     lstrcpyA(buf, "apple");
3394     r = pMsiGetProductInfoExA(prodcode, usersid, 42,
3395                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3396     ok(r == ERROR_INVALID_PARAMETER,
3397        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3398     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3399     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3400
3401     /* szProperty is NULL */
3402     sz = MAX_PATH;
3403     lstrcpyA(buf, "apple");
3404     r = pMsiGetProductInfoExA(prodcode, usersid,
3405                               MSIINSTALLCONTEXT_USERUNMANAGED,
3406                               NULL, buf, &sz);
3407     ok(r == ERROR_INVALID_PARAMETER,
3408        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3409     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3410     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3411
3412     /* szProperty is empty */
3413     sz = MAX_PATH;
3414     lstrcpyA(buf, "apple");
3415     r = pMsiGetProductInfoExA(prodcode, usersid,
3416                               MSIINSTALLCONTEXT_USERUNMANAGED,
3417                               "", buf, &sz);
3418     ok(r == ERROR_INVALID_PARAMETER,
3419        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3420     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3421     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3422
3423     /* szProperty is not a valid property */
3424     sz = MAX_PATH;
3425     lstrcpyA(buf, "apple");
3426     r = pMsiGetProductInfoExA(prodcode, usersid,
3427                               MSIINSTALLCONTEXT_USERUNMANAGED,
3428                               "notvalid", buf, &sz);
3429     ok(r == ERROR_UNKNOWN_PRODUCT,
3430        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3431     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3432     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3433
3434     /* same length as guid, but random */
3435     sz = MAX_PATH;
3436     lstrcpyA(buf, "apple");
3437     r = pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid,
3438                               MSIINSTALLCONTEXT_USERUNMANAGED,
3439                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3440     ok(r == ERROR_INVALID_PARAMETER,
3441        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3442     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3443     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3444
3445     /* MSIINSTALLCONTEXT_USERUNMANAGED */
3446
3447     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
3448     lstrcatA(keypath, usersid);
3449     lstrcatA(keypath, "\\Products\\");
3450     lstrcatA(keypath, prod_squashed);
3451
3452     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
3453     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3454
3455     /* local user product key exists */
3456     sz = MAX_PATH;
3457     lstrcpyA(buf, "apple");
3458     r = pMsiGetProductInfoExA(prodcode, usersid,
3459                               MSIINSTALLCONTEXT_USERUNMANAGED,
3460                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3461     ok(r == ERROR_UNKNOWN_PRODUCT,
3462        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3463     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3464     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3465
3466     res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
3467     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3468
3469     /* InstallProperties key exists */
3470     sz = MAX_PATH;
3471     lstrcpyA(buf, "apple");
3472     r = pMsiGetProductInfoExA(prodcode, usersid,
3473                               MSIINSTALLCONTEXT_USERUNMANAGED,
3474                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3475     ok(r == ERROR_UNKNOWN_PRODUCT,
3476        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3477     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3478     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3479
3480     res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3481     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3482
3483     /* LocalPackage value exists */
3484     sz = MAX_PATH;
3485     lstrcpyA(buf, "apple");
3486     r = pMsiGetProductInfoExA(prodcode, usersid,
3487                               MSIINSTALLCONTEXT_USERUNMANAGED,
3488                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3489     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3490     ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
3491     ok(sz == 1, "Expected 1, got %d\n", sz);
3492
3493     RegDeleteValueA(propkey, "LocalPackage");
3494
3495     /* LocalPackage value must exist */
3496     sz = MAX_PATH;
3497     lstrcpyA(buf, "apple");
3498     r = pMsiGetProductInfoExA(prodcode, usersid,
3499                               MSIINSTALLCONTEXT_USERUNMANAGED,
3500                               INSTALLPROPERTY_HELPLINK, buf, &sz);
3501     ok(r == ERROR_UNKNOWN_PRODUCT,
3502        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3503     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3504     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3505
3506     res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3507     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3508
3509     /* LocalPackage exists, but HelpLink does not exist */
3510     sz = MAX_PATH;
3511     lstrcpyA(buf, "apple");
3512     r = pMsiGetProductInfoExA(prodcode, usersid,
3513                               MSIINSTALLCONTEXT_USERUNMANAGED,
3514                               INSTALLPROPERTY_HELPLINK, buf, &sz);
3515     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3516     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3517     ok(sz == 0, "Expected 0, got %d\n", sz);
3518
3519     res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
3520     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3521
3522     /* HelpLink value exists */
3523     sz = MAX_PATH;
3524     lstrcpyA(buf, "apple");
3525     r = pMsiGetProductInfoExA(prodcode, usersid,
3526                               MSIINSTALLCONTEXT_USERUNMANAGED,
3527                               INSTALLPROPERTY_HELPLINK, buf, &sz);
3528     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3529     ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
3530     ok(sz == 4, "Expected 4, got %d\n", sz);
3531
3532     res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
3533     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3534
3535     /* HelpTelephone value exists */
3536     sz = MAX_PATH;
3537     lstrcpyA(buf, "apple");
3538     r = pMsiGetProductInfoExA(prodcode, usersid,
3539                               MSIINSTALLCONTEXT_USERUNMANAGED,
3540                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3541     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3542     ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
3543     ok(sz == 5, "Expected 5, got %d\n", sz);
3544
3545     /* szValue and pcchValue are NULL */
3546     r = pMsiGetProductInfoExA(prodcode, usersid,
3547                               MSIINSTALLCONTEXT_USERUNMANAGED,
3548                               INSTALLPROPERTY_HELPTELEPHONE, NULL, NULL);
3549     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3550
3551     /* pcchValue is exactly 5 */
3552     sz = 5;
3553     lstrcpyA(buf, "apple");
3554     r = pMsiGetProductInfoExA(prodcode, usersid,
3555                               MSIINSTALLCONTEXT_USERUNMANAGED,
3556                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3557     ok(r == ERROR_MORE_DATA,
3558        "Expected ERROR_MORE_DATA, got %d\n", r);
3559     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3560     ok(sz == 10, "Expected 10, got %d\n", sz);
3561
3562     /* szValue is NULL, pcchValue is exactly 5 */
3563     sz = 5;
3564     r = pMsiGetProductInfoExA(prodcode, usersid,
3565                               MSIINSTALLCONTEXT_USERUNMANAGED,
3566                               INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
3567     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3568     ok(sz == 10, "Expected 10, got %d\n", sz);
3569
3570     /* szValue is NULL, pcchValue is MAX_PATH */
3571     sz = MAX_PATH;
3572     r = pMsiGetProductInfoExA(prodcode, usersid,
3573                               MSIINSTALLCONTEXT_USERUNMANAGED,
3574                               INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
3575     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3576     ok(sz == 10, "Expected 10, got %d\n", sz);
3577
3578     /* pcchValue is exactly 0 */
3579     sz = 0;
3580     lstrcpyA(buf, "apple");
3581     r = pMsiGetProductInfoExA(prodcode, usersid,
3582                               MSIINSTALLCONTEXT_USERUNMANAGED,
3583                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3584     ok(r == ERROR_MORE_DATA,
3585        "Expected ERROR_MORE_DATA, got %d\n", r);
3586     ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
3587     ok(sz == 10, "Expected 10, got %d\n", sz);
3588
3589     res = RegSetValueExA(propkey, "notvalid", 0, REG_SZ, (LPBYTE)"invalid", 8);
3590     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3591
3592     /* szProperty is not a valid property */
3593     sz = MAX_PATH;
3594     lstrcpyA(buf, "apple");
3595     r = pMsiGetProductInfoExA(prodcode, usersid,
3596                               MSIINSTALLCONTEXT_USERUNMANAGED,
3597                               "notvalid", buf, &sz);
3598     ok(r == ERROR_UNKNOWN_PROPERTY,
3599        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
3600     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3601     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3602
3603     res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
3604     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3605
3606     /* InstallDate value exists */
3607     sz = MAX_PATH;
3608     lstrcpyA(buf, "apple");
3609     r = pMsiGetProductInfoExA(prodcode, usersid,
3610                               MSIINSTALLCONTEXT_USERUNMANAGED,
3611                               INSTALLPROPERTY_INSTALLDATE, buf, &sz);
3612     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3613     ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
3614     ok(sz == 4, "Expected 4, got %d\n", sz);
3615
3616     res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
3617     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3618
3619     /* DisplayName value exists */
3620     sz = MAX_PATH;
3621     lstrcpyA(buf, "apple");
3622     r = pMsiGetProductInfoExA(prodcode, usersid,
3623                               MSIINSTALLCONTEXT_USERUNMANAGED,
3624                               INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
3625     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3626     ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
3627     ok(sz == 4, "Expected 4, got %d\n", sz);
3628
3629     res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
3630     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3631
3632     /* InstallLocation value exists */
3633     sz = MAX_PATH;
3634     lstrcpyA(buf, "apple");
3635     r = pMsiGetProductInfoExA(prodcode, usersid,
3636                               MSIINSTALLCONTEXT_USERUNMANAGED,
3637                               INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
3638     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3639     ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
3640     ok(sz == 3, "Expected 3, got %d\n", sz);
3641
3642     res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
3643     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3644
3645     /* InstallSource value exists */
3646     sz = MAX_PATH;
3647     lstrcpyA(buf, "apple");
3648     r = pMsiGetProductInfoExA(prodcode, usersid,
3649                               MSIINSTALLCONTEXT_USERUNMANAGED,
3650                               INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
3651     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3652     ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
3653     ok(sz == 6, "Expected 6, got %d\n", sz);
3654
3655     res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3656     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3657
3658     /* LocalPackage value exists */
3659     sz = MAX_PATH;
3660     lstrcpyA(buf, "apple");
3661     r = pMsiGetProductInfoExA(prodcode, usersid,
3662                               MSIINSTALLCONTEXT_USERUNMANAGED,
3663                               INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
3664     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3665     ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
3666     ok(sz == 5, "Expected 5, got %d\n", sz);
3667
3668     res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
3669     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3670
3671     /* Publisher value exists */
3672     sz = MAX_PATH;
3673     lstrcpyA(buf, "apple");
3674     r = pMsiGetProductInfoExA(prodcode, usersid,
3675                               MSIINSTALLCONTEXT_USERUNMANAGED,
3676                               INSTALLPROPERTY_PUBLISHER, buf, &sz);
3677     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3678     ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
3679     ok(sz == 3, "Expected 3, got %d\n", sz);
3680
3681     res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
3682     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3683
3684     /* URLInfoAbout value exists */
3685     sz = MAX_PATH;
3686     lstrcpyA(buf, "apple");
3687     r = pMsiGetProductInfoExA(prodcode, usersid,
3688                               MSIINSTALLCONTEXT_USERUNMANAGED,
3689                               INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
3690     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3691     ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
3692     ok(sz == 5, "Expected 5, got %d\n", sz);
3693
3694     res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
3695     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3696
3697     /* URLUpdateInfo value exists */
3698     sz = MAX_PATH;
3699     lstrcpyA(buf, "apple");
3700     r = pMsiGetProductInfoExA(prodcode, usersid,
3701                               MSIINSTALLCONTEXT_USERUNMANAGED,
3702                               INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
3703     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3704     ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
3705     ok(sz == 6, "Expected 6, got %d\n", sz);
3706
3707     res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
3708     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3709
3710     /* VersionMinor value exists */
3711     sz = MAX_PATH;
3712     lstrcpyA(buf, "apple");
3713     r = pMsiGetProductInfoExA(prodcode, usersid,
3714                               MSIINSTALLCONTEXT_USERUNMANAGED,
3715                               INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
3716     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3717     ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
3718     ok(sz == 1, "Expected 1, got %d\n", sz);
3719
3720     res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
3721     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3722
3723     /* VersionMajor value exists */
3724     sz = MAX_PATH;
3725     lstrcpyA(buf, "apple");
3726     r = pMsiGetProductInfoExA(prodcode, usersid,
3727                               MSIINSTALLCONTEXT_USERUNMANAGED,
3728                               INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
3729     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3730     ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
3731     ok(sz == 1, "Expected 1, got %d\n", sz);
3732
3733     res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
3734     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3735
3736     /* DisplayVersion value exists */
3737     sz = MAX_PATH;
3738     lstrcpyA(buf, "apple");
3739     r = pMsiGetProductInfoExA(prodcode, usersid,
3740                               MSIINSTALLCONTEXT_USERUNMANAGED,
3741                               INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
3742     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3743     ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
3744     ok(sz == 5, "Expected 5, got %d\n", sz);
3745
3746     res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
3747     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3748
3749     /* ProductID value exists */
3750     sz = MAX_PATH;
3751     lstrcpyA(buf, "apple");
3752     r = pMsiGetProductInfoExA(prodcode, usersid,
3753                               MSIINSTALLCONTEXT_USERUNMANAGED,
3754                               INSTALLPROPERTY_PRODUCTID, buf, &sz);
3755     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3756     ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
3757     ok(sz == 2, "Expected 2, got %d\n", sz);
3758
3759     res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
3760     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3761
3762     /* RegCompany value exists */
3763     sz = MAX_PATH;
3764     lstrcpyA(buf, "apple");
3765     r = pMsiGetProductInfoExA(prodcode, usersid,
3766                               MSIINSTALLCONTEXT_USERUNMANAGED,
3767                               INSTALLPROPERTY_REGCOMPANY, buf, &sz);
3768     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3769     ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
3770     ok(sz == 4, "Expected 4, got %d\n", sz);
3771
3772     res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
3773     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3774
3775     /* RegOwner value exists */
3776     sz = MAX_PATH;
3777     lstrcpyA(buf, "apple");
3778     r = pMsiGetProductInfoExA(prodcode, usersid,
3779                               MSIINSTALLCONTEXT_USERUNMANAGED,
3780                               INSTALLPROPERTY_REGOWNER, buf, &sz);
3781     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3782     ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
3783     ok(sz == 5, "Expected 5, got %d\n", sz);
3784
3785     res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
3786     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3787
3788     /* Transforms value exists */
3789     sz = MAX_PATH;
3790     lstrcpyA(buf, "apple");
3791     r = pMsiGetProductInfoExA(prodcode, usersid,
3792                               MSIINSTALLCONTEXT_USERUNMANAGED,
3793                               INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3794     ok(r == ERROR_UNKNOWN_PRODUCT,
3795        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3796     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3797     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3798
3799     res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
3800     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3801
3802     /* Language value exists */
3803     sz = MAX_PATH;
3804     lstrcpyA(buf, "apple");
3805     r = pMsiGetProductInfoExA(prodcode, usersid,
3806                               MSIINSTALLCONTEXT_USERUNMANAGED,
3807                               INSTALLPROPERTY_LANGUAGE, buf, &sz);
3808     ok(r == ERROR_UNKNOWN_PRODUCT,
3809        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3810     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3811     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3812
3813     res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
3814     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3815
3816     /* ProductName value exists */
3817     sz = MAX_PATH;
3818     lstrcpyA(buf, "apple");
3819     r = pMsiGetProductInfoExA(prodcode, usersid,
3820                               MSIINSTALLCONTEXT_USERUNMANAGED,
3821                               INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3822     ok(r == ERROR_UNKNOWN_PRODUCT,
3823        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3824     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3825     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3826
3827     res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
3828     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3829
3830     /* FIXME */
3831
3832     /* AssignmentType value exists */
3833     sz = MAX_PATH;
3834     lstrcpyA(buf, "apple");
3835     r = pMsiGetProductInfoExA(prodcode, usersid,
3836                               MSIINSTALLCONTEXT_USERUNMANAGED,
3837                               INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3838     ok(r == ERROR_UNKNOWN_PRODUCT,
3839        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3840     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3841     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3842
3843     res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
3844     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3845
3846     /* PackageCode value exists */
3847     sz = MAX_PATH;
3848     lstrcpyA(buf, "apple");
3849     r = pMsiGetProductInfoExA(prodcode, usersid,
3850                               MSIINSTALLCONTEXT_USERUNMANAGED,
3851                               INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3852     ok(r == ERROR_UNKNOWN_PRODUCT,
3853        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3854     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3855     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3856
3857     res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
3858     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3859
3860     /* Version value exists */
3861     sz = MAX_PATH;
3862     lstrcpyA(buf, "apple");
3863     r = pMsiGetProductInfoExA(prodcode, usersid,
3864                               MSIINSTALLCONTEXT_USERUNMANAGED,
3865                               INSTALLPROPERTY_VERSION, buf, &sz);
3866     ok(r == ERROR_UNKNOWN_PRODUCT,
3867        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3868     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3869     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3870
3871     res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
3872     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3873
3874     /* ProductIcon value exists */
3875     sz = MAX_PATH;
3876     lstrcpyA(buf, "apple");
3877     r = pMsiGetProductInfoExA(prodcode, usersid,
3878                               MSIINSTALLCONTEXT_USERUNMANAGED,
3879                               INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3880     ok(r == ERROR_UNKNOWN_PRODUCT,
3881        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3882     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3883     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3884
3885     res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
3886     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3887
3888     /* PackageName value exists */
3889     sz = MAX_PATH;
3890     lstrcpyA(buf, "apple");
3891     r = pMsiGetProductInfoExA(prodcode, usersid,
3892                               MSIINSTALLCONTEXT_USERUNMANAGED,
3893                               INSTALLPROPERTY_PACKAGENAME, buf, &sz);
3894     ok(r == ERROR_UNKNOWN_PRODUCT,
3895        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3896     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3897     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3898
3899     res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3900     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3901
3902     /* AuthorizedLUAApp value exists */
3903     sz = MAX_PATH;
3904     lstrcpyA(buf, "apple");
3905     r = pMsiGetProductInfoExA(prodcode, usersid,
3906                               MSIINSTALLCONTEXT_USERUNMANAGED,
3907                               INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3908     ok(r == ERROR_UNKNOWN_PRODUCT,
3909        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3910     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3911     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3912
3913     RegDeleteValueA(propkey, "AuthorizedLUAApp");
3914     RegDeleteValueA(propkey, "PackageName");
3915     RegDeleteValueA(propkey, "ProductIcon");
3916     RegDeleteValueA(propkey, "Version");
3917     RegDeleteValueA(propkey, "PackageCode");
3918     RegDeleteValueA(propkey, "AssignmentType");
3919     RegDeleteValueA(propkey, "ProductName");
3920     RegDeleteValueA(propkey, "Language");
3921     RegDeleteValueA(propkey, "Transforms");
3922     RegDeleteValueA(propkey, "RegOwner");
3923     RegDeleteValueA(propkey, "RegCompany");
3924     RegDeleteValueA(propkey, "ProductID");
3925     RegDeleteValueA(propkey, "DisplayVersion");
3926     RegDeleteValueA(propkey, "VersionMajor");
3927     RegDeleteValueA(propkey, "VersionMinor");
3928     RegDeleteValueA(propkey, "URLUpdateInfo");
3929     RegDeleteValueA(propkey, "URLInfoAbout");
3930     RegDeleteValueA(propkey, "Publisher");
3931     RegDeleteValueA(propkey, "LocalPackage");
3932     RegDeleteValueA(propkey, "InstallSource");
3933     RegDeleteValueA(propkey, "InstallLocation");
3934     RegDeleteValueA(propkey, "DisplayName");
3935     RegDeleteValueA(propkey, "InstallDate");
3936     RegDeleteValueA(propkey, "HelpTelephone");
3937     RegDeleteValueA(propkey, "HelpLink");
3938     RegDeleteValueA(propkey, "LocalPackage");
3939     RegDeleteKeyA(propkey, "");
3940     RegCloseKey(propkey);
3941     RegDeleteKeyA(localkey, "");
3942     RegCloseKey(localkey);
3943
3944     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
3945     lstrcatA(keypath, usersid);
3946     lstrcatA(keypath, "\\Installer\\Products\\");
3947     lstrcatA(keypath, prod_squashed);
3948
3949     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
3950     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3951
3952     /* user product key exists */
3953     sz = MAX_PATH;
3954     lstrcpyA(buf, "apple");
3955     r = pMsiGetProductInfoExA(prodcode, usersid,
3956                               MSIINSTALLCONTEXT_USERUNMANAGED,
3957                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3958     ok(r == ERROR_UNKNOWN_PRODUCT,
3959        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3960     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3961     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3962
3963     RegDeleteKeyA(userkey, "");
3964     RegCloseKey(userkey);
3965
3966     lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
3967     lstrcatA(keypath, prod_squashed);
3968
3969     res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
3970     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3971
3972     sz = MAX_PATH;
3973     lstrcpyA(buf, "apple");
3974     r = pMsiGetProductInfoExA(prodcode, usersid,
3975                               MSIINSTALLCONTEXT_USERUNMANAGED,
3976                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3977     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3978     ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
3979     ok(sz == 1, "Expected 1, got %d\n", sz);
3980
3981     res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
3982     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3983
3984     /* HelpLink value exists */
3985     sz = MAX_PATH;
3986     lstrcpyA(buf, "apple");
3987     r = pMsiGetProductInfoExA(prodcode, usersid,
3988                               MSIINSTALLCONTEXT_USERUNMANAGED,
3989                               INSTALLPROPERTY_HELPLINK, buf, &sz);
3990     ok(r == ERROR_UNKNOWN_PROPERTY,
3991        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
3992     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3993     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3994
3995     res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
3996     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3997
3998     /* HelpTelephone value exists */
3999     sz = MAX_PATH;
4000     lstrcpyA(buf, "apple");
4001     r = pMsiGetProductInfoExA(prodcode, usersid,
4002                               MSIINSTALLCONTEXT_USERUNMANAGED,
4003                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4004     ok(r == ERROR_UNKNOWN_PROPERTY,
4005        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4006     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4007     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4008
4009     res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4010     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4011
4012     /* InstallDate value exists */
4013     sz = MAX_PATH;
4014     lstrcpyA(buf, "apple");
4015     r = pMsiGetProductInfoExA(prodcode, usersid,
4016                               MSIINSTALLCONTEXT_USERUNMANAGED,
4017                               INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4018     ok(r == ERROR_UNKNOWN_PROPERTY,
4019        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4020     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4021     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4022
4023     res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4024     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4025
4026     /* DisplayName value exists */
4027     sz = MAX_PATH;
4028     lstrcpyA(buf, "apple");
4029     r = pMsiGetProductInfoExA(prodcode, usersid,
4030                               MSIINSTALLCONTEXT_USERUNMANAGED,
4031                               INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4032     ok(r == ERROR_UNKNOWN_PROPERTY,
4033        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4034     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4035     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4036
4037     res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4038     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4039
4040     /* InstallLocation value exists */
4041     sz = MAX_PATH;
4042     lstrcpyA(buf, "apple");
4043     r = pMsiGetProductInfoExA(prodcode, usersid,
4044                               MSIINSTALLCONTEXT_USERUNMANAGED,
4045                               INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4046     ok(r == ERROR_UNKNOWN_PROPERTY,
4047        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4048     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4049     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4050
4051     res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4052     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4053
4054     /* InstallSource value exists */
4055     sz = MAX_PATH;
4056     lstrcpyA(buf, "apple");
4057     r = pMsiGetProductInfoExA(prodcode, usersid,
4058                               MSIINSTALLCONTEXT_USERUNMANAGED,
4059                               INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4060     ok(r == ERROR_UNKNOWN_PROPERTY,
4061        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4062     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4063     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4064
4065     res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4066     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4067
4068     /* LocalPackage value exists */
4069     sz = MAX_PATH;
4070     lstrcpyA(buf, "apple");
4071     r = pMsiGetProductInfoExA(prodcode, usersid,
4072                               MSIINSTALLCONTEXT_USERUNMANAGED,
4073                               INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4074     ok(r == ERROR_UNKNOWN_PROPERTY,
4075        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4076     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4077     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4078
4079     res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4080     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4081
4082     /* Publisher value exists */
4083     sz = MAX_PATH;
4084     lstrcpyA(buf, "apple");
4085     r = pMsiGetProductInfoExA(prodcode, usersid,
4086                               MSIINSTALLCONTEXT_USERUNMANAGED,
4087                               INSTALLPROPERTY_PUBLISHER, buf, &sz);
4088     ok(r == ERROR_UNKNOWN_PROPERTY,
4089        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4090     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4091     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4092
4093     res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4094     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4095
4096     /* URLInfoAbout value exists */
4097     sz = MAX_PATH;
4098     lstrcpyA(buf, "apple");
4099     r = pMsiGetProductInfoExA(prodcode, usersid,
4100                               MSIINSTALLCONTEXT_USERUNMANAGED,
4101                               INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4102     ok(r == ERROR_UNKNOWN_PROPERTY,
4103        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4104     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4105     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4106
4107     res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4108     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4109
4110     /* URLUpdateInfo value exists */
4111     sz = MAX_PATH;
4112     lstrcpyA(buf, "apple");
4113     r = pMsiGetProductInfoExA(prodcode, usersid,
4114                               MSIINSTALLCONTEXT_USERUNMANAGED,
4115                               INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4116     ok(r == ERROR_UNKNOWN_PROPERTY,
4117        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4118     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4119     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4120
4121     res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4122     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4123
4124     /* VersionMinor value exists */
4125     sz = MAX_PATH;
4126     lstrcpyA(buf, "apple");
4127     r = pMsiGetProductInfoExA(prodcode, usersid,
4128                               MSIINSTALLCONTEXT_USERUNMANAGED,
4129                               INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4130     ok(r == ERROR_UNKNOWN_PROPERTY,
4131        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4132     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4133     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4134
4135     res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4136     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4137
4138     /* VersionMajor value exists */
4139     sz = MAX_PATH;
4140     lstrcpyA(buf, "apple");
4141     r = pMsiGetProductInfoExA(prodcode, usersid,
4142                               MSIINSTALLCONTEXT_USERUNMANAGED,
4143                               INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4144     ok(r == ERROR_UNKNOWN_PROPERTY,
4145        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4146     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4147     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4148
4149     res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4150     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4151
4152     /* DisplayVersion value exists */
4153     sz = MAX_PATH;
4154     lstrcpyA(buf, "apple");
4155     r = pMsiGetProductInfoExA(prodcode, usersid,
4156                               MSIINSTALLCONTEXT_USERUNMANAGED,
4157                               INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4158     ok(r == ERROR_UNKNOWN_PROPERTY,
4159        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4160     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4161     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4162
4163     res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4164     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4165
4166     /* ProductID value exists */
4167     sz = MAX_PATH;
4168     lstrcpyA(buf, "apple");
4169     r = pMsiGetProductInfoExA(prodcode, usersid,
4170                               MSIINSTALLCONTEXT_USERUNMANAGED,
4171                               INSTALLPROPERTY_PRODUCTID, buf, &sz);
4172     ok(r == ERROR_UNKNOWN_PROPERTY,
4173        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4174     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4175     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4176
4177     res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4178     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4179
4180     /* RegCompany value exists */
4181     sz = MAX_PATH;
4182     lstrcpyA(buf, "apple");
4183     r = pMsiGetProductInfoExA(prodcode, usersid,
4184                               MSIINSTALLCONTEXT_USERUNMANAGED,
4185                               INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4186     ok(r == ERROR_UNKNOWN_PROPERTY,
4187        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4188     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4189     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4190
4191     res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4192     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4193
4194     /* RegOwner value exists */
4195     sz = MAX_PATH;
4196     lstrcpyA(buf, "apple");
4197     r = pMsiGetProductInfoExA(prodcode, usersid,
4198                               MSIINSTALLCONTEXT_USERUNMANAGED,
4199                               INSTALLPROPERTY_REGOWNER, buf, &sz);
4200     ok(r == ERROR_UNKNOWN_PROPERTY,
4201        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4202     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4203     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4204
4205     res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4206     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4207
4208     /* Transforms value exists */
4209     sz = MAX_PATH;
4210     lstrcpyA(buf, "apple");
4211     r = pMsiGetProductInfoExA(prodcode, usersid,
4212                               MSIINSTALLCONTEXT_USERUNMANAGED,
4213                               INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4214     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4215     ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
4216     ok(sz == 5, "Expected 5, got %d\n", sz);
4217
4218     res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4219     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4220
4221     /* Language value exists */
4222     sz = MAX_PATH;
4223     lstrcpyA(buf, "apple");
4224     r = pMsiGetProductInfoExA(prodcode, usersid,
4225                               MSIINSTALLCONTEXT_USERUNMANAGED,
4226                               INSTALLPROPERTY_LANGUAGE, buf, &sz);
4227     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4228     ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
4229     ok(sz == 4, "Expected 4, got %d\n", sz);
4230
4231     res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4232     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4233
4234     /* ProductName value exists */
4235     sz = MAX_PATH;
4236     lstrcpyA(buf, "apple");
4237     r = pMsiGetProductInfoExA(prodcode, usersid,
4238                               MSIINSTALLCONTEXT_USERUNMANAGED,
4239                               INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4240     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4241     ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4242     ok(sz == 4, "Expected 4, got %d\n", sz);
4243
4244     res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4245     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4246
4247     /* FIXME */
4248
4249     /* AssignmentType value exists */
4250     sz = MAX_PATH;
4251     lstrcpyA(buf, "apple");
4252     r = pMsiGetProductInfoExA(prodcode, usersid,
4253                               MSIINSTALLCONTEXT_USERUNMANAGED,
4254                               INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4255     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4256     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4257     ok(sz == 0, "Expected 0, got %d\n", sz);
4258
4259     res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4260     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4261
4262     /* FIXME */
4263
4264     /* PackageCode value exists */
4265     sz = MAX_PATH;
4266     lstrcpyA(buf, "apple");
4267     r = pMsiGetProductInfoExA(prodcode, usersid,
4268                               MSIINSTALLCONTEXT_USERUNMANAGED,
4269                               INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4270     todo_wine
4271     {
4272         ok(r == ERROR_BAD_CONFIGURATION,
4273            "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
4274         ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4275         ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4276     }
4277
4278     res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4279     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4280
4281     /* Version value exists */
4282     sz = MAX_PATH;
4283     lstrcpyA(buf, "apple");
4284     r = pMsiGetProductInfoExA(prodcode, usersid,
4285                               MSIINSTALLCONTEXT_USERUNMANAGED,
4286                               INSTALLPROPERTY_VERSION, buf, &sz);
4287     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4288     ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
4289     ok(sz == 3, "Expected 3, got %d\n", sz);
4290
4291     res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4292     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4293
4294     /* ProductIcon value exists */
4295     sz = MAX_PATH;
4296     lstrcpyA(buf, "apple");
4297     r = pMsiGetProductInfoExA(prodcode, usersid,
4298                               MSIINSTALLCONTEXT_USERUNMANAGED,
4299                               INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4300     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4301     ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
4302     ok(sz == 4, "Expected 4, got %d\n", sz);
4303
4304     res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4305     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4306
4307     /* PackageName value exists */
4308     sz = MAX_PATH;
4309     lstrcpyA(buf, "apple");
4310     r = pMsiGetProductInfoExA(prodcode, usersid,
4311                               MSIINSTALLCONTEXT_USERUNMANAGED,
4312                               INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4313     todo_wine
4314     {
4315         ok(r == ERROR_UNKNOWN_PRODUCT,
4316            "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4317         ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4318         ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4319     }
4320
4321     res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4322     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4323
4324     /* AuthorizedLUAApp value exists */
4325     sz = MAX_PATH;
4326     lstrcpyA(buf, "apple");
4327     r = pMsiGetProductInfoExA(prodcode, usersid,
4328                               MSIINSTALLCONTEXT_USERUNMANAGED,
4329                               INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4330     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4331     ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
4332     ok(sz == 4, "Expected 4, got %d\n", sz);
4333
4334     RegDeleteValueA(prodkey, "AuthorizedLUAApp");
4335     RegDeleteValueA(prodkey, "PackageName");
4336     RegDeleteValueA(prodkey, "ProductIcon");
4337     RegDeleteValueA(prodkey, "Version");
4338     RegDeleteValueA(prodkey, "PackageCode");
4339     RegDeleteValueA(prodkey, "AssignmentType");
4340     RegDeleteValueA(prodkey, "ProductName");
4341     RegDeleteValueA(prodkey, "Language");
4342     RegDeleteValueA(prodkey, "Transforms");
4343     RegDeleteValueA(prodkey, "RegOwner");
4344     RegDeleteValueA(prodkey, "RegCompany");
4345     RegDeleteValueA(prodkey, "ProductID");
4346     RegDeleteValueA(prodkey, "DisplayVersion");
4347     RegDeleteValueA(prodkey, "VersionMajor");
4348     RegDeleteValueA(prodkey, "VersionMinor");
4349     RegDeleteValueA(prodkey, "URLUpdateInfo");
4350     RegDeleteValueA(prodkey, "URLInfoAbout");
4351     RegDeleteValueA(prodkey, "Publisher");
4352     RegDeleteValueA(prodkey, "LocalPackage");
4353     RegDeleteValueA(prodkey, "InstallSource");
4354     RegDeleteValueA(prodkey, "InstallLocation");
4355     RegDeleteValueA(prodkey, "DisplayName");
4356     RegDeleteValueA(prodkey, "InstallDate");
4357     RegDeleteValueA(prodkey, "HelpTelephone");
4358     RegDeleteValueA(prodkey, "HelpLink");
4359     RegDeleteValueA(prodkey, "LocalPackage");
4360     RegDeleteKeyA(prodkey, "");
4361     RegCloseKey(prodkey);
4362
4363     /* MSIINSTALLCONTEXT_USERMANAGED */
4364
4365     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4366     lstrcatA(keypath, usersid);
4367     lstrcatA(keypath, "\\Products\\");
4368     lstrcatA(keypath, prod_squashed);
4369
4370     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
4371     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4372
4373     /* local user product key exists */
4374     sz = MAX_PATH;
4375     lstrcpyA(buf, "apple");
4376     r = pMsiGetProductInfoExA(prodcode, usersid,
4377                               MSIINSTALLCONTEXT_USERMANAGED,
4378                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4379     ok(r == ERROR_UNKNOWN_PRODUCT,
4380        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4381     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4382     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4383
4384     res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
4385     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4386
4387     /* InstallProperties key exists */
4388     sz = MAX_PATH;
4389     lstrcpyA(buf, "apple");
4390     r = pMsiGetProductInfoExA(prodcode, usersid,
4391                               MSIINSTALLCONTEXT_USERMANAGED,
4392                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4393     ok(r == ERROR_UNKNOWN_PRODUCT,
4394        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4395     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4396     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4397
4398     res = RegSetValueExA(propkey, "ManagedLocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4399     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4400
4401     /* ManagedLocalPackage value exists */
4402     sz = MAX_PATH;
4403     lstrcpyA(buf, "apple");
4404     r = pMsiGetProductInfoExA(prodcode, usersid,
4405                               MSIINSTALLCONTEXT_USERMANAGED,
4406                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4407     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4408     ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
4409     ok(sz == 1, "Expected 1, got %d\n", sz);
4410
4411     res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4412     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4413
4414     /* HelpLink value exists */
4415     sz = MAX_PATH;
4416     lstrcpyA(buf, "apple");
4417     r = pMsiGetProductInfoExA(prodcode, usersid,
4418                               MSIINSTALLCONTEXT_USERMANAGED,
4419                               INSTALLPROPERTY_HELPLINK, buf, &sz);
4420     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4421     ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4422     ok(sz == 4, "Expected 4, got %d\n", sz);
4423
4424     res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4425     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4426
4427     /* HelpTelephone value exists */
4428     sz = MAX_PATH;
4429     lstrcpyA(buf, "apple");
4430     r = pMsiGetProductInfoExA(prodcode, usersid,
4431                               MSIINSTALLCONTEXT_USERMANAGED,
4432                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4433     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4434     ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
4435     ok(sz == 5, "Expected 5, got %d\n", sz);
4436
4437     res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4438     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4439
4440     /* InstallDate value exists */
4441     sz = MAX_PATH;
4442     lstrcpyA(buf, "apple");
4443     r = pMsiGetProductInfoExA(prodcode, usersid,
4444                               MSIINSTALLCONTEXT_USERMANAGED,
4445                               INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4446     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4447     ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4448     ok(sz == 4, "Expected 4, got %d\n", sz);
4449
4450     res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4451     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4452
4453     /* DisplayName value exists */
4454     sz = MAX_PATH;
4455     lstrcpyA(buf, "apple");
4456     r = pMsiGetProductInfoExA(prodcode, usersid,
4457                               MSIINSTALLCONTEXT_USERMANAGED,
4458                               INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4459     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4460     ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4461     ok(sz == 4, "Expected 4, got %d\n", sz);
4462
4463     res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4464     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4465
4466     /* InstallLocation value exists */
4467     sz = MAX_PATH;
4468     lstrcpyA(buf, "apple");
4469     r = pMsiGetProductInfoExA(prodcode, usersid,
4470                               MSIINSTALLCONTEXT_USERMANAGED,
4471                               INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4472     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4473     ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4474     ok(sz == 3, "Expected 3, got %d\n", sz);
4475
4476     res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4477     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4478
4479     /* InstallSource value exists */
4480     sz = MAX_PATH;
4481     lstrcpyA(buf, "apple");
4482     r = pMsiGetProductInfoExA(prodcode, usersid,
4483                               MSIINSTALLCONTEXT_USERMANAGED,
4484                               INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4486     ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4487     ok(sz == 6, "Expected 6, got %d\n", sz);
4488
4489     res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4490     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4491
4492     /* LocalPackage value exists */
4493     sz = MAX_PATH;
4494     lstrcpyA(buf, "apple");
4495     r = pMsiGetProductInfoExA(prodcode, usersid,
4496                               MSIINSTALLCONTEXT_USERMANAGED,
4497                               INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4498     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4499     ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
4500     ok(sz == 5, "Expected 5, got %d\n", sz);
4501
4502     res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4503     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4504
4505     /* Publisher value exists */
4506     sz = MAX_PATH;
4507     lstrcpyA(buf, "apple");
4508     r = pMsiGetProductInfoExA(prodcode, usersid,
4509                               MSIINSTALLCONTEXT_USERMANAGED,
4510                               INSTALLPROPERTY_PUBLISHER, buf, &sz);
4511     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4512     ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4513     ok(sz == 3, "Expected 3, got %d\n", sz);
4514
4515     res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4516     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4517
4518     /* URLInfoAbout value exists */
4519     sz = MAX_PATH;
4520     lstrcpyA(buf, "apple");
4521     r = pMsiGetProductInfoExA(prodcode, usersid,
4522                               MSIINSTALLCONTEXT_USERMANAGED,
4523                               INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4524     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4525     ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4526     ok(sz == 5, "Expected 5, got %d\n", sz);
4527
4528     res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4529     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4530
4531     /* URLUpdateInfo value exists */
4532     sz = MAX_PATH;
4533     lstrcpyA(buf, "apple");
4534     r = pMsiGetProductInfoExA(prodcode, usersid,
4535                               MSIINSTALLCONTEXT_USERMANAGED,
4536                               INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4537     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4538     ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
4539     ok(sz == 6, "Expected 6, got %d\n", sz);
4540
4541     res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4542     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4543
4544     /* VersionMinor value exists */
4545     sz = MAX_PATH;
4546     lstrcpyA(buf, "apple");
4547     r = pMsiGetProductInfoExA(prodcode, usersid,
4548                               MSIINSTALLCONTEXT_USERMANAGED,
4549                               INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4550     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4551     ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
4552     ok(sz == 1, "Expected 1, got %d\n", sz);
4553
4554     res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4555     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4556
4557     /* VersionMajor value exists */
4558     sz = MAX_PATH;
4559     lstrcpyA(buf, "apple");
4560     r = pMsiGetProductInfoExA(prodcode, usersid,
4561                               MSIINSTALLCONTEXT_USERMANAGED,
4562                               INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4563     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4564     ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
4565     ok(sz == 1, "Expected 1, got %d\n", sz);
4566
4567     res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4568     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4569
4570     /* DisplayVersion value exists */
4571     sz = MAX_PATH;
4572     lstrcpyA(buf, "apple");
4573     r = pMsiGetProductInfoExA(prodcode, usersid,
4574                               MSIINSTALLCONTEXT_USERMANAGED,
4575                               INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4576     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4577     ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
4578     ok(sz == 5, "Expected 5, got %d\n", sz);
4579
4580     res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4581     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4582
4583     /* ProductID value exists */
4584     sz = MAX_PATH;
4585     lstrcpyA(buf, "apple");
4586     r = pMsiGetProductInfoExA(prodcode, usersid,
4587                               MSIINSTALLCONTEXT_USERMANAGED,
4588                               INSTALLPROPERTY_PRODUCTID, buf, &sz);
4589     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4590     ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
4591     ok(sz == 2, "Expected 2, got %d\n", sz);
4592
4593     res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4594     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4595
4596     /* RegCompany value exists */
4597     sz = MAX_PATH;
4598     lstrcpyA(buf, "apple");
4599     r = pMsiGetProductInfoExA(prodcode, usersid,
4600                               MSIINSTALLCONTEXT_USERMANAGED,
4601                               INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4602     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4603     ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
4604     ok(sz == 4, "Expected 4, got %d\n", sz);
4605
4606     res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4607     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4608
4609     /* RegOwner value exists */
4610     sz = MAX_PATH;
4611     lstrcpyA(buf, "apple");
4612     r = pMsiGetProductInfoExA(prodcode, usersid,
4613                               MSIINSTALLCONTEXT_USERMANAGED,
4614                               INSTALLPROPERTY_REGOWNER, buf, &sz);
4615     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4616     ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
4617     ok(sz == 5, "Expected 5, got %d\n", sz);
4618
4619     res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4620     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4621
4622     /* Transforms value exists */
4623     sz = MAX_PATH;
4624     lstrcpyA(buf, "apple");
4625     r = pMsiGetProductInfoExA(prodcode, usersid,
4626                               MSIINSTALLCONTEXT_USERMANAGED,
4627                               INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4628     ok(r == ERROR_UNKNOWN_PRODUCT,
4629        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4630     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4631     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4632
4633     res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4634     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4635
4636     /* Language value exists */
4637     sz = MAX_PATH;
4638     lstrcpyA(buf, "apple");
4639     r = pMsiGetProductInfoExA(prodcode, usersid,
4640                               MSIINSTALLCONTEXT_USERMANAGED,
4641                               INSTALLPROPERTY_LANGUAGE, buf, &sz);
4642     ok(r == ERROR_UNKNOWN_PRODUCT,
4643        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4644     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4645     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4646
4647     res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4648     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4649
4650     /* ProductName value exists */
4651     sz = MAX_PATH;
4652     lstrcpyA(buf, "apple");
4653     r = pMsiGetProductInfoExA(prodcode, usersid,
4654                               MSIINSTALLCONTEXT_USERMANAGED,
4655                               INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4656     ok(r == ERROR_UNKNOWN_PRODUCT,
4657        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4658     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4659     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4660
4661     res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4662     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4663
4664     /* FIXME */
4665
4666     /* AssignmentType value exists */
4667     sz = MAX_PATH;
4668     lstrcpyA(buf, "apple");
4669     r = pMsiGetProductInfoExA(prodcode, usersid,
4670                               MSIINSTALLCONTEXT_USERMANAGED,
4671                               INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4672     ok(r == ERROR_UNKNOWN_PRODUCT,
4673        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4674     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4675     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4676
4677     res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4678     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4679
4680     /* PackageCode value exists */
4681     sz = MAX_PATH;
4682     lstrcpyA(buf, "apple");
4683     r = pMsiGetProductInfoExA(prodcode, usersid,
4684                               MSIINSTALLCONTEXT_USERMANAGED,
4685                               INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4686     ok(r == ERROR_UNKNOWN_PRODUCT,
4687        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4688     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4689     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4690
4691     res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4692     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4693
4694     /* Version value exists */
4695     sz = MAX_PATH;
4696     lstrcpyA(buf, "apple");
4697     r = pMsiGetProductInfoExA(prodcode, usersid,
4698                               MSIINSTALLCONTEXT_USERMANAGED,
4699                               INSTALLPROPERTY_VERSION, buf, &sz);
4700     ok(r == ERROR_UNKNOWN_PRODUCT,
4701        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4702     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4703     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4704
4705     res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4706     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4707
4708     /* ProductIcon value exists */
4709     sz = MAX_PATH;
4710     lstrcpyA(buf, "apple");
4711     r = pMsiGetProductInfoExA(prodcode, usersid,
4712                               MSIINSTALLCONTEXT_USERMANAGED,
4713                               INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4714     ok(r == ERROR_UNKNOWN_PRODUCT,
4715        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4716     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4717     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4718
4719     res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4720     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4721
4722     /* PackageName value exists */
4723     sz = MAX_PATH;
4724     lstrcpyA(buf, "apple");
4725     r = pMsiGetProductInfoExA(prodcode, usersid,
4726                               MSIINSTALLCONTEXT_USERMANAGED,
4727                               INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4728     ok(r == ERROR_UNKNOWN_PRODUCT,
4729        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4730     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4731     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4732
4733     res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4734     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4735
4736     /* AuthorizedLUAApp value exists */
4737     sz = MAX_PATH;
4738     lstrcpyA(buf, "apple");
4739     r = pMsiGetProductInfoExA(prodcode, usersid,
4740                               MSIINSTALLCONTEXT_USERMANAGED,
4741                               INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4742     ok(r == ERROR_UNKNOWN_PRODUCT,
4743        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4744     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4745     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4746
4747     RegDeleteValueA(propkey, "AuthorizedLUAApp");
4748     RegDeleteValueA(propkey, "PackageName");
4749     RegDeleteValueA(propkey, "ProductIcon");
4750     RegDeleteValueA(propkey, "Version");
4751     RegDeleteValueA(propkey, "PackageCode");
4752     RegDeleteValueA(propkey, "AssignmentType");
4753     RegDeleteValueA(propkey, "ProductName");
4754     RegDeleteValueA(propkey, "Language");
4755     RegDeleteValueA(propkey, "Transforms");
4756     RegDeleteValueA(propkey, "RegOwner");
4757     RegDeleteValueA(propkey, "RegCompany");
4758     RegDeleteValueA(propkey, "ProductID");
4759     RegDeleteValueA(propkey, "DisplayVersion");
4760     RegDeleteValueA(propkey, "VersionMajor");
4761     RegDeleteValueA(propkey, "VersionMinor");
4762     RegDeleteValueA(propkey, "URLUpdateInfo");
4763     RegDeleteValueA(propkey, "URLInfoAbout");
4764     RegDeleteValueA(propkey, "Publisher");
4765     RegDeleteValueA(propkey, "LocalPackage");
4766     RegDeleteValueA(propkey, "InstallSource");
4767     RegDeleteValueA(propkey, "InstallLocation");
4768     RegDeleteValueA(propkey, "DisplayName");
4769     RegDeleteValueA(propkey, "InstallDate");
4770     RegDeleteValueA(propkey, "HelpTelephone");
4771     RegDeleteValueA(propkey, "HelpLink");
4772     RegDeleteValueA(propkey, "ManagedLocalPackage");
4773     RegDeleteKeyA(propkey, "");
4774     RegCloseKey(propkey);
4775     RegDeleteKeyA(localkey, "");
4776     RegCloseKey(localkey);
4777
4778     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4779     lstrcatA(keypath, usersid);
4780     lstrcatA(keypath, "\\Installer\\Products\\");
4781     lstrcatA(keypath, prod_squashed);
4782
4783     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
4784     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4785
4786     /* user product key exists */
4787     sz = MAX_PATH;
4788     lstrcpyA(buf, "apple");
4789     r = pMsiGetProductInfoExA(prodcode, usersid,
4790                               MSIINSTALLCONTEXT_USERMANAGED,
4791                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4793     ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
4794     ok(sz == 1, "Expected 1, got %d\n", sz);
4795
4796     RegDeleteKeyA(userkey, "");
4797     RegCloseKey(userkey);
4798
4799     lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
4800     lstrcatA(keypath, prod_squashed);
4801
4802     res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
4803     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4804
4805     /* current user product key exists */
4806     sz = MAX_PATH;
4807     lstrcpyA(buf, "apple");
4808     r = pMsiGetProductInfoExA(prodcode, usersid,
4809                               MSIINSTALLCONTEXT_USERMANAGED,
4810                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4811     ok(r == ERROR_UNKNOWN_PRODUCT,
4812        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4813     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4814     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4815
4816     res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4817     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4818
4819     /* HelpLink value exists, user product key does not exist */
4820     sz = MAX_PATH;
4821     lstrcpyA(buf, "apple");
4822     r = pMsiGetProductInfoExA(prodcode, usersid,
4823                               MSIINSTALLCONTEXT_USERMANAGED,
4824                               INSTALLPROPERTY_HELPLINK, buf, &sz);
4825     ok(r == ERROR_UNKNOWN_PRODUCT,
4826        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4827     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4828     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4829
4830     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4831     lstrcatA(keypath, usersid);
4832     lstrcatA(keypath, "\\Installer\\Products\\");
4833     lstrcatA(keypath, prod_squashed);
4834
4835     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
4836     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4837
4838     res = RegSetValueExA(userkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4839     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4840
4841     /* HelpLink value exists, user product key does exist */
4842     sz = MAX_PATH;
4843     lstrcpyA(buf, "apple");
4844     r = pMsiGetProductInfoExA(prodcode, usersid,
4845                               MSIINSTALLCONTEXT_USERMANAGED,
4846                               INSTALLPROPERTY_HELPLINK, buf, &sz);
4847     ok(r == ERROR_UNKNOWN_PROPERTY,
4848        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4849     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4850     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4851
4852     res = RegSetValueExA(userkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4853     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4854
4855     /* HelpTelephone value exists */
4856     sz = MAX_PATH;
4857     lstrcpyA(buf, "apple");
4858     r = pMsiGetProductInfoExA(prodcode, usersid,
4859                               MSIINSTALLCONTEXT_USERMANAGED,
4860                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4861     ok(r == ERROR_UNKNOWN_PROPERTY,
4862        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4863     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4864     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4865
4866     res = RegSetValueExA(userkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4867     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4868
4869     /* InstallDate value exists */
4870     sz = MAX_PATH;
4871     lstrcpyA(buf, "apple");
4872     r = pMsiGetProductInfoExA(prodcode, usersid,
4873                               MSIINSTALLCONTEXT_USERMANAGED,
4874                               INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4875     ok(r == ERROR_UNKNOWN_PROPERTY,
4876        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4877     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4878     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4879
4880     res = RegSetValueExA(userkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4881     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4882
4883     /* DisplayName value exists */
4884     sz = MAX_PATH;
4885     lstrcpyA(buf, "apple");
4886     r = pMsiGetProductInfoExA(prodcode, usersid,
4887                               MSIINSTALLCONTEXT_USERMANAGED,
4888                               INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4889     ok(r == ERROR_UNKNOWN_PROPERTY,
4890        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4891     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4892     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4893
4894     res = RegSetValueExA(userkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4895     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4896
4897     /* InstallLocation value exists */
4898     sz = MAX_PATH;
4899     lstrcpyA(buf, "apple");
4900     r = pMsiGetProductInfoExA(prodcode, usersid,
4901                               MSIINSTALLCONTEXT_USERMANAGED,
4902                               INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4903     ok(r == ERROR_UNKNOWN_PROPERTY,
4904        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4905     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4906     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4907
4908     res = RegSetValueExA(userkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4909     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4910
4911     /* InstallSource value exists */
4912     sz = MAX_PATH;
4913     lstrcpyA(buf, "apple");
4914     r = pMsiGetProductInfoExA(prodcode, usersid,
4915                               MSIINSTALLCONTEXT_USERMANAGED,
4916                               INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4917     ok(r == ERROR_UNKNOWN_PROPERTY,
4918        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4919     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4920     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4921
4922     res = RegSetValueExA(userkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4923     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4924
4925     /* LocalPackage value exists */
4926     sz = MAX_PATH;
4927     lstrcpyA(buf, "apple");
4928     r = pMsiGetProductInfoExA(prodcode, usersid,
4929                               MSIINSTALLCONTEXT_USERMANAGED,
4930                               INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4931     ok(r == ERROR_UNKNOWN_PROPERTY,
4932        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4933     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4934     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4935
4936     res = RegSetValueExA(userkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4937     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4938
4939     /* Publisher value exists */
4940     sz = MAX_PATH;
4941     lstrcpyA(buf, "apple");
4942     r = pMsiGetProductInfoExA(prodcode, usersid,
4943                               MSIINSTALLCONTEXT_USERMANAGED,
4944                               INSTALLPROPERTY_PUBLISHER, buf, &sz);
4945     ok(r == ERROR_UNKNOWN_PROPERTY,
4946        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4947     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4948     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4949
4950     res = RegSetValueExA(userkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4951     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4952
4953     /* URLInfoAbout value exists */
4954     sz = MAX_PATH;
4955     lstrcpyA(buf, "apple");
4956     r = pMsiGetProductInfoExA(prodcode, usersid,
4957                               MSIINSTALLCONTEXT_USERMANAGED,
4958                               INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4959     ok(r == ERROR_UNKNOWN_PROPERTY,
4960        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4961     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4962     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4963
4964     res = RegSetValueExA(userkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4965     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4966
4967     /* URLUpdateInfo value exists */
4968     sz = MAX_PATH;
4969     lstrcpyA(buf, "apple");
4970     r = pMsiGetProductInfoExA(prodcode, usersid,
4971                               MSIINSTALLCONTEXT_USERMANAGED,
4972                               INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4973     ok(r == ERROR_UNKNOWN_PROPERTY,
4974        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4975     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4976     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4977
4978     res = RegSetValueExA(userkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4979     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4980
4981     /* VersionMinor value exists */
4982     sz = MAX_PATH;
4983     lstrcpyA(buf, "apple");
4984     r = pMsiGetProductInfoExA(prodcode, usersid,
4985                               MSIINSTALLCONTEXT_USERMANAGED,
4986                               INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4987     ok(r == ERROR_UNKNOWN_PROPERTY,
4988        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4989     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4990     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4991
4992     res = RegSetValueExA(userkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4993     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4994
4995     /* VersionMajor value exists */
4996     sz = MAX_PATH;
4997     lstrcpyA(buf, "apple");
4998     r = pMsiGetProductInfoExA(prodcode, usersid,
4999                               MSIINSTALLCONTEXT_USERMANAGED,
5000                               INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5001     ok(r == ERROR_UNKNOWN_PROPERTY,
5002        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5003     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5004     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5005
5006     res = RegSetValueExA(userkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5007     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5008
5009     /* DisplayVersion value exists */
5010     sz = MAX_PATH;
5011     lstrcpyA(buf, "apple");
5012     r = pMsiGetProductInfoExA(prodcode, usersid,
5013                               MSIINSTALLCONTEXT_USERMANAGED,
5014                               INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5015     ok(r == ERROR_UNKNOWN_PROPERTY,
5016        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5017     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5018     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5019
5020     res = RegSetValueExA(userkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5021     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5022
5023     /* ProductID value exists */
5024     sz = MAX_PATH;
5025     lstrcpyA(buf, "apple");
5026     r = pMsiGetProductInfoExA(prodcode, usersid,
5027                               MSIINSTALLCONTEXT_USERMANAGED,
5028                               INSTALLPROPERTY_PRODUCTID, buf, &sz);
5029     ok(r == ERROR_UNKNOWN_PROPERTY,
5030        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5031     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5032     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5033
5034     res = RegSetValueExA(userkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5035     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5036
5037     /* RegCompany value exists */
5038     sz = MAX_PATH;
5039     lstrcpyA(buf, "apple");
5040     r = pMsiGetProductInfoExA(prodcode, usersid,
5041                               MSIINSTALLCONTEXT_USERMANAGED,
5042                               INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5043     ok(r == ERROR_UNKNOWN_PROPERTY,
5044        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5045     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5046     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5047
5048     res = RegSetValueExA(userkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5049     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5050
5051     /* RegOwner value exists */
5052     sz = MAX_PATH;
5053     lstrcpyA(buf, "apple");
5054     r = pMsiGetProductInfoExA(prodcode, usersid,
5055                               MSIINSTALLCONTEXT_USERMANAGED,
5056                               INSTALLPROPERTY_REGOWNER, buf, &sz);
5057     ok(r == ERROR_UNKNOWN_PROPERTY,
5058        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5059     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5060     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5061
5062     res = RegSetValueExA(userkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5063     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5064
5065     /* Transforms value exists */
5066     sz = MAX_PATH;
5067     lstrcpyA(buf, "apple");
5068     r = pMsiGetProductInfoExA(prodcode, usersid,
5069                               MSIINSTALLCONTEXT_USERMANAGED,
5070                               INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5071     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5072     ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
5073     ok(sz == 5, "Expected 5, got %d\n", sz);
5074
5075     res = RegSetValueExA(userkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5076     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5077
5078     /* Language value exists */
5079     sz = MAX_PATH;
5080     lstrcpyA(buf, "apple");
5081     r = pMsiGetProductInfoExA(prodcode, usersid,
5082                               MSIINSTALLCONTEXT_USERMANAGED,
5083                               INSTALLPROPERTY_LANGUAGE, buf, &sz);
5084     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5085     ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
5086     ok(sz == 4, "Expected 4, got %d\n", sz);
5087
5088     res = RegSetValueExA(userkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5089     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5090
5091     /* ProductName value exists */
5092     sz = MAX_PATH;
5093     lstrcpyA(buf, "apple");
5094     r = pMsiGetProductInfoExA(prodcode, usersid,
5095                               MSIINSTALLCONTEXT_USERMANAGED,
5096                               INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5097     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5098     ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5099     ok(sz == 4, "Expected 4, got %d\n", sz);
5100
5101     res = RegSetValueExA(userkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5102     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5103
5104     /* FIXME */
5105
5106     /* AssignmentType value exists */
5107     sz = MAX_PATH;
5108     lstrcpyA(buf, "apple");
5109     r = pMsiGetProductInfoExA(prodcode, usersid,
5110                               MSIINSTALLCONTEXT_USERMANAGED,
5111                               INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5112     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5113     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5114     ok(sz == 0, "Expected 0, got %d\n", sz);
5115
5116     res = RegSetValueExA(userkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5117     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5118
5119     /* FIXME */
5120
5121     /* PackageCode value exists */
5122     sz = MAX_PATH;
5123     lstrcpyA(buf, "apple");
5124     r = pMsiGetProductInfoExA(prodcode, usersid,
5125                               MSIINSTALLCONTEXT_USERMANAGED,
5126                               INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5127     todo_wine
5128     {
5129         ok(r == ERROR_BAD_CONFIGURATION,
5130            "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
5131         ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5132         ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5133     }
5134
5135     res = RegSetValueExA(userkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5136     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5137
5138     /* Version value exists */
5139     sz = MAX_PATH;
5140     lstrcpyA(buf, "apple");
5141     r = pMsiGetProductInfoExA(prodcode, usersid,
5142                               MSIINSTALLCONTEXT_USERMANAGED,
5143                               INSTALLPROPERTY_VERSION, buf, &sz);
5144     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5145     ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
5146     ok(sz == 3, "Expected 3, got %d\n", sz);
5147
5148     res = RegSetValueExA(userkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5149     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5150
5151     /* ProductIcon value exists */
5152     sz = MAX_PATH;
5153     lstrcpyA(buf, "apple");
5154     r = pMsiGetProductInfoExA(prodcode, usersid,
5155                               MSIINSTALLCONTEXT_USERMANAGED,
5156                               INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5157     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5158     ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
5159     ok(sz == 4, "Expected 4, got %d\n", sz);
5160
5161     res = RegSetValueExA(userkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5162     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5163
5164     /* PackageName value exists */
5165     sz = MAX_PATH;
5166     lstrcpyA(buf, "apple");
5167     r = pMsiGetProductInfoExA(prodcode, usersid,
5168                               MSIINSTALLCONTEXT_USERMANAGED,
5169                               INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5170     todo_wine
5171     {
5172         ok(r == ERROR_UNKNOWN_PRODUCT,
5173            "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5174         ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5175         ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5176     }
5177
5178     res = RegSetValueExA(userkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5179     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5180
5181     /* AuthorizedLUAApp value exists */
5182     sz = MAX_PATH;
5183     lstrcpyA(buf, "apple");
5184     r = pMsiGetProductInfoExA(prodcode, usersid,
5185                               MSIINSTALLCONTEXT_USERMANAGED,
5186                               INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5187     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5188     ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
5189     ok(sz == 4, "Expected 4, got %d\n", sz);
5190
5191     RegDeleteValueA(userkey, "AuthorizedLUAApp");
5192     RegDeleteValueA(userkey, "PackageName");
5193     RegDeleteValueA(userkey, "ProductIcon");
5194     RegDeleteValueA(userkey, "Version");
5195     RegDeleteValueA(userkey, "PackageCode");
5196     RegDeleteValueA(userkey, "AssignmentType");
5197     RegDeleteValueA(userkey, "ProductName");
5198     RegDeleteValueA(userkey, "Language");
5199     RegDeleteValueA(userkey, "Transforms");
5200     RegDeleteValueA(userkey, "RegOwner");
5201     RegDeleteValueA(userkey, "RegCompany");
5202     RegDeleteValueA(userkey, "ProductID");
5203     RegDeleteValueA(userkey, "DisplayVersion");
5204     RegDeleteValueA(userkey, "VersionMajor");
5205     RegDeleteValueA(userkey, "VersionMinor");
5206     RegDeleteValueA(userkey, "URLUpdateInfo");
5207     RegDeleteValueA(userkey, "URLInfoAbout");
5208     RegDeleteValueA(userkey, "Publisher");
5209     RegDeleteValueA(userkey, "LocalPackage");
5210     RegDeleteValueA(userkey, "InstallSource");
5211     RegDeleteValueA(userkey, "InstallLocation");
5212     RegDeleteValueA(userkey, "DisplayName");
5213     RegDeleteValueA(userkey, "InstallDate");
5214     RegDeleteValueA(userkey, "HelpTelephone");
5215     RegDeleteValueA(userkey, "HelpLink");
5216     RegDeleteKeyA(userkey, "");
5217     RegCloseKey(userkey);
5218     RegDeleteKeyA(prodkey, "");
5219     RegCloseKey(prodkey);
5220
5221     /* MSIINSTALLCONTEXT_MACHINE */
5222
5223     /* szUserSid is non-NULL */
5224     sz = MAX_PATH;
5225     lstrcpyA(buf, "apple");
5226     r = pMsiGetProductInfoExA(prodcode, usersid,
5227                               MSIINSTALLCONTEXT_MACHINE,
5228                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5229     ok(r == ERROR_INVALID_PARAMETER,
5230        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5231     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5232     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5233
5234     lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
5235     lstrcatA(keypath, prod_squashed);
5236
5237     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
5238     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5239
5240     /* local system product key exists */
5241     sz = MAX_PATH;
5242     lstrcpyA(buf, "apple");
5243     r = pMsiGetProductInfoExA(prodcode, NULL,
5244                               MSIINSTALLCONTEXT_MACHINE,
5245                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5246     ok(r == ERROR_UNKNOWN_PRODUCT,
5247        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5248     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5249     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5250
5251     res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
5252     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5253
5254     /* InstallProperties key exists */
5255     sz = MAX_PATH;
5256     lstrcpyA(buf, "apple");
5257     r = pMsiGetProductInfoExA(prodcode, NULL,
5258                               MSIINSTALLCONTEXT_MACHINE,
5259                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5260     ok(r == ERROR_UNKNOWN_PRODUCT,
5261        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5262     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5263     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5264
5265     res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5266     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5267
5268     /* LocalPackage value exists */
5269     sz = MAX_PATH;
5270     lstrcpyA(buf, "apple");
5271     r = pMsiGetProductInfoExA(prodcode, NULL,
5272                               MSIINSTALLCONTEXT_MACHINE,
5273                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5274     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5275     ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
5276     ok(sz == 1, "Expected 1, got %d\n", sz);
5277
5278     res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5279     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5280
5281     /* HelpLink value exists */
5282     sz = MAX_PATH;
5283     lstrcpyA(buf, "apple");
5284     r = pMsiGetProductInfoExA(prodcode, NULL,
5285                               MSIINSTALLCONTEXT_MACHINE,
5286                               INSTALLPROPERTY_HELPLINK, buf, &sz);
5287     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5288     ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
5289     ok(sz == 4, "Expected 4, got %d\n", sz);
5290
5291     res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5292     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5293
5294     /* HelpTelephone value exists */
5295     sz = MAX_PATH;
5296     lstrcpyA(buf, "apple");
5297     r = pMsiGetProductInfoExA(prodcode, NULL,
5298                               MSIINSTALLCONTEXT_MACHINE,
5299                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5300     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5301     ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
5302     ok(sz == 5, "Expected 5, got %d\n", sz);
5303
5304     res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5305     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5306
5307     /* InstallDate value exists */
5308     sz = MAX_PATH;
5309     lstrcpyA(buf, "apple");
5310     r = pMsiGetProductInfoExA(prodcode, NULL,
5311                               MSIINSTALLCONTEXT_MACHINE,
5312                               INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5313     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5314     ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
5315     ok(sz == 4, "Expected 4, got %d\n", sz);
5316
5317     res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5318     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5319
5320     /* DisplayName value exists */
5321     sz = MAX_PATH;
5322     lstrcpyA(buf, "apple");
5323     r = pMsiGetProductInfoExA(prodcode, NULL,
5324                               MSIINSTALLCONTEXT_MACHINE,
5325                               INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5326     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5327     ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5328     ok(sz == 4, "Expected 4, got %d\n", sz);
5329
5330     res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5331     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5332
5333     /* InstallLocation value exists */
5334     sz = MAX_PATH;
5335     lstrcpyA(buf, "apple");
5336     r = pMsiGetProductInfoExA(prodcode, NULL,
5337                               MSIINSTALLCONTEXT_MACHINE,
5338                               INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5339     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5340     ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
5341     ok(sz == 3, "Expected 3, got %d\n", sz);
5342
5343     res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5344     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5345
5346     /* InstallSource value exists */
5347     sz = MAX_PATH;
5348     lstrcpyA(buf, "apple");
5349     r = pMsiGetProductInfoExA(prodcode, NULL,
5350                               MSIINSTALLCONTEXT_MACHINE,
5351                               INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5352     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5353     ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
5354     ok(sz == 6, "Expected 6, got %d\n", sz);
5355
5356     res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5357     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5358
5359     /* LocalPackage value exists */
5360     sz = MAX_PATH;
5361     lstrcpyA(buf, "apple");
5362     r = pMsiGetProductInfoExA(prodcode, NULL,
5363                               MSIINSTALLCONTEXT_MACHINE,
5364                               INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5365     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5366     ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
5367     ok(sz == 5, "Expected 5, got %d\n", sz);
5368
5369     res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5370     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5371
5372     /* Publisher value exists */
5373     sz = MAX_PATH;
5374     lstrcpyA(buf, "apple");
5375     r = pMsiGetProductInfoExA(prodcode, NULL,
5376                               MSIINSTALLCONTEXT_MACHINE,
5377                               INSTALLPROPERTY_PUBLISHER, buf, &sz);
5378     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5379     ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
5380     ok(sz == 3, "Expected 3, got %d\n", sz);
5381
5382     res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5383     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5384
5385     /* URLInfoAbout value exists */
5386     sz = MAX_PATH;
5387     lstrcpyA(buf, "apple");
5388     r = pMsiGetProductInfoExA(prodcode, NULL,
5389                               MSIINSTALLCONTEXT_MACHINE,
5390                               INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5391     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5392     ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
5393     ok(sz == 5, "Expected 5, got %d\n", sz);
5394
5395     res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5396     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5397
5398     /* URLUpdateInfo value exists */
5399     sz = MAX_PATH;
5400     lstrcpyA(buf, "apple");
5401     r = pMsiGetProductInfoExA(prodcode, NULL,
5402                               MSIINSTALLCONTEXT_MACHINE,
5403                               INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5404     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5405     ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
5406     ok(sz == 6, "Expected 6, got %d\n", sz);
5407
5408     res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5409     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5410
5411     /* VersionMinor value exists */
5412     sz = MAX_PATH;
5413     lstrcpyA(buf, "apple");
5414     r = pMsiGetProductInfoExA(prodcode, NULL,
5415                               MSIINSTALLCONTEXT_MACHINE,
5416                               INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5417     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5418     ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
5419     ok(sz == 1, "Expected 1, got %d\n", sz);
5420
5421     res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5422     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5423
5424     /* VersionMajor value exists */
5425     sz = MAX_PATH;
5426     lstrcpyA(buf, "apple");
5427     r = pMsiGetProductInfoExA(prodcode, NULL,
5428                               MSIINSTALLCONTEXT_MACHINE,
5429                               INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5431     ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5432     ok(sz == 1, "Expected 1, got %d\n", sz);
5433
5434     res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5435     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5436
5437     /* DisplayVersion value exists */
5438     sz = MAX_PATH;
5439     lstrcpyA(buf, "apple");
5440     r = pMsiGetProductInfoExA(prodcode, NULL,
5441                               MSIINSTALLCONTEXT_MACHINE,
5442                               INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5443     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5444     ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
5445     ok(sz == 5, "Expected 5, got %d\n", sz);
5446
5447     res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5448     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5449
5450     /* ProductID value exists */
5451     sz = MAX_PATH;
5452     lstrcpyA(buf, "apple");
5453     r = pMsiGetProductInfoExA(prodcode, NULL,
5454                               MSIINSTALLCONTEXT_MACHINE,
5455                               INSTALLPROPERTY_PRODUCTID, buf, &sz);
5456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5457     ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
5458     ok(sz == 2, "Expected 2, got %d\n", sz);
5459
5460     res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5461     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5462
5463     /* RegCompany value exists */
5464     sz = MAX_PATH;
5465     lstrcpyA(buf, "apple");
5466     r = pMsiGetProductInfoExA(prodcode, NULL,
5467                               MSIINSTALLCONTEXT_MACHINE,
5468                               INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5469     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5470     ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
5471     ok(sz == 4, "Expected 4, got %d\n", sz);
5472
5473     res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5474     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5475
5476     /* RegOwner value exists */
5477     sz = MAX_PATH;
5478     lstrcpyA(buf, "apple");
5479     r = pMsiGetProductInfoExA(prodcode, NULL,
5480                               MSIINSTALLCONTEXT_MACHINE,
5481                               INSTALLPROPERTY_REGOWNER, buf, &sz);
5482     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5483     ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
5484     ok(sz == 5, "Expected 5, got %d\n", sz);
5485
5486     res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5487     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5488
5489     /* Transforms value exists */
5490     sz = MAX_PATH;
5491     lstrcpyA(buf, "apple");
5492     r = pMsiGetProductInfoExA(prodcode, NULL,
5493                               MSIINSTALLCONTEXT_MACHINE,
5494                               INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5495     ok(r == ERROR_UNKNOWN_PRODUCT,
5496        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5497     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5498     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5499
5500     res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5501     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5502
5503     /* Language value exists */
5504     sz = MAX_PATH;
5505     lstrcpyA(buf, "apple");
5506     r = pMsiGetProductInfoExA(prodcode, NULL,
5507                               MSIINSTALLCONTEXT_MACHINE,
5508                               INSTALLPROPERTY_LANGUAGE, buf, &sz);
5509     ok(r == ERROR_UNKNOWN_PRODUCT,
5510        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5511     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5512     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5513
5514     res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5515     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5516
5517     /* ProductName value exists */
5518     sz = MAX_PATH;
5519     lstrcpyA(buf, "apple");
5520     r = pMsiGetProductInfoExA(prodcode, NULL,
5521                               MSIINSTALLCONTEXT_MACHINE,
5522                               INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5523     ok(r == ERROR_UNKNOWN_PRODUCT,
5524        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5525     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5526     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5527
5528     res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5529     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5530
5531     /* FIXME */
5532
5533     /* AssignmentType value exists */
5534     sz = MAX_PATH;
5535     lstrcpyA(buf, "apple");
5536     r = pMsiGetProductInfoExA(prodcode, NULL,
5537                               MSIINSTALLCONTEXT_MACHINE,
5538                               INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5539     ok(r == ERROR_UNKNOWN_PRODUCT,
5540        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5541     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5542     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5543
5544     res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5545     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5546
5547     /* PackageCode value exists */
5548     sz = MAX_PATH;
5549     lstrcpyA(buf, "apple");
5550     r = pMsiGetProductInfoExA(prodcode, NULL,
5551                               MSIINSTALLCONTEXT_MACHINE,
5552                               INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5553     ok(r == ERROR_UNKNOWN_PRODUCT,
5554        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5555     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5556     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5557
5558     res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5559     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5560
5561     /* Version value exists */
5562     sz = MAX_PATH;
5563     lstrcpyA(buf, "apple");
5564     r = pMsiGetProductInfoExA(prodcode, NULL,
5565                               MSIINSTALLCONTEXT_MACHINE,
5566                               INSTALLPROPERTY_VERSION, buf, &sz);
5567     ok(r == ERROR_UNKNOWN_PRODUCT,
5568        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5569     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5570     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5571
5572     res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5573     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5574
5575     /* ProductIcon value exists */
5576     sz = MAX_PATH;
5577     lstrcpyA(buf, "apple");
5578     r = pMsiGetProductInfoExA(prodcode, NULL,
5579                               MSIINSTALLCONTEXT_MACHINE,
5580                               INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5581     ok(r == ERROR_UNKNOWN_PRODUCT,
5582        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5583     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5584     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5585
5586     res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5587     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5588
5589     /* PackageName value exists */
5590     sz = MAX_PATH;
5591     lstrcpyA(buf, "apple");
5592     r = pMsiGetProductInfoExA(prodcode, NULL,
5593                               MSIINSTALLCONTEXT_MACHINE,
5594                               INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5595     ok(r == ERROR_UNKNOWN_PRODUCT,
5596        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5597     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5598     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5599
5600     res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5601     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5602
5603     /* AuthorizedLUAApp value exists */
5604     sz = MAX_PATH;
5605     lstrcpyA(buf, "apple");
5606     r = pMsiGetProductInfoExA(prodcode, NULL,
5607                               MSIINSTALLCONTEXT_MACHINE,
5608                               INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5609     ok(r == ERROR_UNKNOWN_PRODUCT,
5610        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5611     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5612     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5613
5614     RegDeleteValueA(propkey, "AuthorizedLUAApp");
5615     RegDeleteValueA(propkey, "PackageName");
5616     RegDeleteValueA(propkey, "ProductIcon");
5617     RegDeleteValueA(propkey, "Version");
5618     RegDeleteValueA(propkey, "PackageCode");
5619     RegDeleteValueA(propkey, "AssignmentType");
5620     RegDeleteValueA(propkey, "ProductName");
5621     RegDeleteValueA(propkey, "Language");
5622     RegDeleteValueA(propkey, "Transforms");
5623     RegDeleteValueA(propkey, "RegOwner");
5624     RegDeleteValueA(propkey, "RegCompany");
5625     RegDeleteValueA(propkey, "ProductID");
5626     RegDeleteValueA(propkey, "DisplayVersion");
5627     RegDeleteValueA(propkey, "VersionMajor");
5628     RegDeleteValueA(propkey, "VersionMinor");
5629     RegDeleteValueA(propkey, "URLUpdateInfo");
5630     RegDeleteValueA(propkey, "URLInfoAbout");
5631     RegDeleteValueA(propkey, "Publisher");
5632     RegDeleteValueA(propkey, "LocalPackage");
5633     RegDeleteValueA(propkey, "InstallSource");
5634     RegDeleteValueA(propkey, "InstallLocation");
5635     RegDeleteValueA(propkey, "DisplayName");
5636     RegDeleteValueA(propkey, "InstallDate");
5637     RegDeleteValueA(propkey, "HelpTelephone");
5638     RegDeleteValueA(propkey, "HelpLink");
5639     RegDeleteValueA(propkey, "LocalPackage");
5640     RegDeleteKeyA(propkey, "");
5641     RegCloseKey(propkey);
5642     RegDeleteKeyA(localkey, "");
5643     RegCloseKey(localkey);
5644
5645     lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
5646     lstrcatA(keypath, prod_squashed);
5647
5648     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
5649     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5650
5651     /* local classes product key exists */
5652     sz = MAX_PATH;
5653     lstrcpyA(buf, "apple");
5654     r = pMsiGetProductInfoExA(prodcode, NULL,
5655                               MSIINSTALLCONTEXT_MACHINE,
5656                               INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5657     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5658     ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
5659     ok(sz == 1, "Expected 1, got %d\n", sz);
5660
5661     res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5662     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5663
5664     /* HelpLink value exists */
5665     sz = MAX_PATH;
5666     lstrcpyA(buf, "apple");
5667     r = pMsiGetProductInfoExA(prodcode, NULL,
5668                               MSIINSTALLCONTEXT_MACHINE,
5669                               INSTALLPROPERTY_HELPLINK, buf, &sz);
5670     ok(r == ERROR_UNKNOWN_PROPERTY,
5671        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5672     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5673     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5674
5675     res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5676     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5677
5678     /* HelpTelephone value exists */
5679     sz = MAX_PATH;
5680     lstrcpyA(buf, "apple");
5681     r = pMsiGetProductInfoExA(prodcode, NULL,
5682                               MSIINSTALLCONTEXT_MACHINE,
5683                               INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5684     ok(r == ERROR_UNKNOWN_PROPERTY,
5685        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5686     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5687     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5688
5689     res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5690     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5691
5692     /* InstallDate value exists */
5693     sz = MAX_PATH;
5694     lstrcpyA(buf, "apple");
5695     r = pMsiGetProductInfoExA(prodcode, NULL,
5696                               MSIINSTALLCONTEXT_MACHINE,
5697                               INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5698     ok(r == ERROR_UNKNOWN_PROPERTY,
5699        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5700     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5701     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5702
5703     res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5704     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5705
5706     /* DisplayName value exists */
5707     sz = MAX_PATH;
5708     lstrcpyA(buf, "apple");
5709     r = pMsiGetProductInfoExA(prodcode, NULL,
5710                               MSIINSTALLCONTEXT_MACHINE,
5711                               INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5712     ok(r == ERROR_UNKNOWN_PROPERTY,
5713        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5714     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5715     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5716
5717     res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5718     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5719
5720     /* InstallLocation value exists */
5721     sz = MAX_PATH;
5722     lstrcpyA(buf, "apple");
5723     r = pMsiGetProductInfoExA(prodcode, NULL,
5724                               MSIINSTALLCONTEXT_MACHINE,
5725                               INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5726     ok(r == ERROR_UNKNOWN_PROPERTY,
5727        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5728     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5729     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5730
5731     res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5732     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5733
5734     /* InstallSource value exists */
5735     sz = MAX_PATH;
5736     lstrcpyA(buf, "apple");
5737     r = pMsiGetProductInfoExA(prodcode, NULL,
5738                               MSIINSTALLCONTEXT_MACHINE,
5739                               INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5740     ok(r == ERROR_UNKNOWN_PROPERTY,
5741        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5742     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5743     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5744
5745     res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5746     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5747
5748     /* LocalPackage value exists */
5749     sz = MAX_PATH;
5750     lstrcpyA(buf, "apple");
5751     r = pMsiGetProductInfoExA(prodcode, NULL,
5752                               MSIINSTALLCONTEXT_MACHINE,
5753                               INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5754     ok(r == ERROR_UNKNOWN_PROPERTY,
5755        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5756     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5757     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5758
5759     res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5760     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5761
5762     /* Publisher value exists */
5763     sz = MAX_PATH;
5764     lstrcpyA(buf, "apple");
5765     r = pMsiGetProductInfoExA(prodcode, NULL,
5766                               MSIINSTALLCONTEXT_MACHINE,
5767                               INSTALLPROPERTY_PUBLISHER, buf, &sz);
5768     ok(r == ERROR_UNKNOWN_PROPERTY,
5769        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5770     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5771     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5772
5773     res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5774     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5775
5776     /* URLInfoAbout value exists */
5777     sz = MAX_PATH;
5778     lstrcpyA(buf, "apple");
5779     r = pMsiGetProductInfoExA(prodcode, NULL,
5780                               MSIINSTALLCONTEXT_MACHINE,
5781                               INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5782     ok(r == ERROR_UNKNOWN_PROPERTY,
5783        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5784     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5785     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5786
5787     res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5788     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5789
5790     /* URLUpdateInfo value exists */
5791     sz = MAX_PATH;
5792     lstrcpyA(buf, "apple");
5793     r = pMsiGetProductInfoExA(prodcode, NULL,
5794                               MSIINSTALLCONTEXT_MACHINE,
5795                               INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5796     ok(r == ERROR_UNKNOWN_PROPERTY,
5797        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5798     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5799     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5800
5801     res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5802     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5803
5804     /* VersionMinor value exists */
5805     sz = MAX_PATH;
5806     lstrcpyA(buf, "apple");
5807     r = pMsiGetProductInfoExA(prodcode, NULL,
5808                               MSIINSTALLCONTEXT_MACHINE,
5809                               INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5810     ok(r == ERROR_UNKNOWN_PROPERTY,
5811        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5812     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5813     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5814
5815     res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5816     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5817
5818     /* VersionMajor value exists */
5819     sz = MAX_PATH;
5820     lstrcpyA(buf, "apple");
5821     r = pMsiGetProductInfoExA(prodcode, NULL,
5822                               MSIINSTALLCONTEXT_MACHINE,
5823                               INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5824     ok(r == ERROR_UNKNOWN_PROPERTY,
5825        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5826     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5827     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5828
5829     res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5830     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5831
5832     /* DisplayVersion value exists */
5833     sz = MAX_PATH;
5834     lstrcpyA(buf, "apple");
5835     r = pMsiGetProductInfoExA(prodcode, NULL,
5836                               MSIINSTALLCONTEXT_MACHINE,
5837                               INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5838     ok(r == ERROR_UNKNOWN_PROPERTY,
5839        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5840     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5841     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5842
5843     res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5844     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5845
5846     /* ProductID value exists */
5847     sz = MAX_PATH;
5848     lstrcpyA(buf, "apple");
5849     r = pMsiGetProductInfoExA(prodcode, NULL,
5850                               MSIINSTALLCONTEXT_MACHINE,
5851                               INSTALLPROPERTY_PRODUCTID, buf, &sz);
5852     ok(r == ERROR_UNKNOWN_PROPERTY,
5853        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5854     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5855     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5856
5857     res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5858     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5859
5860     /* RegCompany value exists */
5861     sz = MAX_PATH;
5862     lstrcpyA(buf, "apple");
5863     r = pMsiGetProductInfoExA(prodcode, NULL,
5864                               MSIINSTALLCONTEXT_MACHINE,
5865                               INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5866     ok(r == ERROR_UNKNOWN_PROPERTY,
5867        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5868     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5869     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5870
5871     res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5872     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5873
5874     /* RegOwner value exists */
5875     sz = MAX_PATH;
5876     lstrcpyA(buf, "apple");
5877     r = pMsiGetProductInfoExA(prodcode, NULL,
5878                               MSIINSTALLCONTEXT_MACHINE,
5879                               INSTALLPROPERTY_REGOWNER, buf, &sz);
5880     ok(r == ERROR_UNKNOWN_PROPERTY,
5881        "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5882     ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5883     ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5884
5885     res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5886     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5887
5888     /* Transforms value exists */
5889     sz = MAX_PATH;
5890     lstrcpyA(buf, "apple");
5891     r = pMsiGetProductInfoExA(prodcode, NULL,
5892                               MSIINSTALLCONTEXT_MACHINE,
5893                               INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5894     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5895     ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
5896     ok(sz == 5, "Expected 5, got %d\n", sz);
5897
5898     res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5899     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5900
5901     /* Language value exists */
5902     sz = MAX_PATH;
5903     lstrcpyA(buf, "apple");
5904     r = pMsiGetProductInfoExA(prodcode, NULL,
5905                               MSIINSTALLCONTEXT_MACHINE,
5906                               INSTALLPROPERTY_LANGUAGE, buf, &sz);
5907     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5908     ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
5909     ok(sz == 4, "Expected 4, got %d\n", sz);
5910
5911     res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5912     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5913
5914     /* ProductName value exists */
5915     sz = MAX_PATH;
5916     lstrcpyA(buf, "apple");
5917     r = pMsiGetProductInfoExA(prodcode, NULL,
5918                               MSIINSTALLCONTEXT_MACHINE,
5919                               INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5920     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5921     ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5922     ok(sz == 4, "Expected 4, got %d\n", sz);
5923
5924     res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5925     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5926
5927     /* FIXME */
5928
5929     /* AssignmentType value exists */
5930     sz = MAX_PATH;
5931     lstrcpyA(buf, "apple");
5932     r = pMsiGetProductInfoExA(prodcode, NULL,
5933                               MSIINSTALLCONTEXT_MACHINE,
5934                               INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5935     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5936     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5937     ok(sz == 0, "Expected 0, got %d\n", sz);
5938
5939     res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5940     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5941
5942     /* FIXME */
5943
5944     /* PackageCode value exists */
5945     sz = MAX_PATH;
5946     lstrcpyA(buf, "apple");
5947     r = pMsiGetProductInfoExA(prodcode, NULL,
5948                               MSIINSTALLCONTEXT_MACHINE,
5949                               INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5950     todo_wine
5951     {
5952         ok(r == ERROR_BAD_CONFIGURATION,
5953            "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
5954         ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5955         ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5956     }
5957
5958     res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5959     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5960
5961     /* Version value exists */
5962     sz = MAX_PATH;
5963     lstrcpyA(buf, "apple");
5964     r = pMsiGetProductInfoExA(prodcode, NULL,
5965                               MSIINSTALLCONTEXT_MACHINE,
5966                               INSTALLPROPERTY_VERSION, buf, &sz);
5967     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5968     ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
5969     ok(sz == 3, "Expected 3, got %d\n", sz);
5970
5971     res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5972     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5973
5974     /* ProductIcon value exists */
5975     sz = MAX_PATH;
5976     lstrcpyA(buf, "apple");
5977     r = pMsiGetProductInfoExA(prodcode, NULL,
5978                               MSIINSTALLCONTEXT_MACHINE,
5979                               INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5980     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5981     ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
5982     ok(sz == 4, "Expected 4, got %d\n", sz);
5983
5984     res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5985     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5986
5987     /* PackageName value exists */
5988     sz = MAX_PATH;
5989     lstrcpyA(buf, "apple");
5990     r = pMsiGetProductInfoExA(prodcode, NULL,
5991                               MSIINSTALLCONTEXT_MACHINE,
5992                               INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5993     todo_wine
5994     {
5995         ok(r == ERROR_UNKNOWN_PRODUCT,
5996            "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5997         ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5998         ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5999     }
6000
6001     res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6002     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6003
6004     /* AuthorizedLUAApp value exists */
6005     sz = MAX_PATH;
6006     lstrcpyA(buf, "apple");
6007     r = pMsiGetProductInfoExA(prodcode, NULL,
6008                               MSIINSTALLCONTEXT_MACHINE,
6009                               INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
6010     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6011     ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
6012     ok(sz == 4, "Expected 4, got %d\n", sz);
6013
6014     RegDeleteValueA(prodkey, "AuthorizedLUAApp");
6015     RegDeleteValueA(prodkey, "PackageName");
6016     RegDeleteValueA(prodkey, "ProductIcon");
6017     RegDeleteValueA(prodkey, "Version");
6018     RegDeleteValueA(prodkey, "PackageCode");
6019     RegDeleteValueA(prodkey, "AssignmentType");
6020     RegDeleteValueA(prodkey, "ProductName");
6021     RegDeleteValueA(prodkey, "Language");
6022     RegDeleteValueA(prodkey, "Transforms");
6023     RegDeleteValueA(prodkey, "RegOwner");
6024     RegDeleteValueA(prodkey, "RegCompany");
6025     RegDeleteValueA(prodkey, "ProductID");
6026     RegDeleteValueA(prodkey, "DisplayVersion");
6027     RegDeleteValueA(prodkey, "VersionMajor");
6028     RegDeleteValueA(prodkey, "VersionMinor");
6029     RegDeleteValueA(prodkey, "URLUpdateInfo");
6030     RegDeleteValueA(prodkey, "URLInfoAbout");
6031     RegDeleteValueA(prodkey, "Publisher");
6032     RegDeleteValueA(prodkey, "LocalPackage");
6033     RegDeleteValueA(prodkey, "InstallSource");
6034     RegDeleteValueA(prodkey, "InstallLocation");
6035     RegDeleteValueA(prodkey, "DisplayName");
6036     RegDeleteValueA(prodkey, "InstallDate");
6037     RegDeleteValueA(prodkey, "HelpTelephone");
6038     RegDeleteValueA(prodkey, "HelpLink");
6039     RegDeleteKeyA(prodkey, "");
6040     RegCloseKey(prodkey);
6041 }
6042
6043 START_TEST(msi)
6044 {
6045     init_functionpointers();
6046
6047     test_usefeature();
6048     test_null();
6049     test_getcomponentpath();
6050     test_MsiGetFileHash();
6051
6052     if (!pConvertSidToStringSidA)
6053         skip("ConvertSidToStringSidA not implemented\n");
6054     else
6055     {
6056         /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
6057         test_MsiQueryProductState();
6058         test_MsiQueryFeatureState();
6059         test_MsiQueryComponentState();
6060         test_MsiGetComponentPath();
6061         test_MsiGetProductCode();
6062         test_MsiEnumClients();
6063         test_MsiGetProductInfo();
6064         test_MsiGetProductInfoEx();
6065     }
6066
6067     test_MsiGetFileVersion();
6068 }