push 0e883ac4a03c91e56787e1ec12e001b6558b4b62
[wine/hacks.git] / dlls / msi / tests / msi.c
blobbafcddcf701e3bb8eb737b03c157d8b87c72b3b4
1 /*
2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define _WIN32_MSI 300
23 #include <stdio.h>
24 #include <windows.h>
25 #include <msi.h>
26 #include <msiquery.h>
27 #include <msidefs.h>
28 #include <sddl.h>
30 #include "wine/test.h"
32 static const char msifile[] = "winetest.msi";
34 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
36 static INSTALLSTATE (WINAPI *pMsiGetComponentPathA)
37 (LPCSTR, LPCSTR, LPSTR, DWORD*);
38 static UINT (WINAPI *pMsiGetFileHashA)
39 (LPCSTR, DWORD, PMSIFILEHASHINFO);
40 static UINT (WINAPI *pMsiGetProductInfoExA)
41 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, LPSTR, LPDWORD);
42 static UINT (WINAPI *pMsiOpenPackageExA)
43 (LPCSTR, DWORD, MSIHANDLE*);
44 static UINT (WINAPI *pMsiOpenPackageExW)
45 (LPCWSTR, DWORD, MSIHANDLE*);
46 static UINT (WINAPI *pMsiQueryComponentStateA)
47 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
48 static INSTALLSTATE (WINAPI *pMsiUseFeatureExA)
49 (LPCSTR, LPCSTR ,DWORD, DWORD );
51 static void init_functionpointers(void)
53 HMODULE hmsi = GetModuleHandleA("msi.dll");
54 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
56 #define GET_PROC(dll, func) \
57 p ## func = (void *)GetProcAddress(dll, #func); \
58 if(!p ## func) \
59 trace("GetProcAddress(%s) failed\n", #func);
61 GET_PROC(hmsi, MsiGetComponentPathA)
62 GET_PROC(hmsi, MsiGetFileHashA)
63 GET_PROC(hmsi, MsiGetProductInfoExA)
64 GET_PROC(hmsi, MsiOpenPackageExA)
65 GET_PROC(hmsi, MsiOpenPackageExW)
66 GET_PROC(hmsi, MsiQueryComponentStateA)
67 GET_PROC(hmsi, MsiUseFeatureExA)
69 GET_PROC(hadvapi32, ConvertSidToStringSidA)
71 #undef GET_PROC
74 static UINT run_query(MSIHANDLE hdb, const char *query)
76 MSIHANDLE hview = 0;
77 UINT r;
79 r = MsiDatabaseOpenView(hdb, query, &hview);
80 if (r != ERROR_SUCCESS)
81 return r;
83 r = MsiViewExecute(hview, 0);
84 if (r == ERROR_SUCCESS)
85 r = MsiViewClose(hview);
86 MsiCloseHandle(hview);
87 return r;
90 static UINT set_summary_info(MSIHANDLE hdb, LPSTR prodcode)
92 UINT res;
93 MSIHANDLE suminfo;
95 /* build summary info */
96 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
97 ok(res == ERROR_SUCCESS, "Failed to open summaryinfo\n");
99 res = MsiSummaryInfoSetProperty(suminfo, 2, VT_LPSTR, 0, NULL,
100 "Installation Database");
101 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
103 res = MsiSummaryInfoSetProperty(suminfo, 3, VT_LPSTR, 0, NULL,
104 "Installation Database");
105 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
107 res = MsiSummaryInfoSetProperty(suminfo, 4, VT_LPSTR, 0, NULL,
108 "Wine Hackers");
109 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
111 res = MsiSummaryInfoSetProperty(suminfo, 7, VT_LPSTR, 0, NULL,
112 ";1033");
113 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
115 res = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
116 "{A2078D65-94D6-4205-8DEE-F68D6FD622AA}");
117 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
119 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
120 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
122 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
123 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
125 res = MsiSummaryInfoPersist(suminfo);
126 ok(res == ERROR_SUCCESS, "Failed to make summary info persist\n");
128 res = MsiCloseHandle(suminfo);
129 ok(res == ERROR_SUCCESS, "Failed to close suminfo\n");
131 return res;
134 static MSIHANDLE create_package_db(LPSTR prodcode)
136 MSIHANDLE hdb = 0;
137 CHAR query[MAX_PATH];
138 UINT res;
140 DeleteFile(msifile);
142 /* create an empty database */
143 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
144 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
145 if (res != ERROR_SUCCESS)
146 return hdb;
148 res = MsiDatabaseCommit(hdb);
149 ok(res == ERROR_SUCCESS, "Failed to commit database\n");
151 set_summary_info(hdb, prodcode);
153 res = run_query(hdb,
154 "CREATE TABLE `Directory` ( "
155 "`Directory` CHAR(255) NOT NULL, "
156 "`Directory_Parent` CHAR(255), "
157 "`DefaultDir` CHAR(255) NOT NULL "
158 "PRIMARY KEY `Directory`)");
159 ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
161 res = run_query(hdb,
162 "CREATE TABLE `Property` ( "
163 "`Property` CHAR(72) NOT NULL, "
164 "`Value` CHAR(255) "
165 "PRIMARY KEY `Property`)");
166 ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
168 sprintf(query, "INSERT INTO `Property` "
169 "(`Property`, `Value`) "
170 "VALUES( 'ProductCode', '%s' )", prodcode);
171 res = run_query(hdb, query);
172 ok(res == ERROR_SUCCESS , "Failed\n");
174 res = MsiDatabaseCommit(hdb);
175 ok(res == ERROR_SUCCESS, "Failed to commit database\n");
177 return hdb;
180 static void test_usefeature(void)
182 INSTALLSTATE r;
184 if (!pMsiUseFeatureExA)
186 skip("MsiUseFeatureExA not implemented\n");
187 return;
190 r = MsiQueryFeatureState(NULL,NULL);
191 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
193 r = MsiQueryFeatureState("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL);
194 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
196 r = pMsiUseFeatureExA(NULL,NULL,0,0);
197 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
199 r = pMsiUseFeatureExA(NULL, "WORDVIEWFiles", -2, 1 );
200 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
202 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
203 NULL, -2, 0 );
204 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
206 r = pMsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
207 "WORDVIEWFiles", -2, 0 );
208 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
210 r = pMsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
211 "WORDVIEWFiles", -2, 0 );
212 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
214 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
215 "WORDVIEWFiles", -2, 1 );
216 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
219 static void test_null(void)
221 MSIHANDLE hpkg;
222 UINT r;
223 HKEY hkey;
224 DWORD dwType, cbData;
225 LPBYTE lpData = NULL;
226 INSTALLSTATE state;
228 r = pMsiOpenPackageExW(NULL, 0, &hpkg);
229 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
231 state = MsiQueryProductStateW(NULL);
232 ok( state == INSTALLSTATE_INVALIDARG, "wrong return\n");
234 r = MsiEnumFeaturesW(NULL,0,NULL,NULL);
235 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
237 r = MsiConfigureFeatureW(NULL, NULL, 0);
238 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
240 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", NULL, 0);
241 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
243 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", "foo", 0);
244 ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
246 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", "foo", INSTALLSTATE_DEFAULT);
247 ok( r == ERROR_UNKNOWN_PRODUCT, "wrong error %d\n", r);
249 /* make sure empty string to MsiGetProductInfo is not a handle to default registry value, saving and restoring the
250 * necessary registry values */
252 /* empty product string */
253 r = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", &hkey);
254 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
256 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
257 ok ( r == ERROR_SUCCESS || r == ERROR_FILE_NOT_FOUND, "wrong error %d\n", r);
258 if ( r == ERROR_SUCCESS )
260 lpData = HeapAlloc(GetProcessHeap(), 0, cbData);
261 if (!lpData)
262 skip("Out of memory\n");
263 else
265 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
266 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
270 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
271 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
273 r = MsiGetProductInfoA("", "", NULL, NULL);
274 ok ( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
276 if (lpData)
278 r = RegSetValueExA(hkey, NULL, 0, dwType, lpData, cbData);
279 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
281 HeapFree(GetProcessHeap(), 0, lpData);
283 else
285 r = RegDeleteValueA(hkey, NULL);
286 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
289 r = RegCloseKey(hkey);
290 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
292 /* empty attribute */
293 r = RegCreateKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", &hkey);
294 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
296 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
297 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
299 r = MsiGetProductInfoA("{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", "", NULL, NULL);
300 ok ( r == ERROR_UNKNOWN_PROPERTY, "wrong error %d\n", r);
302 r = RegCloseKey(hkey);
303 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
305 r = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}");
306 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
309 static void test_getcomponentpath(void)
311 INSTALLSTATE r;
312 char buffer[0x100];
313 DWORD sz;
315 if(!pMsiGetComponentPathA)
316 return;
318 r = pMsiGetComponentPathA( NULL, NULL, NULL, NULL );
319 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
321 r = pMsiGetComponentPathA( "bogus", "bogus", NULL, NULL );
322 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
324 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL, NULL );
325 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
327 sz = sizeof buffer;
328 buffer[0]=0;
329 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer, &sz );
330 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
332 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}",
333 "{00000000-0000-0000-0000-000000000000}", buffer, &sz );
334 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
336 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
337 "{00000000-0000-0000-0000-00000000}", buffer, &sz );
338 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
340 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
341 "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer, &sz );
342 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
344 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}",
345 "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer, &sz );
346 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
349 static void create_file(LPCSTR name, LPCSTR data, DWORD size)
351 HANDLE file;
352 DWORD written;
354 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
355 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
356 WriteFile(file, data, strlen(data), &written, NULL);
358 if (size)
360 SetFilePointer(file, size, NULL, FILE_BEGIN);
361 SetEndOfFile(file);
364 CloseHandle(file);
367 #define HASHSIZE sizeof(MSIFILEHASHINFO)
369 static const struct
371 LPCSTR data;
372 DWORD size;
373 MSIFILEHASHINFO hash;
374 } hash_data[] =
376 { "abc", 0,
377 { HASHSIZE,
378 { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 },
382 { "C:\\Program Files\\msitest\\caesar\n", 0,
383 { HASHSIZE,
384 { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 },
388 { "C:\\Program Files\\msitest\\caesar\n", 500,
389 { HASHSIZE,
390 { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 },
395 static void test_MsiGetFileHash(void)
397 const char name[] = "msitest.bin";
398 UINT r;
399 MSIFILEHASHINFO hash;
400 DWORD i;
402 if (!pMsiGetFileHashA)
404 skip("MsiGetFileHash not implemented\n");
405 return;
408 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
410 /* szFilePath is NULL */
411 r = pMsiGetFileHashA(NULL, 0, &hash);
412 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
414 /* szFilePath is empty */
415 r = pMsiGetFileHashA("", 0, &hash);
416 ok(r == ERROR_PATH_NOT_FOUND || r == ERROR_BAD_PATHNAME,
417 "Expected ERROR_PATH_NOT_FOUND or ERROR_BAD_PATHNAME, got %d\n", r);
419 /* szFilePath is nonexistent */
420 r = pMsiGetFileHashA(name, 0, &hash);
421 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
423 /* dwOptions is non-zero */
424 r = pMsiGetFileHashA(name, 1, &hash);
425 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
427 /* pHash.dwFileHashInfoSize is not correct */
428 hash.dwFileHashInfoSize = 0;
429 r = pMsiGetFileHashA(name, 0, &hash);
430 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
432 /* pHash is NULL */
433 r = pMsiGetFileHashA(name, 0, NULL);
434 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
436 for (i = 0; i < sizeof(hash_data) / sizeof(hash_data[0]); i++)
438 create_file(name, hash_data[i].data, hash_data[i].size);
440 memset(&hash, 0, sizeof(MSIFILEHASHINFO));
441 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
443 r = pMsiGetFileHashA(name, 0, &hash);
444 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
445 ok(!memcmp(&hash, &hash_data[i].hash, HASHSIZE), "Hash incorrect\n");
447 DeleteFile(name);
451 /* copied from dlls/msi/registry.c */
452 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
454 DWORD i,n=1;
455 GUID guid;
457 if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
458 return FALSE;
460 for(i=0; i<8; i++)
461 out[7-i] = in[n++];
462 n++;
463 for(i=0; i<4; i++)
464 out[11-i] = in[n++];
465 n++;
466 for(i=0; i<4; i++)
467 out[15-i] = in[n++];
468 n++;
469 for(i=0; i<2; i++)
471 out[17+i*2] = in[n++];
472 out[16+i*2] = in[n++];
474 n++;
475 for( ; i<8; i++)
477 out[17+i*2] = in[n++];
478 out[16+i*2] = in[n++];
480 out[32]=0;
481 return TRUE;
484 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
486 WCHAR guidW[MAX_PATH];
487 WCHAR squashedW[MAX_PATH];
488 GUID guid;
489 HRESULT hr;
490 int size;
492 hr = CoCreateGuid(&guid);
493 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
495 size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
496 ok(size == 39, "Expected 39, got %d\n", hr);
498 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
499 squash_guid(guidW, squashedW);
500 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
503 static void get_user_sid(LPSTR *usersid)
505 HANDLE token;
506 BYTE buf[1024];
507 DWORD size;
508 PTOKEN_USER user;
510 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
511 size = sizeof(buf);
512 GetTokenInformation(token, TokenUser, (void *)buf, size, &size);
513 user = (PTOKEN_USER)buf;
514 pConvertSidToStringSidA(user->User.Sid, usersid);
517 static void test_MsiQueryProductState(void)
519 CHAR prodcode[MAX_PATH];
520 CHAR prod_squashed[MAX_PATH];
521 CHAR keypath[MAX_PATH*2];
522 LPSTR usersid;
523 INSTALLSTATE state;
524 LONG res;
525 HKEY userkey, localkey, props;
526 HKEY prodkey;
527 DWORD data;
529 create_test_guid(prodcode, prod_squashed);
530 get_user_sid(&usersid);
532 /* NULL prodcode */
533 state = MsiQueryProductStateA(NULL);
534 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
536 /* empty prodcode */
537 state = MsiQueryProductStateA("");
538 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
540 /* garbage prodcode */
541 state = MsiQueryProductStateA("garbage");
542 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
544 /* guid without brackets */
545 state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
546 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
548 /* guid with brackets */
549 state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
550 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
552 /* same length as guid, but random */
553 state = MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
554 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
556 /* MSIINSTALLCONTEXT_USERUNMANAGED */
558 state = MsiQueryProductStateA(prodcode);
559 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
561 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
562 lstrcatA(keypath, prod_squashed);
564 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
565 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
567 /* user product key exists */
568 state = MsiQueryProductStateA(prodcode);
569 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
571 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
572 lstrcatA(keypath, prodcode);
574 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
575 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
577 /* local uninstall key exists */
578 state = MsiQueryProductStateA(prodcode);
579 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
581 data = 1;
582 res = RegSetValueExA(localkey, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
583 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
585 /* WindowsInstaller value exists */
586 state = MsiQueryProductStateA(prodcode);
587 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
589 RegDeleteValueA(localkey, "WindowsInstaller");
590 RegDeleteKeyA(localkey, "");
592 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
593 lstrcatA(keypath, usersid);
594 lstrcatA(keypath, "\\Products\\");
595 lstrcatA(keypath, prod_squashed);
597 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
598 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
600 /* local product key exists */
601 state = MsiQueryProductStateA(prodcode);
602 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
604 res = RegCreateKeyA(localkey, "InstallProperties", &props);
605 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
607 /* install properties key exists */
608 state = MsiQueryProductStateA(prodcode);
609 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
611 data = 1;
612 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
613 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
615 /* WindowsInstaller value exists */
616 state = MsiQueryProductStateA(prodcode);
617 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
619 data = 2;
620 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
621 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
623 /* WindowsInstaller value is not 1 */
624 state = MsiQueryProductStateA(prodcode);
625 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
627 RegDeleteKeyA(userkey, "");
629 /* user product key does not exist */
630 state = MsiQueryProductStateA(prodcode);
631 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
633 RegDeleteValueA(props, "WindowsInstaller");
634 RegDeleteKeyA(props, "");
635 RegCloseKey(props);
636 RegDeleteKeyA(localkey, "");
637 RegCloseKey(localkey);
638 RegDeleteKeyA(userkey, "");
639 RegCloseKey(userkey);
641 /* MSIINSTALLCONTEXT_USERMANAGED */
643 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
644 lstrcatA(keypath, usersid);
645 lstrcatA(keypath, "\\Installer\\Products\\");
646 lstrcatA(keypath, prod_squashed);
648 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
649 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
651 state = MsiQueryProductStateA(prodcode);
652 ok(state == INSTALLSTATE_ADVERTISED,
653 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
655 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
656 lstrcatA(keypath, usersid);
657 lstrcatA(keypath, "\\Products\\");
658 lstrcatA(keypath, prod_squashed);
660 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
661 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
663 state = MsiQueryProductStateA(prodcode);
664 ok(state == INSTALLSTATE_ADVERTISED,
665 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
667 res = RegCreateKeyA(localkey, "InstallProperties", &props);
668 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
670 state = MsiQueryProductStateA(prodcode);
671 ok(state == INSTALLSTATE_ADVERTISED,
672 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
674 data = 1;
675 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
676 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
678 /* WindowsInstaller value exists */
679 state = MsiQueryProductStateA(prodcode);
680 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
682 RegDeleteValueA(props, "WindowsInstaller");
683 RegDeleteKeyA(props, "");
684 RegCloseKey(props);
685 RegDeleteKeyA(localkey, "");
686 RegCloseKey(localkey);
687 RegDeleteKeyA(prodkey, "");
688 RegCloseKey(prodkey);
690 /* MSIINSTALLCONTEXT_MACHINE */
692 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
693 lstrcatA(keypath, prod_squashed);
695 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
696 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
698 state = MsiQueryProductStateA(prodcode);
699 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
701 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
702 lstrcatA(keypath, "S-1-5-18\\Products\\");
703 lstrcatA(keypath, prod_squashed);
705 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
706 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
708 state = MsiQueryProductStateA(prodcode);
709 ok(state == INSTALLSTATE_ADVERTISED,
710 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
712 res = RegCreateKeyA(localkey, "InstallProperties", &props);
713 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
715 state = MsiQueryProductStateA(prodcode);
716 ok(state == INSTALLSTATE_ADVERTISED,
717 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
719 data = 1;
720 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
721 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
723 /* WindowsInstaller value exists */
724 state = MsiQueryProductStateA(prodcode);
725 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
727 RegDeleteValueA(props, "WindowsInstaller");
728 RegDeleteKeyA(props, "");
729 RegCloseKey(props);
730 RegDeleteKeyA(localkey, "");
731 RegCloseKey(localkey);
732 RegDeleteKeyA(prodkey, "");
733 RegCloseKey(prodkey);
735 LocalFree(usersid);
738 static const char table_enc85[] =
739 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
740 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
741 "yz{}~";
744 * Encodes a base85 guid given a GUID pointer
745 * Caller should provide a 21 character buffer for the encoded string.
747 * returns TRUE if successful, FALSE if not
749 static BOOL encode_base85_guid( GUID *guid, LPWSTR str )
751 unsigned int x, *p, i;
753 p = (unsigned int*) guid;
754 for( i=0; i<4; i++ )
756 x = p[i];
757 *str++ = table_enc85[x%85];
758 x = x/85;
759 *str++ = table_enc85[x%85];
760 x = x/85;
761 *str++ = table_enc85[x%85];
762 x = x/85;
763 *str++ = table_enc85[x%85];
764 x = x/85;
765 *str++ = table_enc85[x%85];
767 *str = 0;
769 return TRUE;
772 static void compose_base85_guid(LPSTR component, LPSTR comp_base85, LPSTR squashed)
774 WCHAR guidW[MAX_PATH];
775 WCHAR base85W[MAX_PATH];
776 WCHAR squashedW[MAX_PATH];
777 GUID guid;
778 HRESULT hr;
779 int size;
781 hr = CoCreateGuid(&guid);
782 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
784 size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
785 ok(size == 39, "Expected 39, got %d\n", hr);
787 WideCharToMultiByte(CP_ACP, 0, guidW, size, component, MAX_PATH, NULL, NULL);
788 encode_base85_guid(&guid, base85W);
789 WideCharToMultiByte(CP_ACP, 0, base85W, -1, comp_base85, MAX_PATH, NULL, NULL);
790 squash_guid(guidW, squashedW);
791 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
794 static void test_MsiQueryFeatureState(void)
796 HKEY userkey, localkey, compkey;
797 CHAR prodcode[MAX_PATH];
798 CHAR prod_squashed[MAX_PATH];
799 CHAR component[MAX_PATH];
800 CHAR comp_base85[MAX_PATH];
801 CHAR comp_squashed[MAX_PATH];
802 CHAR keypath[MAX_PATH*2];
803 INSTALLSTATE state;
804 LPSTR usersid;
805 LONG res;
807 create_test_guid(prodcode, prod_squashed);
808 compose_base85_guid(component, comp_base85, comp_squashed);
809 get_user_sid(&usersid);
811 /* NULL prodcode */
812 state = MsiQueryFeatureStateA(NULL, "feature");
813 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
815 /* empty prodcode */
816 state = MsiQueryFeatureStateA("", "feature");
817 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
819 /* garbage prodcode */
820 state = MsiQueryFeatureStateA("garbage", "feature");
821 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
823 /* guid without brackets */
824 state = MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
825 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
827 /* guid with brackets */
828 state = MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
829 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
831 /* same length as guid, but random */
832 state = MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
833 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
835 /* NULL szFeature */
836 state = MsiQueryFeatureStateA(prodcode, NULL);
837 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
839 /* empty szFeature */
840 state = MsiQueryFeatureStateA(prodcode, "");
841 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
843 /* feature key does not exist yet */
844 state = MsiQueryFeatureStateA(prodcode, "feature");
845 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
847 /* MSIINSTALLCONTEXT_USERUNMANAGED */
849 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Features\\");
850 lstrcatA(keypath, prod_squashed);
852 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
853 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
855 /* feature key exists */
856 state = MsiQueryFeatureStateA(prodcode, "feature");
857 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
859 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
860 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
862 /* feature value exists */
863 state = MsiQueryFeatureStateA(prodcode, "feature");
864 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
866 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
867 lstrcatA(keypath, usersid);
868 lstrcatA(keypath, "\\Products\\");
869 lstrcatA(keypath, prod_squashed);
870 lstrcatA(keypath, "\\Features");
872 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
873 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
875 /* userdata features key exists */
876 state = MsiQueryFeatureStateA(prodcode, "feature");
877 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
879 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
880 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
882 state = MsiQueryFeatureStateA(prodcode, "feature");
883 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
885 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
886 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
888 state = MsiQueryFeatureStateA(prodcode, "feature");
889 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
891 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
892 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
894 state = MsiQueryFeatureStateA(prodcode, "feature");
895 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
897 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
898 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
900 state = MsiQueryFeatureStateA(prodcode, "feature");
901 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
903 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
904 lstrcatA(keypath, usersid);
905 lstrcatA(keypath, "\\Components\\");
906 lstrcatA(keypath, comp_squashed);
908 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
909 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
911 state = MsiQueryFeatureStateA(prodcode, "feature");
912 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
914 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
915 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
917 state = MsiQueryFeatureStateA(prodcode, "feature");
918 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
920 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
921 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
923 state = MsiQueryFeatureStateA(prodcode, "feature");
924 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
926 RegDeleteValueA(compkey, prod_squashed);
927 RegDeleteKeyA(compkey, "");
928 RegDeleteValueA(localkey, "feature");
929 RegDeleteValueA(userkey, "feature");
930 RegDeleteKeyA(userkey, "");
931 RegCloseKey(compkey);
932 RegCloseKey(localkey);
933 RegCloseKey(userkey);
935 /* MSIINSTALLCONTEXT_USERMANAGED */
937 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
938 lstrcatA(keypath, usersid);
939 lstrcatA(keypath, "\\Installer\\Features\\");
940 lstrcatA(keypath, prod_squashed);
942 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
943 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
945 /* feature key exists */
946 state = MsiQueryFeatureStateA(prodcode, "feature");
947 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
949 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
950 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
952 /* feature value exists */
953 state = MsiQueryFeatureStateA(prodcode, "feature");
954 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
956 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
957 lstrcatA(keypath, usersid);
958 lstrcatA(keypath, "\\Products\\");
959 lstrcatA(keypath, prod_squashed);
960 lstrcatA(keypath, "\\Features");
962 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
963 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
965 /* userdata features key exists */
966 state = MsiQueryFeatureStateA(prodcode, "feature");
967 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
969 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
970 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
972 state = MsiQueryFeatureStateA(prodcode, "feature");
973 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
975 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
976 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
978 state = MsiQueryFeatureStateA(prodcode, "feature");
979 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
981 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
982 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
984 state = MsiQueryFeatureStateA(prodcode, "feature");
985 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
987 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
988 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
990 state = MsiQueryFeatureStateA(prodcode, "feature");
991 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
993 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
994 lstrcatA(keypath, usersid);
995 lstrcatA(keypath, "\\Components\\");
996 lstrcatA(keypath, comp_squashed);
998 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
999 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1001 state = MsiQueryFeatureStateA(prodcode, "feature");
1002 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1004 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
1005 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1007 state = MsiQueryFeatureStateA(prodcode, "feature");
1008 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1010 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
1011 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1013 state = MsiQueryFeatureStateA(prodcode, "feature");
1014 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1016 RegDeleteValueA(compkey, prod_squashed);
1017 RegDeleteKeyA(compkey, "");
1018 RegDeleteValueA(localkey, "feature");
1019 RegDeleteValueA(userkey, "feature");
1020 RegDeleteKeyA(userkey, "");
1021 RegCloseKey(compkey);
1022 RegCloseKey(localkey);
1023 RegCloseKey(userkey);
1025 /* MSIINSTALLCONTEXT_MACHINE */
1027 lstrcpyA(keypath, "Software\\Classes\\Installer\\Features\\");
1028 lstrcatA(keypath, prod_squashed);
1030 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
1031 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1033 /* feature key exists */
1034 state = MsiQueryFeatureStateA(prodcode, "feature");
1035 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1037 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
1038 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1040 /* feature value exists */
1041 state = MsiQueryFeatureStateA(prodcode, "feature");
1042 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1044 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1045 lstrcatA(keypath, "S-1-5-18\\Products\\");
1046 lstrcatA(keypath, prod_squashed);
1047 lstrcatA(keypath, "\\Features");
1049 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
1050 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1052 /* userdata features key exists */
1053 state = MsiQueryFeatureStateA(prodcode, "feature");
1054 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1056 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
1057 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1059 state = MsiQueryFeatureStateA(prodcode, "feature");
1060 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
1062 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
1063 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1065 state = MsiQueryFeatureStateA(prodcode, "feature");
1066 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1068 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
1069 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1071 state = MsiQueryFeatureStateA(prodcode, "feature");
1072 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1074 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
1075 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1077 state = MsiQueryFeatureStateA(prodcode, "feature");
1078 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1080 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1081 lstrcatA(keypath, "S-1-5-18\\Components\\");
1082 lstrcatA(keypath, comp_squashed);
1084 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1085 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1087 state = MsiQueryFeatureStateA(prodcode, "feature");
1088 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1090 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
1091 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1093 state = MsiQueryFeatureStateA(prodcode, "feature");
1094 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1096 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
1097 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1099 state = MsiQueryFeatureStateA(prodcode, "feature");
1100 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1102 RegDeleteValueA(compkey, prod_squashed);
1103 RegDeleteKeyA(compkey, "");
1104 RegDeleteValueA(localkey, "feature");
1105 RegDeleteValueA(userkey, "feature");
1106 RegDeleteKeyA(userkey, "");
1107 RegCloseKey(compkey);
1108 RegCloseKey(localkey);
1109 RegCloseKey(userkey);
1112 static void test_MsiQueryComponentState(void)
1114 HKEY compkey, prodkey;
1115 CHAR prodcode[MAX_PATH];
1116 CHAR prod_squashed[MAX_PATH];
1117 CHAR component[MAX_PATH];
1118 CHAR comp_base85[MAX_PATH];
1119 CHAR comp_squashed[MAX_PATH];
1120 CHAR keypath[MAX_PATH];
1121 INSTALLSTATE state;
1122 LPSTR usersid;
1123 LONG res;
1124 UINT r;
1126 static const INSTALLSTATE MAGIC_ERROR = 0xdeadbeef;
1128 if (!pMsiQueryComponentStateA)
1130 skip("MsiQueryComponentStateA not implemented\n");
1131 return;
1134 create_test_guid(prodcode, prod_squashed);
1135 compose_base85_guid(component, comp_base85, comp_squashed);
1136 get_user_sid(&usersid);
1138 /* NULL szProductCode */
1139 state = MAGIC_ERROR;
1140 r = pMsiQueryComponentStateA(NULL, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1141 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1142 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1144 /* empty szProductCode */
1145 state = MAGIC_ERROR;
1146 r = pMsiQueryComponentStateA("", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1147 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1148 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1150 /* random szProductCode */
1151 state = MAGIC_ERROR;
1152 r = pMsiQueryComponentStateA("random", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1153 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1154 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1156 /* GUID-length szProductCode */
1157 state = MAGIC_ERROR;
1158 r = pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1159 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1160 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1162 /* GUID-length with brackets */
1163 state = MAGIC_ERROR;
1164 r = pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1165 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1166 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1168 /* actual GUID */
1169 state = MAGIC_ERROR;
1170 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1171 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1172 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1174 state = MAGIC_ERROR;
1175 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1176 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1177 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1179 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1180 lstrcatA(keypath, prod_squashed);
1182 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1183 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1185 state = MAGIC_ERROR;
1186 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1187 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1188 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1190 RegDeleteKeyA(prodkey, "");
1191 RegCloseKey(prodkey);
1193 /* create local system product key */
1194 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
1195 lstrcatA(keypath, prod_squashed);
1196 lstrcatA(keypath, "\\InstallProperties");
1198 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1199 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1201 /* local system product key exists */
1202 state = MAGIC_ERROR;
1203 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1204 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1205 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1207 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1208 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1210 /* LocalPackage value exists */
1211 state = MAGIC_ERROR;
1212 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1213 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1214 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1216 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
1217 lstrcatA(keypath, comp_squashed);
1219 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1220 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1222 /* component key exists */
1223 state = MAGIC_ERROR;
1224 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1225 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1226 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1228 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
1229 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1231 /* component\product exists */
1232 state = MAGIC_ERROR;
1233 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1234 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1235 ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
1237 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
1238 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1240 /* INSTALLSTATE_LOCAL */
1241 state = MAGIC_ERROR;
1242 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1244 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1246 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
1247 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1249 /* INSTALLSTATE_SOURCE */
1250 state = MAGIC_ERROR;
1251 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1252 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1253 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
1255 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
1256 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1258 /* bad INSTALLSTATE_SOURCE */
1259 state = MAGIC_ERROR;
1260 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1261 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1262 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1264 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
1265 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1267 /* INSTALLSTATE_SOURCE */
1268 state = MAGIC_ERROR;
1269 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1270 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1271 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
1273 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
1274 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1276 /* bad INSTALLSTATE_SOURCE */
1277 state = MAGIC_ERROR;
1278 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1280 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1282 RegDeleteValueA(prodkey, "LocalPackage");
1283 RegDeleteKeyA(prodkey, "");
1284 RegDeleteValueA(compkey, prod_squashed);
1285 RegDeleteKeyA(prodkey, "");
1286 RegCloseKey(prodkey);
1287 RegCloseKey(compkey);
1289 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1291 state = MAGIC_ERROR;
1292 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1293 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1294 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1296 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1297 lstrcatA(keypath, prod_squashed);
1299 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1300 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1302 state = MAGIC_ERROR;
1303 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1304 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1305 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1307 RegDeleteKeyA(prodkey, "");
1308 RegCloseKey(prodkey);
1310 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1311 lstrcatA(keypath, usersid);
1312 lstrcatA(keypath, "\\Products\\");
1313 lstrcatA(keypath, prod_squashed);
1314 lstrcatA(keypath, "\\InstallProperties");
1316 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1317 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1319 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1320 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1322 RegCloseKey(prodkey);
1324 state = MAGIC_ERROR;
1325 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1326 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1327 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1329 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1330 lstrcatA(keypath, usersid);
1331 lstrcatA(keypath, "\\Components\\");
1332 lstrcatA(keypath, comp_squashed);
1334 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1335 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1337 /* component key exists */
1338 state = MAGIC_ERROR;
1339 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1340 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1341 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1343 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
1344 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1346 /* component\product exists */
1347 state = MAGIC_ERROR;
1348 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1349 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1350 ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
1352 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
1353 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1355 state = MAGIC_ERROR;
1356 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1357 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1358 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1360 /* MSIINSTALLCONTEXT_USERMANAGED */
1362 state = MAGIC_ERROR;
1363 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1364 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1365 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1367 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1368 lstrcatA(keypath, prod_squashed);
1370 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1371 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1373 state = MAGIC_ERROR;
1374 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1375 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1376 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1378 RegDeleteKeyA(prodkey, "");
1379 RegCloseKey(prodkey);
1381 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1382 lstrcatA(keypath, usersid);
1383 lstrcatA(keypath, "\\Installer\\Products\\");
1384 lstrcatA(keypath, prod_squashed);
1386 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1387 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1389 state = MAGIC_ERROR;
1390 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1391 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1392 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1394 RegDeleteKeyA(prodkey, "");
1395 RegCloseKey(prodkey);
1397 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1398 lstrcatA(keypath, usersid);
1399 lstrcatA(keypath, "\\Products\\");
1400 lstrcatA(keypath, prod_squashed);
1401 lstrcatA(keypath, "\\InstallProperties");
1403 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1404 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1406 res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1407 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1409 state = MAGIC_ERROR;
1410 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1412 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1414 RegDeleteValueA(prodkey, "LocalPackage");
1415 RegDeleteValueA(prodkey, "ManagedLocalPackage");
1416 RegDeleteKeyA(prodkey, "");
1417 RegDeleteValueA(compkey, prod_squashed);
1418 RegDeleteKeyA(compkey, "");
1419 RegCloseKey(prodkey);
1420 RegCloseKey(compkey);
1423 static void test_MsiGetComponentPath(void)
1425 HKEY compkey, prodkey, installprop;
1426 CHAR prodcode[MAX_PATH];
1427 CHAR prod_squashed[MAX_PATH];
1428 CHAR component[MAX_PATH];
1429 CHAR comp_base85[MAX_PATH];
1430 CHAR comp_squashed[MAX_PATH];
1431 CHAR keypath[MAX_PATH];
1432 CHAR path[MAX_PATH];
1433 INSTALLSTATE state;
1434 LPSTR usersid;
1435 DWORD size, val;
1436 LONG res;
1438 create_test_guid(prodcode, prod_squashed);
1439 compose_base85_guid(component, comp_base85, comp_squashed);
1440 get_user_sid(&usersid);
1442 /* NULL szProduct */
1443 size = MAX_PATH;
1444 state = MsiGetComponentPathA(NULL, component, path, &size);
1445 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1446 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1448 /* NULL szComponent */
1449 size = MAX_PATH;
1450 state = MsiGetComponentPathA(prodcode, NULL, path, &size);
1451 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1452 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1454 /* NULL lpPathBuf */
1455 size = MAX_PATH;
1456 state = MsiGetComponentPathA(prodcode, component, NULL, &size);
1457 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1458 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1460 /* NULL pcchBuf */
1461 size = MAX_PATH;
1462 state = MsiGetComponentPathA(prodcode, component, path, NULL);
1463 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1464 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1466 /* all params valid */
1467 size = MAX_PATH;
1468 state = MsiGetComponentPathA(prodcode, component, path, &size);
1469 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1470 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1472 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1473 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1474 lstrcatA(keypath, comp_squashed);
1476 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1479 /* local system component key exists */
1480 size = MAX_PATH;
1481 state = MsiGetComponentPathA(prodcode, component, path, &size);
1482 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1483 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1485 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1486 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1488 /* product value exists */
1489 size = MAX_PATH;
1490 state = MsiGetComponentPathA(prodcode, component, path, &size);
1491 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1492 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1493 ok(size == 10, "Expected 10, got %d\n", size);
1495 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1496 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1497 lstrcatA(keypath, prod_squashed);
1498 lstrcatA(keypath, "\\InstallProperties");
1500 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1501 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1503 val = 1;
1504 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1505 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1507 /* install properties key exists */
1508 size = MAX_PATH;
1509 state = MsiGetComponentPathA(prodcode, component, path, &size);
1510 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1511 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1512 ok(size == 10, "Expected 10, got %d\n", size);
1514 create_file("C:\\imapath", "C:\\imapath", 11);
1516 /* file exists */
1517 size = MAX_PATH;
1518 state = MsiGetComponentPathA(prodcode, component, path, &size);
1519 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1520 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1521 ok(size == 10, "Expected 10, got %d\n", size);
1523 RegDeleteValueA(compkey, prod_squashed);
1524 RegDeleteKeyA(compkey, "");
1525 RegDeleteValueA(installprop, "WindowsInstaller");
1526 RegDeleteKeyA(installprop, "");
1527 RegCloseKey(compkey);
1528 RegCloseKey(installprop);
1529 DeleteFileA("C:\\imapath");
1531 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1532 lstrcatA(keypath, "Installer\\UserData\\");
1533 lstrcatA(keypath, usersid);
1534 lstrcatA(keypath, "\\Components\\");
1535 lstrcatA(keypath, comp_squashed);
1537 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1538 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1540 /* user managed component key exists */
1541 size = MAX_PATH;
1542 state = MsiGetComponentPathA(prodcode, component, path, &size);
1543 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1544 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1546 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1547 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1549 /* product value exists */
1550 size = MAX_PATH;
1551 state = MsiGetComponentPathA(prodcode, component, path, &size);
1552 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1553 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1554 ok(size == 10, "Expected 10, got %d\n", size);
1556 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1557 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1558 lstrcatA(keypath, prod_squashed);
1559 lstrcatA(keypath, "\\InstallProperties");
1561 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1562 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1564 val = 1;
1565 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1566 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1568 /* install properties key exists */
1569 size = MAX_PATH;
1570 state = MsiGetComponentPathA(prodcode, component, path, &size);
1571 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1572 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1573 ok(size == 10, "Expected 10, got %d\n", size);
1575 create_file("C:\\imapath", "C:\\imapath", 11);
1577 /* file exists */
1578 size = MAX_PATH;
1579 state = MsiGetComponentPathA(prodcode, component, path, &size);
1580 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1581 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1582 ok(size == 10, "Expected 10, got %d\n", size);
1584 RegDeleteValueA(compkey, prod_squashed);
1585 RegDeleteKeyA(compkey, "");
1586 RegDeleteValueA(installprop, "WindowsInstaller");
1587 RegDeleteKeyA(installprop, "");
1588 RegCloseKey(compkey);
1589 RegCloseKey(installprop);
1590 DeleteFileA("C:\\imapath");
1592 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1593 lstrcatA(keypath, "Installer\\Managed\\");
1594 lstrcatA(keypath, usersid);
1595 lstrcatA(keypath, "\\Installer\\Products\\");
1596 lstrcatA(keypath, prod_squashed);
1598 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1599 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1601 /* user managed product key exists */
1602 size = MAX_PATH;
1603 state = MsiGetComponentPathA(prodcode, component, path, &size);
1604 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1605 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1607 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1608 lstrcatA(keypath, "Installer\\UserData\\");
1609 lstrcatA(keypath, usersid);
1610 lstrcatA(keypath, "\\Components\\");
1611 lstrcatA(keypath, comp_squashed);
1613 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1614 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1616 /* user managed component key exists */
1617 size = MAX_PATH;
1618 state = MsiGetComponentPathA(prodcode, component, path, &size);
1619 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1620 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1622 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1623 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1625 /* product value exists */
1626 size = MAX_PATH;
1627 state = MsiGetComponentPathA(prodcode, component, path, &size);
1628 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1629 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1630 ok(size == 10, "Expected 10, got %d\n", size);
1632 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1633 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1634 lstrcatA(keypath, prod_squashed);
1635 lstrcatA(keypath, "\\InstallProperties");
1637 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1638 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1640 val = 1;
1641 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1642 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1644 /* install properties key exists */
1645 size = MAX_PATH;
1646 state = MsiGetComponentPathA(prodcode, component, path, &size);
1647 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1648 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1649 ok(size == 10, "Expected 10, got %d\n", size);
1651 create_file("C:\\imapath", "C:\\imapath", 11);
1653 /* file exists */
1654 size = MAX_PATH;
1655 state = MsiGetComponentPathA(prodcode, component, path, &size);
1656 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1657 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1658 ok(size == 10, "Expected 10, got %d\n", size);
1660 RegDeleteValueA(compkey, prod_squashed);
1661 RegDeleteKeyA(prodkey, "");
1662 RegDeleteKeyA(compkey, "");
1663 RegDeleteValueA(installprop, "WindowsInstaller");
1664 RegDeleteKeyA(installprop, "");
1665 RegCloseKey(prodkey);
1666 RegCloseKey(compkey);
1667 RegCloseKey(installprop);
1668 DeleteFileA("C:\\imapath");
1670 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1671 lstrcatA(keypath, prod_squashed);
1673 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1674 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1676 /* user unmanaged product key exists */
1677 size = MAX_PATH;
1678 state = MsiGetComponentPathA(prodcode, component, path, &size);
1679 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1680 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1682 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1683 lstrcatA(keypath, "Installer\\UserData\\");
1684 lstrcatA(keypath, usersid);
1685 lstrcatA(keypath, "\\Components\\");
1686 lstrcatA(keypath, comp_squashed);
1688 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1689 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1691 /* user unmanaged component key exists */
1692 size = MAX_PATH;
1693 state = MsiGetComponentPathA(prodcode, component, path, &size);
1694 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1695 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1697 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1698 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1700 /* product value exists */
1701 size = MAX_PATH;
1702 state = MsiGetComponentPathA(prodcode, component, path, &size);
1703 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1704 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1705 ok(size == 10, "Expected 10, got %d\n", size);
1707 create_file("C:\\imapath", "C:\\imapath", 11);
1709 /* file exists */
1710 size = MAX_PATH;
1711 state = MsiGetComponentPathA(prodcode, component, path, &size);
1712 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1713 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1714 ok(size == 10, "Expected 10, got %d\n", size);
1716 RegDeleteValueA(compkey, prod_squashed);
1717 RegDeleteKeyA(prodkey, "");
1718 RegDeleteKeyA(compkey, "");
1719 RegCloseKey(prodkey);
1720 RegCloseKey(compkey);
1721 RegCloseKey(installprop);
1722 DeleteFileA("C:\\imapath");
1724 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1725 lstrcatA(keypath, prod_squashed);
1727 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1728 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1730 /* local classes product key exists */
1731 size = MAX_PATH;
1732 state = MsiGetComponentPathA(prodcode, component, path, &size);
1733 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1734 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1736 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1737 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1738 lstrcatA(keypath, comp_squashed);
1740 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1741 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1743 /* local user component key exists */
1744 size = MAX_PATH;
1745 state = MsiGetComponentPathA(prodcode, component, path, &size);
1746 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1747 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1749 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1750 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1752 /* product value exists */
1753 size = MAX_PATH;
1754 state = MsiGetComponentPathA(prodcode, component, path, &size);
1755 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1756 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1757 ok(size == 10, "Expected 10, got %d\n", size);
1759 create_file("C:\\imapath", "C:\\imapath", 11);
1761 /* file exists */
1762 size = MAX_PATH;
1763 state = MsiGetComponentPathA(prodcode, component, path, &size);
1764 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1765 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1766 ok(size == 10, "Expected 10, got %d\n", size);
1768 RegDeleteValueA(compkey, prod_squashed);
1769 RegDeleteKeyA(prodkey, "");
1770 RegDeleteKeyA(compkey, "");
1771 RegCloseKey(prodkey);
1772 RegCloseKey(compkey);
1773 DeleteFileA("C:\\imapath");
1776 static void test_MsiGetProductCode(void)
1778 HKEY compkey, prodkey;
1779 CHAR prodcode[MAX_PATH];
1780 CHAR prod_squashed[MAX_PATH];
1781 CHAR prodcode2[MAX_PATH];
1782 CHAR prod2_squashed[MAX_PATH];
1783 CHAR component[MAX_PATH];
1784 CHAR comp_base85[MAX_PATH];
1785 CHAR comp_squashed[MAX_PATH];
1786 CHAR keypath[MAX_PATH];
1787 CHAR product[MAX_PATH];
1788 LPSTR usersid;
1789 LONG res;
1790 UINT r;
1792 create_test_guid(prodcode, prod_squashed);
1793 create_test_guid(prodcode2, prod2_squashed);
1794 compose_base85_guid(component, comp_base85, comp_squashed);
1795 get_user_sid(&usersid);
1797 /* szComponent is NULL */
1798 lstrcpyA(product, "prod");
1799 r = MsiGetProductCodeA(NULL, product);
1800 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1801 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1803 /* szComponent is empty */
1804 lstrcpyA(product, "prod");
1805 r = MsiGetProductCodeA("", product);
1806 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1807 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1809 /* garbage szComponent */
1810 lstrcpyA(product, "prod");
1811 r = MsiGetProductCodeA("garbage", product);
1812 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1813 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1815 /* guid without brackets */
1816 lstrcpyA(product, "prod");
1817 r = MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product);
1818 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1819 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1821 /* guid with brackets */
1822 lstrcpyA(product, "prod");
1823 r = MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product);
1824 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1825 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1827 /* same length as guid, but random */
1828 lstrcpyA(product, "prod");
1829 r = MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product);
1830 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1831 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1833 /* all params correct, szComponent not published */
1834 lstrcpyA(product, "prod");
1835 r = MsiGetProductCodeA(component, product);
1836 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1837 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1839 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1840 lstrcatA(keypath, "Installer\\UserData\\");
1841 lstrcatA(keypath, usersid);
1842 lstrcatA(keypath, "\\Components\\");
1843 lstrcatA(keypath, comp_squashed);
1845 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1846 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1848 /* user unmanaged component key exists */
1849 lstrcpyA(product, "prod");
1850 r = MsiGetProductCodeA(component, product);
1851 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1852 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1854 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1855 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1857 /* product value exists */
1858 lstrcpyA(product, "prod");
1859 r = MsiGetProductCodeA(component, product);
1860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1861 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1863 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1864 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1866 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1867 lstrcatA(keypath, "Installer\\Managed\\");
1868 lstrcatA(keypath, usersid);
1869 lstrcatA(keypath, "\\Installer\\Products\\");
1870 lstrcatA(keypath, prod_squashed);
1872 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1873 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1875 /* user managed product key of first product exists */
1876 lstrcpyA(product, "prod");
1877 r = MsiGetProductCodeA(component, product);
1878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1879 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1881 RegDeleteKeyA(prodkey, "");
1882 RegCloseKey(prodkey);
1884 RegDeleteKeyA(prodkey, "");
1885 RegCloseKey(prodkey);
1887 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1888 lstrcatA(keypath, prod_squashed);
1890 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1891 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1893 /* user unmanaged product key exists */
1894 lstrcpyA(product, "prod");
1895 r = MsiGetProductCodeA(component, product);
1896 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1897 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1899 RegDeleteKeyA(prodkey, "");
1900 RegCloseKey(prodkey);
1902 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1903 lstrcatA(keypath, prod_squashed);
1905 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1906 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1908 /* local classes product key exists */
1909 lstrcpyA(product, "prod");
1910 r = MsiGetProductCodeA(component, product);
1911 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1912 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1914 RegDeleteKeyA(prodkey, "");
1915 RegCloseKey(prodkey);
1917 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1918 lstrcatA(keypath, "Installer\\Managed\\");
1919 lstrcatA(keypath, usersid);
1920 lstrcatA(keypath, "\\Installer\\Products\\");
1921 lstrcatA(keypath, prod2_squashed);
1923 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1924 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1926 /* user managed product key of second product exists */
1927 lstrcpyA(product, "prod");
1928 r = MsiGetProductCodeA(component, product);
1929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1930 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
1932 RegDeleteKeyA(prodkey, "");
1933 RegCloseKey(prodkey);
1934 RegDeleteValueA(compkey, prod_squashed);
1935 RegDeleteValueA(compkey, prod2_squashed);
1936 RegDeleteKeyA(compkey, "");
1937 RegCloseKey(compkey);
1939 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1940 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1941 lstrcatA(keypath, comp_squashed);
1943 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1944 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1946 /* local user component key exists */
1947 lstrcpyA(product, "prod");
1948 r = MsiGetProductCodeA(component, product);
1949 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1950 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1952 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1953 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1955 /* product value exists */
1956 lstrcpyA(product, "prod");
1957 r = MsiGetProductCodeA(component, product);
1958 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1959 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1961 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1962 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1964 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1965 lstrcatA(keypath, "Installer\\Managed\\");
1966 lstrcatA(keypath, usersid);
1967 lstrcatA(keypath, "\\Installer\\Products\\");
1968 lstrcatA(keypath, prod_squashed);
1970 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1971 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1973 /* user managed product key of first product exists */
1974 lstrcpyA(product, "prod");
1975 r = MsiGetProductCodeA(component, product);
1976 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1977 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1979 RegDeleteKeyA(prodkey, "");
1980 RegCloseKey(prodkey);
1982 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1983 lstrcatA(keypath, prod_squashed);
1985 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1986 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1988 /* user unmanaged product key exists */
1989 lstrcpyA(product, "prod");
1990 r = MsiGetProductCodeA(component, product);
1991 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1992 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1994 RegDeleteKeyA(prodkey, "");
1995 RegCloseKey(prodkey);
1997 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1998 lstrcatA(keypath, prod_squashed);
2000 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2001 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2003 /* local classes product key exists */
2004 lstrcpyA(product, "prod");
2005 r = MsiGetProductCodeA(component, product);
2006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2007 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2009 RegDeleteKeyA(prodkey, "");
2010 RegCloseKey(prodkey);
2012 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2013 lstrcatA(keypath, "Installer\\Managed\\");
2014 lstrcatA(keypath, usersid);
2015 lstrcatA(keypath, "\\Installer\\Products\\");
2016 lstrcatA(keypath, prod2_squashed);
2018 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2019 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2021 /* user managed product key of second product exists */
2022 lstrcpyA(product, "prod");
2023 r = MsiGetProductCodeA(component, product);
2024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2025 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
2027 RegDeleteKeyA(prodkey, "");
2028 RegCloseKey(prodkey);
2029 RegDeleteValueA(compkey, prod_squashed);
2030 RegDeleteValueA(compkey, prod2_squashed);
2031 RegDeleteKeyA(compkey, "");
2032 RegCloseKey(compkey);
2035 static void test_MsiEnumClients(void)
2037 HKEY compkey;
2038 CHAR prodcode[MAX_PATH];
2039 CHAR prod_squashed[MAX_PATH];
2040 CHAR prodcode2[MAX_PATH];
2041 CHAR prod2_squashed[MAX_PATH];
2042 CHAR component[MAX_PATH];
2043 CHAR comp_base85[MAX_PATH];
2044 CHAR comp_squashed[MAX_PATH];
2045 CHAR product[MAX_PATH];
2046 CHAR keypath[MAX_PATH];
2047 LPSTR usersid;
2048 LONG res;
2049 UINT r;
2051 create_test_guid(prodcode, prod_squashed);
2052 create_test_guid(prodcode2, prod2_squashed);
2053 compose_base85_guid(component, comp_base85, comp_squashed);
2054 get_user_sid(&usersid);
2056 /* NULL szComponent */
2057 product[0] = '\0';
2058 r = MsiEnumClientsA(NULL, 0, product);
2059 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2060 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2062 /* empty szComponent */
2063 product[0] = '\0';
2064 r = MsiEnumClientsA("", 0, product);
2065 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2066 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2068 /* NULL lpProductBuf */
2069 r = MsiEnumClientsA(component, 0, NULL);
2070 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2072 /* all params correct, component missing */
2073 product[0] = '\0';
2074 r = MsiEnumClientsA(component, 0, product);
2075 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2076 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2078 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2079 lstrcatA(keypath, "Installer\\UserData\\");
2080 lstrcatA(keypath, usersid);
2081 lstrcatA(keypath, "\\Components\\");
2082 lstrcatA(keypath, comp_squashed);
2084 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
2085 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2087 /* user unmanaged component key exists */
2088 product[0] = '\0';
2089 r = MsiEnumClientsA(component, 0, product);
2090 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2091 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2093 /* index > 0, no products exist */
2094 product[0] = '\0';
2095 r = MsiEnumClientsA(component, 1, product);
2096 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2097 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2099 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2100 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2102 /* product value exists */
2103 r = MsiEnumClientsA(component, 0, product);
2104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2105 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2107 /* try index 0 again */
2108 product[0] = '\0';
2109 r = MsiEnumClientsA(component, 0, product);
2110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2111 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2113 /* try index 1, second product value does not exist */
2114 product[0] = '\0';
2115 r = MsiEnumClientsA(component, 1, product);
2116 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2117 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2119 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
2120 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2122 /* try index 1, second product value does exist */
2123 product[0] = '\0';
2124 r = MsiEnumClientsA(component, 1, product);
2125 todo_wine
2127 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2128 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2131 /* start the enumeration over */
2132 product[0] = '\0';
2133 r = MsiEnumClientsA(component, 0, product);
2134 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2135 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2136 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2138 /* correctly query second product */
2139 product[0] = '\0';
2140 r = MsiEnumClientsA(component, 1, product);
2141 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2142 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2143 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2145 RegDeleteValueA(compkey, prod_squashed);
2146 RegDeleteValueA(compkey, prod2_squashed);
2147 RegDeleteKeyA(compkey, "");
2148 RegCloseKey(compkey);
2150 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2151 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
2152 lstrcatA(keypath, comp_squashed);
2154 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
2155 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2157 /* user local component key exists */
2158 product[0] = '\0';
2159 r = MsiEnumClientsA(component, 0, product);
2160 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2161 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2163 /* index > 0, no products exist */
2164 product[0] = '\0';
2165 r = MsiEnumClientsA(component, 1, product);
2166 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2167 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2169 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2170 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2172 /* product value exists */
2173 product[0] = '\0';
2174 r = MsiEnumClientsA(component, 0, product);
2175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2176 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2178 /* try index 0 again */
2179 product[0] = '\0';
2180 r = MsiEnumClientsA(component, 0, product);
2181 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2183 /* try index 1, second product value does not exist */
2184 product[0] = '\0';
2185 r = MsiEnumClientsA(component, 1, product);
2186 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2187 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2189 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
2190 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2192 /* try index 1, second product value does exist */
2193 product[0] = '\0';
2194 r = MsiEnumClientsA(component, 1, product);
2195 todo_wine
2197 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2198 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2201 /* start the enumeration over */
2202 product[0] = '\0';
2203 r = MsiEnumClientsA(component, 0, product);
2204 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2205 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2206 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2208 /* correctly query second product */
2209 product[0] = '\0';
2210 r = MsiEnumClientsA(component, 1, product);
2211 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2212 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2213 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2215 RegDeleteValueA(compkey, prod_squashed);
2216 RegDeleteValueA(compkey, prod2_squashed);
2217 RegDeleteKeyA(compkey, "");
2218 RegCloseKey(compkey);
2221 static void get_version_info(LPSTR path, LPSTR *vercheck, LPDWORD verchecksz,
2222 LPSTR *langcheck, LPDWORD langchecksz)
2224 LPSTR version;
2225 VS_FIXEDFILEINFO *ffi;
2226 DWORD size = GetFileVersionInfoSizeA(path, NULL);
2227 USHORT *lang;
2229 version = HeapAlloc(GetProcessHeap(), 0, size);
2230 GetFileVersionInfoA(path, 0, size, version);
2232 VerQueryValueA(version, "\\", (LPVOID *)&ffi, &size);
2233 *vercheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
2234 sprintf(*vercheck, "%d.%d.%d.%d", HIWORD(ffi->dwFileVersionMS),
2235 LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionLS),
2236 LOWORD(ffi->dwFileVersionLS));
2237 *verchecksz = lstrlenA(*vercheck);
2239 VerQueryValue(version, "\\VarFileInfo\\Translation", (void **)&lang, &size);
2240 *langcheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
2241 sprintf(*langcheck, "%d", *lang);
2242 *langchecksz = lstrlenA(*langcheck);
2244 HeapFree(GetProcessHeap(), 0, version);
2247 static void test_MsiGetFileVersion(void)
2249 UINT r;
2250 DWORD versz, langsz;
2251 char version[MAX_PATH];
2252 char lang[MAX_PATH];
2253 char path[MAX_PATH];
2254 LPSTR vercheck, langcheck;
2255 DWORD verchecksz, langchecksz;
2257 /* NULL szFilePath */
2258 versz = MAX_PATH;
2259 langsz = MAX_PATH;
2260 lstrcpyA(version, "version");
2261 lstrcpyA(lang, "lang");
2262 r = MsiGetFileVersionA(NULL, version, &versz, lang, &langsz);
2263 ok(r == ERROR_INVALID_PARAMETER,
2264 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2265 ok(!lstrcmpA(version, "version"),
2266 "Expected version to be unchanged, got %s\n", version);
2267 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2268 ok(!lstrcmpA(lang, "lang"),
2269 "Expected lang to be unchanged, got %s\n", lang);
2270 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2272 /* empty szFilePath */
2273 versz = MAX_PATH;
2274 langsz = MAX_PATH;
2275 lstrcpyA(version, "version");
2276 lstrcpyA(lang, "lang");
2277 r = MsiGetFileVersionA("", version, &versz, lang, &langsz);
2278 ok(r == ERROR_FILE_NOT_FOUND,
2279 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2280 ok(!lstrcmpA(version, "version"),
2281 "Expected version to be unchanged, got %s\n", version);
2282 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2283 ok(!lstrcmpA(lang, "lang"),
2284 "Expected lang to be unchanged, got %s\n", lang);
2285 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2287 /* nonexistent szFilePath */
2288 versz = MAX_PATH;
2289 langsz = MAX_PATH;
2290 lstrcpyA(version, "version");
2291 lstrcpyA(lang, "lang");
2292 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2293 ok(r == ERROR_FILE_NOT_FOUND,
2294 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2295 ok(!lstrcmpA(version, "version"),
2296 "Expected version to be unchanged, got %s\n", version);
2297 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2298 ok(!lstrcmpA(lang, "lang"),
2299 "Expected lang to be unchanged, got %s\n", lang);
2300 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2302 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
2303 versz = MAX_PATH;
2304 langsz = MAX_PATH;
2305 lstrcpyA(version, "version");
2306 lstrcpyA(lang, "lang");
2307 r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz);
2308 ok(r == ERROR_INVALID_PARAMETER,
2309 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2310 ok(!lstrcmpA(version, "version"),
2311 "Expected version to be unchanged, got %s\n", version);
2312 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2313 ok(!lstrcmpA(lang, "lang"),
2314 "Expected lang to be unchanged, got %s\n", lang);
2315 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2317 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
2318 versz = MAX_PATH;
2319 langsz = MAX_PATH;
2320 lstrcpyA(version, "version");
2321 lstrcpyA(lang, "lang");
2322 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL);
2323 ok(r == ERROR_INVALID_PARAMETER,
2324 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2325 ok(!lstrcmpA(version, "version"),
2326 "Expected version to be unchanged, got %s\n", version);
2327 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2328 ok(!lstrcmpA(lang, "lang"),
2329 "Expected lang to be unchanged, got %s\n", lang);
2330 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2332 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
2333 versz = 0;
2334 langsz = MAX_PATH;
2335 lstrcpyA(version, "version");
2336 lstrcpyA(lang, "lang");
2337 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2338 ok(r == ERROR_FILE_NOT_FOUND,
2339 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2340 ok(!lstrcmpA(version, "version"),
2341 "Expected version to be unchanged, got %s\n", version);
2342 ok(versz == 0, "Expected 0, got %d\n", versz);
2343 ok(!lstrcmpA(lang, "lang"),
2344 "Expected lang to be unchanged, got %s\n", lang);
2345 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2347 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
2348 versz = MAX_PATH;
2349 langsz = 0;
2350 lstrcpyA(version, "version");
2351 lstrcpyA(lang, "lang");
2352 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2353 ok(r == ERROR_FILE_NOT_FOUND,
2354 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2355 ok(!lstrcmpA(version, "version"),
2356 "Expected version to be unchanged, got %s\n", version);
2357 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2358 ok(!lstrcmpA(lang, "lang"),
2359 "Expected lang to be unchanged, got %s\n", lang);
2360 ok(langsz == 0, "Expected 0, got %d\n", langsz);
2362 /* nonexistent szFilePath, rest NULL */
2363 r = MsiGetFileVersionA("nonexistent", NULL, NULL, NULL, NULL);
2364 ok(r == ERROR_FILE_NOT_FOUND,
2365 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2367 create_file("ver.txt", "ver.txt", 20);
2369 /* file exists, no version information */
2370 versz = MAX_PATH;
2371 langsz = MAX_PATH;
2372 lstrcpyA(version, "version");
2373 lstrcpyA(lang, "lang");
2374 r = MsiGetFileVersionA("ver.txt", version, &versz, lang, &langsz);
2375 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2376 ok(!lstrcmpA(version, "version"),
2377 "Expected version to be unchanged, got %s\n", version);
2378 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2379 ok(!lstrcmpA(lang, "lang"),
2380 "Expected lang to be unchanged, got %s\n", lang);
2381 ok(r == ERROR_FILE_INVALID,
2382 "Expected ERROR_FILE_INVALID, got %d\n", r);
2384 DeleteFileA("ver.txt");
2386 /* relative path, has version information */
2387 versz = MAX_PATH;
2388 langsz = MAX_PATH;
2389 lstrcpyA(version, "version");
2390 lstrcpyA(lang, "lang");
2391 r = MsiGetFileVersionA("kernel32.dll", version, &versz, lang, &langsz);
2392 todo_wine
2394 ok(r == ERROR_FILE_NOT_FOUND,
2395 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2396 ok(!lstrcmpA(version, "version"),
2397 "Expected version to be unchanged, got %s\n", version);
2398 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2399 ok(!lstrcmpA(lang, "lang"),
2400 "Expected lang to be unchanged, got %s\n", lang);
2401 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2404 GetSystemDirectoryA(path, MAX_PATH);
2405 lstrcatA(path, "\\kernel32.dll");
2407 get_version_info(path, &vercheck, &verchecksz, &langcheck, &langchecksz);
2409 /* absolute path, has version information */
2410 versz = MAX_PATH;
2411 langsz = MAX_PATH;
2412 lstrcpyA(version, "version");
2413 lstrcpyA(lang, "lang");
2414 r = MsiGetFileVersionA(path, version, &versz, lang, &langsz);
2415 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2416 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2417 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
2418 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2419 ok(!lstrcmpA(version, vercheck),
2420 "Expected %s, got %s\n", vercheck, version);
2422 /* only check version */
2423 versz = MAX_PATH;
2424 lstrcpyA(version, "version");
2425 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
2426 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2427 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2428 ok(!lstrcmpA(version, vercheck),
2429 "Expected %s, got %s\n", vercheck, version);
2431 /* only check language */
2432 langsz = MAX_PATH;
2433 lstrcpyA(lang, "lang");
2434 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2435 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2436 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
2437 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2439 /* check neither version nor language */
2440 r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
2441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2443 /* get pcchVersionBuf */
2444 versz = MAX_PATH;
2445 r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL);
2446 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2447 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2449 /* get pcchLangBuf */
2450 langsz = MAX_PATH;
2451 r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
2452 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2453 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2455 /* pcchVersionBuf not big enough */
2456 versz = 5;
2457 lstrcpyA(version, "version");
2458 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
2459 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2460 ok(!strncmp(version, vercheck, 4),
2461 "Expected first 4 characters of %s, got %s\n", vercheck, version);
2462 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2464 /* pcchLangBuf not big enough */
2465 langsz = 3;
2466 lstrcpyA(lang, "lang");
2467 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2468 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2469 ok(!strncmp(lang, langcheck, 2),
2470 "Expected first character of %s, got %s\n", langcheck, lang);
2471 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2473 HeapFree(GetProcessHeap(), 0, vercheck);
2474 HeapFree(GetProcessHeap(), 0, langcheck);
2477 static void test_MsiGetProductInfo(void)
2479 UINT r;
2480 LONG res;
2481 HKEY propkey, source;
2482 HKEY prodkey, localkey;
2483 CHAR prodcode[MAX_PATH];
2484 CHAR prod_squashed[MAX_PATH];
2485 CHAR packcode[MAX_PATH];
2486 CHAR pack_squashed[MAX_PATH];
2487 CHAR buf[MAX_PATH];
2488 CHAR keypath[MAX_PATH];
2489 LPSTR usersid;
2490 DWORD sz, val = 42;
2492 create_test_guid(prodcode, prod_squashed);
2493 create_test_guid(packcode, pack_squashed);
2494 get_user_sid(&usersid);
2496 /* NULL szProduct */
2497 sz = MAX_PATH;
2498 lstrcpyA(buf, "apple");
2499 r = MsiGetProductInfoA(NULL, INSTALLPROPERTY_HELPLINK, buf, &sz);
2500 ok(r == ERROR_INVALID_PARAMETER,
2501 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2502 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2503 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2505 /* empty szProduct */
2506 sz = MAX_PATH;
2507 lstrcpyA(buf, "apple");
2508 r = MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINK, buf, &sz);
2509 ok(r == ERROR_INVALID_PARAMETER,
2510 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2511 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2512 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2514 /* garbage szProduct */
2515 sz = MAX_PATH;
2516 lstrcpyA(buf, "apple");
2517 r = MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINK, buf, &sz);
2518 ok(r == ERROR_INVALID_PARAMETER,
2519 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2520 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2521 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2523 /* guid without brackets */
2524 sz = MAX_PATH;
2525 lstrcpyA(buf, "apple");
2526 r = MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
2527 INSTALLPROPERTY_HELPLINK, buf, &sz);
2528 ok(r == ERROR_INVALID_PARAMETER,
2529 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2530 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2531 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2533 /* guid with brackets */
2534 sz = MAX_PATH;
2535 lstrcpyA(buf, "apple");
2536 r = MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
2537 INSTALLPROPERTY_HELPLINK, buf, &sz);
2538 ok(r == ERROR_UNKNOWN_PRODUCT,
2539 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2540 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2541 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2543 /* same length as guid, but random */
2544 sz = MAX_PATH;
2545 lstrcpyA(buf, "apple");
2546 r = MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
2547 INSTALLPROPERTY_HELPLINK, buf, &sz);
2548 ok(r == ERROR_INVALID_PARAMETER,
2549 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2550 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2551 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2553 /* not installed, NULL szAttribute */
2554 sz = MAX_PATH;
2555 lstrcpyA(buf, "apple");
2556 r = MsiGetProductInfoA(prodcode, NULL, buf, &sz);
2557 ok(r == ERROR_INVALID_PARAMETER,
2558 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2559 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2560 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2562 /* not installed, NULL lpValueBuf */
2563 sz = MAX_PATH;
2564 lstrcpyA(buf, "apple");
2565 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2566 ok(r == ERROR_UNKNOWN_PRODUCT,
2567 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2568 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2569 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2571 /* not installed, NULL pcchValueBuf */
2572 sz = MAX_PATH;
2573 lstrcpyA(buf, "apple");
2574 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, NULL);
2575 ok(r == ERROR_INVALID_PARAMETER,
2576 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2577 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2578 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2580 /* created guid cannot possibly be an installed product code */
2581 sz = MAX_PATH;
2582 lstrcpyA(buf, "apple");
2583 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2584 ok(r == ERROR_UNKNOWN_PRODUCT,
2585 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2586 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2587 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2589 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2590 lstrcatA(keypath, usersid);
2591 lstrcatA(keypath, "\\Installer\\Products\\");
2592 lstrcatA(keypath, prod_squashed);
2594 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2595 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2597 /* managed product code exists */
2598 sz = MAX_PATH;
2599 lstrcpyA(buf, "apple");
2600 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2601 ok(r == ERROR_UNKNOWN_PROPERTY,
2602 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2603 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2604 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2606 RegDeleteKeyA(prodkey, "");
2607 RegCloseKey(prodkey);
2609 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2610 lstrcatA(keypath, usersid);
2611 lstrcatA(keypath, "\\Products\\");
2612 lstrcatA(keypath, prod_squashed);
2614 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2615 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2617 /* local user product code exists */
2618 sz = MAX_PATH;
2619 lstrcpyA(buf, "apple");
2620 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2621 ok(r == ERROR_UNKNOWN_PRODUCT,
2622 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2623 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2624 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2626 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2627 lstrcatA(keypath, usersid);
2628 lstrcatA(keypath, "\\Installer\\Products\\");
2629 lstrcatA(keypath, prod_squashed);
2631 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2632 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2634 /* both local and managed product code exist */
2635 sz = MAX_PATH;
2636 lstrcpyA(buf, "apple");
2637 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2638 ok(r == ERROR_UNKNOWN_PROPERTY,
2639 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2640 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2641 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2643 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2644 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2646 /* InstallProperties key exists */
2647 sz = MAX_PATH;
2648 lstrcpyA(buf, "apple");
2649 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2650 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2651 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2652 ok(sz == 0, "Expected 0, got %d\n", sz);
2654 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2655 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2657 /* HelpLink value exists */
2658 sz = MAX_PATH;
2659 lstrcpyA(buf, "apple");
2660 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2661 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2662 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2663 ok(sz == 4, "Expected 4, got %d\n", sz);
2665 /* pcchBuf is NULL */
2666 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, NULL);
2667 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2669 /* lpValueBuf is NULL */
2670 sz = MAX_PATH;
2671 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2672 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2673 ok(sz == 4, "Expected 4, got %d\n", sz);
2675 /* lpValueBuf is NULL, pcchValueBuf is too small */
2676 sz = 2;
2677 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2679 ok(sz == 4, "Expected 4, got %d\n", sz);
2681 /* lpValueBuf is NULL, pcchValueBuf is too small */
2682 sz = 2;
2683 lstrcpyA(buf, "apple");
2684 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2685 ok(!lstrcmpA(buf, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf);
2686 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2687 ok(sz == 4, "Expected 4, got %d\n", sz);
2689 /* lpValueBuf is NULL, pcchValueBuf is exactly 4 */
2690 sz = 4;
2691 lstrcpyA(buf, "apple");
2692 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2693 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2694 ok(!lstrcmpA(buf, "apple"),
2695 "Expected buf to remain unchanged, got \"%s\"\n", buf);
2696 ok(sz == 4, "Expected 4, got %d\n", sz);
2698 res = RegSetValueExA(propkey, "IMadeThis", 0, REG_SZ, (LPBYTE)"random", 7);
2699 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2701 /* random property not supported by MSI, value exists */
2702 sz = MAX_PATH;
2703 lstrcpyA(buf, "apple");
2704 r = MsiGetProductInfoA(prodcode, "IMadeThis", buf, &sz);
2705 ok(r == ERROR_UNKNOWN_PROPERTY,
2706 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2707 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2708 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2710 RegDeleteValueA(propkey, "IMadeThis");
2711 RegDeleteValueA(propkey, "HelpLink");
2712 RegDeleteKeyA(propkey, "");
2713 RegDeleteKeyA(localkey, "");
2714 RegDeleteKeyA(prodkey, "");
2715 RegCloseKey(propkey);
2716 RegCloseKey(localkey);
2717 RegCloseKey(prodkey);
2719 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2720 lstrcatA(keypath, prod_squashed);
2722 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2723 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2725 /* user product key exists */
2726 sz = MAX_PATH;
2727 lstrcpyA(buf, "apple");
2728 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2729 ok(r == ERROR_UNKNOWN_PROPERTY,
2730 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2731 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2732 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2734 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2735 lstrcatA(keypath, usersid);
2736 lstrcatA(keypath, "\\Products\\");
2737 lstrcatA(keypath, prod_squashed);
2739 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2740 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2742 /* local user product key exists */
2743 sz = MAX_PATH;
2744 lstrcpyA(buf, "apple");
2745 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2746 ok(r == ERROR_UNKNOWN_PROPERTY,
2747 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2748 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2749 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2751 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2752 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2754 /* InstallProperties key exists */
2755 sz = MAX_PATH;
2756 lstrcpyA(buf, "apple");
2757 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2758 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2759 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2760 ok(sz == 0, "Expected 0, got %d\n", sz);
2762 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2763 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2765 /* HelpLink value exists */
2766 sz = MAX_PATH;
2767 lstrcpyA(buf, "apple");
2768 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2769 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2770 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2771 ok(sz == 4, "Expected 4, got %d\n", sz);
2773 RegDeleteValueA(propkey, "HelpLink");
2774 RegDeleteKeyA(propkey, "");
2775 RegDeleteKeyA(localkey, "");
2776 RegDeleteKeyA(prodkey, "");
2777 RegCloseKey(propkey);
2778 RegCloseKey(localkey);
2779 RegCloseKey(prodkey);
2781 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2782 lstrcatA(keypath, prod_squashed);
2784 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2785 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2787 /* classes product key exists */
2788 sz = MAX_PATH;
2789 lstrcpyA(buf, "apple");
2790 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2791 ok(r == ERROR_UNKNOWN_PROPERTY,
2792 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2793 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2794 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2796 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2797 lstrcatA(keypath, usersid);
2798 lstrcatA(keypath, "\\Products\\");
2799 lstrcatA(keypath, prod_squashed);
2801 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2802 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2804 /* local user product key exists */
2805 sz = MAX_PATH;
2806 lstrcpyA(buf, "apple");
2807 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2808 ok(r == ERROR_UNKNOWN_PROPERTY,
2809 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2810 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2811 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2813 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2814 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2816 /* InstallProperties key exists */
2817 sz = MAX_PATH;
2818 lstrcpyA(buf, "apple");
2819 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2820 ok(r == ERROR_UNKNOWN_PROPERTY,
2821 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2822 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2823 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2825 RegDeleteKeyA(propkey, "");
2826 RegDeleteKeyA(localkey, "");
2827 RegCloseKey(propkey);
2828 RegCloseKey(localkey);
2830 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2831 lstrcatA(keypath, "S-1-5-18\\\\Products\\");
2832 lstrcatA(keypath, prod_squashed);
2834 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2835 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2837 /* Local System product key exists */
2838 sz = MAX_PATH;
2839 lstrcpyA(buf, "apple");
2840 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2841 ok(r == ERROR_UNKNOWN_PROPERTY,
2842 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2843 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2844 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2846 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2847 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2849 /* InstallProperties key exists */
2850 sz = MAX_PATH;
2851 lstrcpyA(buf, "apple");
2852 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2853 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2854 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2855 ok(sz == 0, "Expected 0, got %d\n", sz);
2857 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2858 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2860 /* HelpLink value exists */
2861 sz = MAX_PATH;
2862 lstrcpyA(buf, "apple");
2863 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2864 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2865 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2866 ok(sz == 4, "Expected 4, got %d\n", sz);
2868 res = RegSetValueExA(propkey, "HelpLink", 0, REG_DWORD,
2869 (const BYTE *)&val, sizeof(DWORD));
2870 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2872 /* HelpLink type is REG_DWORD */
2873 sz = MAX_PATH;
2874 lstrcpyA(buf, "apple");
2875 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2876 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2877 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2878 ok(sz == 2, "Expected 2, got %d\n", sz);
2880 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
2881 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2883 /* DisplayName value exists */
2884 sz = MAX_PATH;
2885 lstrcpyA(buf, "apple");
2886 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
2887 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2888 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
2889 ok(sz == 4, "Expected 4, got %d\n", sz);
2891 res = RegSetValueExA(propkey, "DisplayName", 0, REG_DWORD,
2892 (const BYTE *)&val, sizeof(DWORD));
2893 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2895 /* DisplayName type is REG_DWORD */
2896 sz = MAX_PATH;
2897 lstrcpyA(buf, "apple");
2898 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
2899 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2900 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2901 ok(sz == 2, "Expected 2, got %d\n", sz);
2903 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"1.1.1", 6);
2904 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2906 /* DisplayVersion value exists */
2907 sz = MAX_PATH;
2908 lstrcpyA(buf, "apple");
2909 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
2910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2911 ok(!lstrcmpA(buf, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf);
2912 ok(sz == 5, "Expected 5, got %d\n", sz);
2914 res = RegSetValueExA(propkey, "DisplayVersion", 0,
2915 REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
2916 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2918 /* DisplayVersion type is REG_DWORD */
2919 sz = MAX_PATH;
2920 lstrcpyA(buf, "apple");
2921 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
2922 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2923 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2924 ok(sz == 2, "Expected 2, got %d\n", sz);
2926 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"tele", 5);
2927 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2929 /* HelpTelephone value exists */
2930 sz = MAX_PATH;
2931 lstrcpyA(buf, "apple");
2932 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
2933 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2934 ok(!lstrcmpA(buf, "tele"), "Expected \"tele\", got \"%s\"\n", buf);
2935 ok(sz == 4, "Expected 4, got %d\n", sz);
2937 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_DWORD,
2938 (const BYTE *)&val, sizeof(DWORD));
2939 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2941 /* HelpTelephone type is REG_DWORD */
2942 sz = MAX_PATH;
2943 lstrcpyA(buf, "apple");
2944 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
2945 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2946 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2947 ok(sz == 2, "Expected 2, got %d\n", sz);
2949 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
2950 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2952 /* InstallLocation value exists */
2953 sz = MAX_PATH;
2954 lstrcpyA(buf, "apple");
2955 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
2956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2957 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
2958 ok(sz == 3, "Expected 3, got %d\n", sz);
2960 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_DWORD,
2961 (const BYTE *)&val, sizeof(DWORD));
2962 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2964 /* InstallLocation type is REG_DWORD */
2965 sz = MAX_PATH;
2966 lstrcpyA(buf, "apple");
2967 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
2968 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2969 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2970 ok(sz == 2, "Expected 2, got %d\n", sz);
2972 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
2973 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2975 /* InstallSource value exists */
2976 sz = MAX_PATH;
2977 lstrcpyA(buf, "apple");
2978 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
2979 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2980 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
2981 ok(sz == 6, "Expected 6, got %d\n", sz);
2983 res = RegSetValueExA(propkey, "InstallSource", 0, REG_DWORD,
2984 (const BYTE *)&val, sizeof(DWORD));
2985 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2987 /* InstallSource type is REG_DWORD */
2988 sz = MAX_PATH;
2989 lstrcpyA(buf, "apple");
2990 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
2991 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2992 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2993 ok(sz == 2, "Expected 2, got %d\n", sz);
2995 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
2996 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2998 /* InstallDate value exists */
2999 sz = MAX_PATH;
3000 lstrcpyA(buf, "apple");
3001 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATE, buf, &sz);
3002 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3003 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
3004 ok(sz == 4, "Expected 4, got %d\n", sz);
3006 res = RegSetValueExA(propkey, "InstallDate", 0, REG_DWORD,
3007 (const BYTE *)&val, sizeof(DWORD));
3008 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3010 /* InstallDate type is REG_DWORD */
3011 sz = MAX_PATH;
3012 lstrcpyA(buf, "apple");
3013 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATE, buf, &sz);
3014 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3015 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3016 ok(sz == 2, "Expected 2, got %d\n", sz);
3018 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
3019 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3021 /* Publisher value exists */
3022 sz = MAX_PATH;
3023 lstrcpyA(buf, "apple");
3024 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHER, buf, &sz);
3025 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3026 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
3027 ok(sz == 3, "Expected 3, got %d\n", sz);
3029 res = RegSetValueExA(propkey, "Publisher", 0, REG_DWORD,
3030 (const BYTE *)&val, sizeof(DWORD));
3031 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3033 /* Publisher type is REG_DWORD */
3034 sz = MAX_PATH;
3035 lstrcpyA(buf, "apple");
3036 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHER, buf, &sz);
3037 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3038 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3039 ok(sz == 2, "Expected 2, got %d\n", sz);
3041 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"pack", 5);
3042 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3044 /* LocalPackage value exists */
3045 sz = MAX_PATH;
3046 lstrcpyA(buf, "apple");
3047 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
3048 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3049 ok(!lstrcmpA(buf, "pack"), "Expected \"pack\", got \"%s\"\n", buf);
3050 ok(sz == 4, "Expected 4, got %d\n", sz);
3052 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_DWORD,
3053 (const BYTE *)&val, sizeof(DWORD));
3054 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3056 /* LocalPackage type is REG_DWORD */
3057 sz = MAX_PATH;
3058 lstrcpyA(buf, "apple");
3059 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
3060 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3061 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3062 ok(sz == 2, "Expected 2, got %d\n", sz);
3064 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
3065 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3067 /* UrlInfoAbout value exists */
3068 sz = MAX_PATH;
3069 lstrcpyA(buf, "apple");
3070 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
3071 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3072 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
3073 ok(sz == 5, "Expected 5, got %d\n", sz);
3075 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_DWORD,
3076 (const BYTE *)&val, sizeof(DWORD));
3077 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3079 /* UrlInfoAbout type is REG_DWORD */
3080 sz = MAX_PATH;
3081 lstrcpyA(buf, "apple");
3082 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
3083 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3084 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3085 ok(sz == 2, "Expected 2, got %d\n", sz);
3087 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_SZ, (LPBYTE)"info", 5);
3088 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3090 /* UrlUpdateInfo value exists */
3091 sz = MAX_PATH;
3092 lstrcpyA(buf, "apple");
3093 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
3094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3095 ok(!lstrcmpA(buf, "info"), "Expected \"info\", got \"%s\"\n", buf);
3096 ok(sz == 4, "Expected 4, got %d\n", sz);
3098 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_DWORD,
3099 (const BYTE *)&val, sizeof(DWORD));
3100 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3102 /* UrlUpdateInfo type is REG_DWORD */
3103 sz = MAX_PATH;
3104 lstrcpyA(buf, "apple");
3105 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
3106 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3107 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3108 ok(sz == 2, "Expected 2, got %d\n", sz);
3110 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"1", 2);
3111 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3113 /* VersionMinor value exists */
3114 sz = MAX_PATH;
3115 lstrcpyA(buf, "apple");
3116 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
3117 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3118 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
3119 ok(sz == 1, "Expected 1, got %d\n", sz);
3121 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_DWORD,
3122 (const BYTE *)&val, sizeof(DWORD));
3123 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3125 /* VersionMinor type is REG_DWORD */
3126 sz = MAX_PATH;
3127 lstrcpyA(buf, "apple");
3128 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
3129 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3130 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3131 ok(sz == 2, "Expected 2, got %d\n", sz);
3133 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"1", 2);
3134 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3136 /* VersionMajor value exists */
3137 sz = MAX_PATH;
3138 lstrcpyA(buf, "apple");
3139 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
3140 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3141 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
3142 ok(sz == 1, "Expected 1, got %d\n", sz);
3144 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_DWORD,
3145 (const BYTE *)&val, sizeof(DWORD));
3146 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3148 /* VersionMajor type is REG_DWORD */
3149 sz = MAX_PATH;
3150 lstrcpyA(buf, "apple");
3151 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
3152 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3153 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3154 ok(sz == 2, "Expected 2, got %d\n", sz);
3156 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
3157 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3159 /* ProductID value exists */
3160 sz = MAX_PATH;
3161 lstrcpyA(buf, "apple");
3162 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTID, buf, &sz);
3163 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3164 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
3165 ok(sz == 2, "Expected 2, got %d\n", sz);
3167 res = RegSetValueExA(propkey, "ProductID", 0, REG_DWORD,
3168 (const BYTE *)&val, sizeof(DWORD));
3169 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3171 /* ProductID type is REG_DWORD */
3172 sz = MAX_PATH;
3173 lstrcpyA(buf, "apple");
3174 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTID, buf, &sz);
3175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3176 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3177 ok(sz == 2, "Expected 2, got %d\n", sz);
3179 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
3180 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3182 /* RegCompany value exists */
3183 sz = MAX_PATH;
3184 lstrcpyA(buf, "apple");
3185 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANY, buf, &sz);
3186 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3187 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
3188 ok(sz == 4, "Expected 4, got %d\n", sz);
3190 res = RegSetValueExA(propkey, "RegCompany", 0, REG_DWORD,
3191 (const BYTE *)&val, sizeof(DWORD));
3192 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3194 /* RegCompany type is REG_DWORD */
3195 sz = MAX_PATH;
3196 lstrcpyA(buf, "apple");
3197 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANY, 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);
3202 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"own", 4);
3203 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3205 /* RegOwner value exists */
3206 sz = MAX_PATH;
3207 lstrcpyA(buf, "apple");
3208 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNER, buf, &sz);
3209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3210 ok(!lstrcmpA(buf, "own"), "Expected \"own\", got \"%s\"\n", buf);
3211 ok(sz == 3, "Expected 3, got %d\n", sz);
3213 res = RegSetValueExA(propkey, "RegOwner", 0, REG_DWORD,
3214 (const BYTE *)&val, sizeof(DWORD));
3215 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3217 /* RegOwner type is REG_DWORD */
3218 sz = MAX_PATH;
3219 lstrcpyA(buf, "apple");
3220 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNER, buf, &sz);
3221 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3222 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3223 ok(sz == 2, "Expected 2, got %d\n", sz);
3225 res = RegSetValueExA(propkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
3226 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3228 /* InstanceType value exists */
3229 sz = MAX_PATH;
3230 lstrcpyA(buf, "apple");
3231 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3233 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3234 ok(sz == 0, "Expected 0, got %d\n", sz);
3236 res = RegSetValueExA(propkey, "InstanceType", 0, REG_DWORD,
3237 (const BYTE *)&val, sizeof(DWORD));
3238 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3240 /* InstanceType type is REG_DWORD */
3241 sz = MAX_PATH;
3242 lstrcpyA(buf, "apple");
3243 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3245 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3246 ok(sz == 0, "Expected 0, got %d\n", sz);
3248 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
3249 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3251 /* InstanceType value exists */
3252 sz = MAX_PATH;
3253 lstrcpyA(buf, "apple");
3254 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3255 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3256 ok(!lstrcmpA(buf, "type"), "Expected \"type\", got \"%s\"\n", buf);
3257 ok(sz == 4, "Expected 4, got %d\n", sz);
3259 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_DWORD,
3260 (const BYTE *)&val, sizeof(DWORD));
3261 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3263 /* InstanceType type is REG_DWORD */
3264 sz = MAX_PATH;
3265 lstrcpyA(buf, "apple");
3266 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3268 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3269 ok(sz == 2, "Expected 2, got %d\n", sz);
3271 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
3272 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3274 /* Transforms value exists */
3275 sz = MAX_PATH;
3276 lstrcpyA(buf, "apple");
3277 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3278 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3279 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3280 ok(sz == 0, "Expected 0, got %d\n", sz);
3282 res = RegSetValueExA(propkey, "Transforms", 0, REG_DWORD,
3283 (const BYTE *)&val, sizeof(DWORD));
3284 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3286 /* Transforms type is REG_DWORD */
3287 sz = MAX_PATH;
3288 lstrcpyA(buf, "apple");
3289 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3290 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3291 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3292 ok(sz == 0, "Expected 0, got %d\n", sz);
3294 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
3295 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3297 /* Transforms value exists */
3298 sz = MAX_PATH;
3299 lstrcpyA(buf, "apple");
3300 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3302 ok(!lstrcmpA(buf, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf);
3303 ok(sz == 6, "Expected 6, got %d\n", sz);
3305 res = RegSetValueExA(prodkey, "Transforms", 0, REG_DWORD,
3306 (const BYTE *)&val, sizeof(DWORD));
3307 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3309 /* Transforms type is REG_DWORD */
3310 sz = MAX_PATH;
3311 lstrcpyA(buf, "apple");
3312 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3313 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3314 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3315 ok(sz == 2, "Expected 2, got %d\n", sz);
3317 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
3318 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3320 /* Language value exists */
3321 sz = MAX_PATH;
3322 lstrcpyA(buf, "apple");
3323 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3324 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3325 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3326 ok(sz == 0, "Expected 0, got %d\n", sz);
3328 res = RegSetValueExA(propkey, "Language", 0, REG_DWORD,
3329 (const BYTE *)&val, sizeof(DWORD));
3330 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3332 /* Language type is REG_DWORD */
3333 sz = MAX_PATH;
3334 lstrcpyA(buf, "apple");
3335 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3336 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3337 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3338 ok(sz == 0, "Expected 0, got %d\n", sz);
3340 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
3341 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3343 /* Language value exists */
3344 sz = MAX_PATH;
3345 lstrcpyA(buf, "apple");
3346 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3347 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3348 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
3349 ok(sz == 4, "Expected 4, got %d\n", sz);
3351 res = RegSetValueExA(prodkey, "Language", 0, REG_DWORD,
3352 (const BYTE *)&val, sizeof(DWORD));
3353 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3355 /* Language type is REG_DWORD */
3356 sz = MAX_PATH;
3357 lstrcpyA(buf, "apple");
3358 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3360 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3361 ok(sz == 2, "Expected 2, got %d\n", sz);
3363 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
3364 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3366 /* ProductName value exists */
3367 sz = MAX_PATH;
3368 lstrcpyA(buf, "apple");
3369 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3370 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3371 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3372 ok(sz == 0, "Expected 0, got %d\n", sz);
3374 res = RegSetValueExA(propkey, "ProductName", 0, REG_DWORD,
3375 (const BYTE *)&val, sizeof(DWORD));
3376 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3378 /* ProductName type is REG_DWORD */
3379 sz = MAX_PATH;
3380 lstrcpyA(buf, "apple");
3381 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3383 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3384 ok(sz == 0, "Expected 0, got %d\n", sz);
3386 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
3387 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3389 /* ProductName value exists */
3390 sz = MAX_PATH;
3391 lstrcpyA(buf, "apple");
3392 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3394 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
3395 ok(sz == 4, "Expected 4, got %d\n", sz);
3397 res = RegSetValueExA(prodkey, "ProductName", 0, REG_DWORD,
3398 (const BYTE *)&val, sizeof(DWORD));
3399 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3401 /* ProductName type is REG_DWORD */
3402 sz = MAX_PATH;
3403 lstrcpyA(buf, "apple");
3404 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3406 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3407 ok(sz == 2, "Expected 2, got %d\n", sz);
3409 res = RegSetValueExA(propkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
3410 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3412 /* Assignment value exists */
3413 sz = MAX_PATH;
3414 lstrcpyA(buf, "apple");
3415 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3416 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3417 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3418 ok(sz == 0, "Expected 0, got %d\n", sz);
3420 res = RegSetValueExA(propkey, "Assignment", 0, REG_DWORD,
3421 (const BYTE *)&val, sizeof(DWORD));
3422 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3424 /* Assignment type is REG_DWORD */
3425 sz = MAX_PATH;
3426 lstrcpyA(buf, "apple");
3427 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3428 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3429 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3430 ok(sz == 0, "Expected 0, got %d\n", sz);
3432 res = RegSetValueExA(prodkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
3433 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3435 /* Assignment value exists */
3436 sz = MAX_PATH;
3437 lstrcpyA(buf, "apple");
3438 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3439 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3440 ok(!lstrcmpA(buf, "at"), "Expected \"at\", got \"%s\"\n", buf);
3441 ok(sz == 2, "Expected 2, got %d\n", sz);
3443 res = RegSetValueExA(prodkey, "Assignment", 0, REG_DWORD,
3444 (const BYTE *)&val, sizeof(DWORD));
3445 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3447 /* Assignment type is REG_DWORD */
3448 sz = MAX_PATH;
3449 lstrcpyA(buf, "apple");
3450 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3451 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3452 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3453 ok(sz == 2, "Expected 2, got %d\n", sz);
3455 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
3456 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3458 /* PackageCode value exists */
3459 sz = MAX_PATH;
3460 lstrcpyA(buf, "apple");
3461 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3462 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3463 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3464 ok(sz == 0, "Expected 0, got %d\n", sz);
3466 res = RegSetValueExA(propkey, "PackageCode", 0, REG_DWORD,
3467 (const BYTE *)&val, sizeof(DWORD));
3468 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3470 /* PackageCode type is REG_DWORD */
3471 sz = MAX_PATH;
3472 lstrcpyA(buf, "apple");
3473 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3474 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3475 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3476 ok(sz == 0, "Expected 0, got %d\n", sz);
3478 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
3479 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3481 /* PackageCode value exists */
3482 sz = MAX_PATH;
3483 lstrcpyA(buf, "apple");
3484 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3485 ok(r == ERROR_BAD_CONFIGURATION,
3486 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3487 ok(!lstrcmpA(buf, "code"), "Expected \"code\", got \"%s\"\n", buf);
3488 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3490 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_DWORD,
3491 (const BYTE *)&val, sizeof(DWORD));
3492 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3494 /* PackageCode type is REG_DWORD */
3495 sz = MAX_PATH;
3496 lstrcpyA(buf, "apple");
3497 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3498 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3499 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3500 ok(sz == 2, "Expected 2, got %d\n", sz);
3502 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)pack_squashed, 33);
3503 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3505 /* PackageCode value exists */
3506 sz = MAX_PATH;
3507 lstrcpyA(buf, "apple");
3508 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3509 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3510 ok(!lstrcmpA(buf, packcode), "Expected \"%s\", got \"%s\"\n", packcode, buf);
3511 ok(sz == 38, "Expected 38, got %d\n", sz);
3513 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
3514 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3516 /* Version value exists */
3517 sz = MAX_PATH;
3518 lstrcpyA(buf, "apple");
3519 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3520 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3521 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3522 ok(sz == 0, "Expected 0, got %d\n", sz);
3524 res = RegSetValueExA(propkey, "Version", 0, REG_DWORD,
3525 (const BYTE *)&val, sizeof(DWORD));
3526 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3528 /* Version type is REG_DWORD */
3529 sz = MAX_PATH;
3530 lstrcpyA(buf, "apple");
3531 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3532 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3533 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3534 ok(sz == 0, "Expected 0, got %d\n", sz);
3536 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
3537 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3539 /* Version value exists */
3540 sz = MAX_PATH;
3541 lstrcpyA(buf, "apple");
3542 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3543 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3544 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
3545 ok(sz == 3, "Expected 3, got %d\n", sz);
3547 res = RegSetValueExA(prodkey, "Version", 0, REG_DWORD,
3548 (const BYTE *)&val, sizeof(DWORD));
3549 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3551 /* Version type is REG_DWORD */
3552 sz = MAX_PATH;
3553 lstrcpyA(buf, "apple");
3554 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3555 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3556 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3557 ok(sz == 2, "Expected 2, got %d\n", sz);
3559 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
3560 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3562 /* ProductIcon value exists */
3563 sz = MAX_PATH;
3564 lstrcpyA(buf, "apple");
3565 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3566 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3567 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3568 ok(sz == 0, "Expected 0, got %d\n", sz);
3570 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_DWORD,
3571 (const BYTE *)&val, sizeof(DWORD));
3572 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3574 /* ProductIcon type is REG_DWORD */
3575 sz = MAX_PATH;
3576 lstrcpyA(buf, "apple");
3577 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3578 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3579 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3580 ok(sz == 0, "Expected 0, got %d\n", sz);
3582 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
3583 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3585 /* ProductIcon value exists */
3586 sz = MAX_PATH;
3587 lstrcpyA(buf, "apple");
3588 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3589 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3590 ok(!lstrcmpA(buf, "ico"), "Expected \"ico\", got \"%s\"\n", buf);
3591 ok(sz == 3, "Expected 3, got %d\n", sz);
3593 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_DWORD,
3594 (const BYTE *)&val, sizeof(DWORD));
3595 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3597 /* ProductIcon type is REG_DWORD */
3598 sz = MAX_PATH;
3599 lstrcpyA(buf, "apple");
3600 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3601 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3602 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3603 ok(sz == 2, "Expected 2, got %d\n", sz);
3605 res = RegCreateKeyA(prodkey, "SourceList", &source);
3606 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3608 res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
3609 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3611 sz = MAX_PATH;
3612 lstrcpyA(buf, "apple");
3613 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
3614 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3615 ok(!lstrcmpA(buf, "packname"), "Expected \"packname\", got \"%s\"\n", buf);
3616 ok(sz == 8, "Expected 8, got %d\n", sz);
3618 res = RegSetValueExA(source, "PackageName", 0, REG_DWORD,
3619 (const BYTE *)&val, sizeof(DWORD));
3620 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3622 /* PackageName type is REG_DWORD */
3623 sz = MAX_PATH;
3624 lstrcpyA(buf, "apple");
3625 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
3626 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3627 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3628 ok(sz == 2, "Expected 2, got %d\n", sz);
3630 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3631 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3633 /* Authorized value exists */
3634 sz = MAX_PATH;
3635 lstrcpyA(buf, "apple");
3636 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3637 if (r != ERROR_UNKNOWN_PROPERTY)
3639 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3640 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3641 ok(sz == 0, "Expected 0, got %d\n", sz);
3644 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_DWORD,
3645 (const BYTE *)&val, sizeof(DWORD));
3646 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3648 /* AuthorizedLUAApp type is REG_DWORD */
3649 sz = MAX_PATH;
3650 lstrcpyA(buf, "apple");
3651 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3652 if (r != ERROR_UNKNOWN_PROPERTY)
3654 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3655 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3656 ok(sz == 0, "Expected 0, got %d\n", sz);
3659 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3660 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3662 /* Authorized value exists */
3663 sz = MAX_PATH;
3664 lstrcpyA(buf, "apple");
3665 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3666 if (r != ERROR_UNKNOWN_PROPERTY)
3668 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3669 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
3670 ok(sz == 4, "Expected 4, got %d\n", sz);
3673 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_DWORD,
3674 (const BYTE *)&val, sizeof(DWORD));
3675 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3677 /* AuthorizedLUAApp type is REG_DWORD */
3678 sz = MAX_PATH;
3679 lstrcpyA(buf, "apple");
3680 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3681 if (r != ERROR_UNKNOWN_PROPERTY)
3683 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3684 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3685 ok(sz == 2, "Expected 2, got %d\n", sz);
3688 RegDeleteValueA(propkey, "HelpLink");
3689 RegDeleteValueA(propkey, "DisplayName");
3690 RegDeleteValueA(propkey, "DisplayVersion");
3691 RegDeleteValueA(propkey, "HelpTelephone");
3692 RegDeleteValueA(propkey, "InstallLocation");
3693 RegDeleteValueA(propkey, "InstallSource");
3694 RegDeleteValueA(propkey, "InstallDate");
3695 RegDeleteValueA(propkey, "Publisher");
3696 RegDeleteValueA(propkey, "LocalPackage");
3697 RegDeleteValueA(propkey, "UrlInfoAbout");
3698 RegDeleteValueA(propkey, "UrlUpdateInfo");
3699 RegDeleteValueA(propkey, "VersionMinor");
3700 RegDeleteValueA(propkey, "VersionMajor");
3701 RegDeleteValueA(propkey, "ProductID");
3702 RegDeleteValueA(propkey, "RegCompany");
3703 RegDeleteValueA(propkey, "RegOwner");
3704 RegDeleteValueA(propkey, "InstanceType");
3705 RegDeleteValueA(propkey, "Transforms");
3706 RegDeleteValueA(propkey, "Language");
3707 RegDeleteValueA(propkey, "ProductName");
3708 RegDeleteValueA(propkey, "Assignment");
3709 RegDeleteValueA(propkey, "PackageCode");
3710 RegDeleteValueA(propkey, "Version");
3711 RegDeleteValueA(propkey, "ProductIcon");
3712 RegDeleteValueA(propkey, "AuthorizedLUAApp");
3713 RegDeleteKeyA(propkey, "");
3714 RegDeleteKeyA(localkey, "");
3715 RegDeleteValueA(prodkey, "InstanceType");
3716 RegDeleteValueA(prodkey, "Transforms");
3717 RegDeleteValueA(prodkey, "Language");
3718 RegDeleteValueA(prodkey, "ProductName");
3719 RegDeleteValueA(prodkey, "Assignment");
3720 RegDeleteValueA(prodkey, "PackageCode");
3721 RegDeleteValueA(prodkey, "Version");
3722 RegDeleteValueA(prodkey, "ProductIcon");
3723 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
3724 RegDeleteValueA(source, "PackageName");
3725 RegDeleteKeyA(source, "");
3726 RegDeleteKeyA(prodkey, "");
3727 RegCloseKey(propkey);
3728 RegCloseKey(localkey);
3729 RegCloseKey(source);
3730 RegCloseKey(prodkey);
3733 static void test_MsiGetProductInfoEx(void)
3735 UINT r;
3736 LONG res;
3737 HKEY propkey, userkey;
3738 HKEY prodkey, localkey;
3739 CHAR prodcode[MAX_PATH];
3740 CHAR prod_squashed[MAX_PATH];
3741 CHAR packcode[MAX_PATH];
3742 CHAR pack_squashed[MAX_PATH];
3743 CHAR buf[MAX_PATH];
3744 CHAR keypath[MAX_PATH];
3745 LPSTR usersid;
3746 DWORD sz;
3748 if (!pMsiGetProductInfoExA)
3750 skip("MsiGetProductInfoExA is not available\n");
3751 return;
3754 create_test_guid(prodcode, prod_squashed);
3755 create_test_guid(packcode, pack_squashed);
3756 get_user_sid(&usersid);
3758 /* NULL szProductCode */
3759 sz = MAX_PATH;
3760 lstrcpyA(buf, "apple");
3761 r = pMsiGetProductInfoExA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3762 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3763 ok(r == ERROR_INVALID_PARAMETER,
3764 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3765 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3766 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3768 /* empty szProductCode */
3769 sz = MAX_PATH;
3770 lstrcpyA(buf, "apple");
3771 r = pMsiGetProductInfoExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3772 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3773 ok(r == ERROR_INVALID_PARAMETER,
3774 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3775 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3776 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3778 /* garbage szProductCode */
3779 sz = MAX_PATH;
3780 lstrcpyA(buf, "apple");
3781 r = pMsiGetProductInfoExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3782 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3783 ok(r == ERROR_INVALID_PARAMETER,
3784 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3785 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3786 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3788 /* guid without brackets */
3789 sz = MAX_PATH;
3790 lstrcpyA(buf, "apple");
3791 r = pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
3792 MSIINSTALLCONTEXT_USERUNMANAGED,
3793 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3794 ok(r == ERROR_INVALID_PARAMETER,
3795 "Expected ERROR_INVALID_PARAMETER, 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);
3799 /* guid with brackets */
3800 sz = MAX_PATH;
3801 lstrcpyA(buf, "apple");
3802 r = pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid,
3803 MSIINSTALLCONTEXT_USERUNMANAGED,
3804 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3805 ok(r == ERROR_UNKNOWN_PRODUCT,
3806 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3807 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3808 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3810 /* szValue is non-NULL while pcchValue is NULL */
3811 lstrcpyA(buf, "apple");
3812 r = pMsiGetProductInfoExA(prodcode, usersid,
3813 MSIINSTALLCONTEXT_USERUNMANAGED,
3814 INSTALLPROPERTY_PRODUCTSTATE, buf, NULL);
3815 ok(r == ERROR_INVALID_PARAMETER,
3816 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3817 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3819 /* dwContext is out of range */
3820 sz = MAX_PATH;
3821 lstrcpyA(buf, "apple");
3822 r = pMsiGetProductInfoExA(prodcode, usersid, 42,
3823 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3824 ok(r == ERROR_INVALID_PARAMETER,
3825 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3826 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3827 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3829 /* szProperty is NULL */
3830 sz = MAX_PATH;
3831 lstrcpyA(buf, "apple");
3832 r = pMsiGetProductInfoExA(prodcode, usersid,
3833 MSIINSTALLCONTEXT_USERUNMANAGED,
3834 NULL, buf, &sz);
3835 ok(r == ERROR_INVALID_PARAMETER,
3836 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3837 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3838 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3840 /* szProperty is empty */
3841 sz = MAX_PATH;
3842 lstrcpyA(buf, "apple");
3843 r = pMsiGetProductInfoExA(prodcode, usersid,
3844 MSIINSTALLCONTEXT_USERUNMANAGED,
3845 "", buf, &sz);
3846 ok(r == ERROR_INVALID_PARAMETER,
3847 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3848 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3849 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3851 /* szProperty is not a valid property */
3852 sz = MAX_PATH;
3853 lstrcpyA(buf, "apple");
3854 r = pMsiGetProductInfoExA(prodcode, usersid,
3855 MSIINSTALLCONTEXT_USERUNMANAGED,
3856 "notvalid", buf, &sz);
3857 ok(r == ERROR_UNKNOWN_PRODUCT,
3858 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3859 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3860 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3862 /* same length as guid, but random */
3863 sz = MAX_PATH;
3864 lstrcpyA(buf, "apple");
3865 r = pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid,
3866 MSIINSTALLCONTEXT_USERUNMANAGED,
3867 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3868 ok(r == ERROR_INVALID_PARAMETER,
3869 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3870 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3871 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3873 /* MSIINSTALLCONTEXT_USERUNMANAGED */
3875 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
3876 lstrcatA(keypath, usersid);
3877 lstrcatA(keypath, "\\Products\\");
3878 lstrcatA(keypath, prod_squashed);
3880 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
3881 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3883 /* local user product key exists */
3884 sz = MAX_PATH;
3885 lstrcpyA(buf, "apple");
3886 r = pMsiGetProductInfoExA(prodcode, usersid,
3887 MSIINSTALLCONTEXT_USERUNMANAGED,
3888 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3889 ok(r == ERROR_UNKNOWN_PRODUCT,
3890 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3891 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3892 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3894 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
3895 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3897 /* InstallProperties key exists */
3898 sz = MAX_PATH;
3899 lstrcpyA(buf, "apple");
3900 r = pMsiGetProductInfoExA(prodcode, usersid,
3901 MSIINSTALLCONTEXT_USERUNMANAGED,
3902 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3903 ok(r == ERROR_UNKNOWN_PRODUCT,
3904 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3905 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3906 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3908 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3909 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3911 /* LocalPackage value exists */
3912 sz = MAX_PATH;
3913 lstrcpyA(buf, "apple");
3914 r = pMsiGetProductInfoExA(prodcode, usersid,
3915 MSIINSTALLCONTEXT_USERUNMANAGED,
3916 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3917 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3918 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
3919 ok(sz == 1, "Expected 1, got %d\n", sz);
3921 RegDeleteValueA(propkey, "LocalPackage");
3923 /* LocalPackage value must exist */
3924 sz = MAX_PATH;
3925 lstrcpyA(buf, "apple");
3926 r = pMsiGetProductInfoExA(prodcode, usersid,
3927 MSIINSTALLCONTEXT_USERUNMANAGED,
3928 INSTALLPROPERTY_HELPLINK, buf, &sz);
3929 ok(r == ERROR_UNKNOWN_PRODUCT,
3930 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3931 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3932 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3934 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3935 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3937 /* LocalPackage exists, but HelpLink does not exist */
3938 sz = MAX_PATH;
3939 lstrcpyA(buf, "apple");
3940 r = pMsiGetProductInfoExA(prodcode, usersid,
3941 MSIINSTALLCONTEXT_USERUNMANAGED,
3942 INSTALLPROPERTY_HELPLINK, buf, &sz);
3943 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3944 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3945 ok(sz == 0, "Expected 0, got %d\n", sz);
3947 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
3948 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3950 /* HelpLink value exists */
3951 sz = MAX_PATH;
3952 lstrcpyA(buf, "apple");
3953 r = pMsiGetProductInfoExA(prodcode, usersid,
3954 MSIINSTALLCONTEXT_USERUNMANAGED,
3955 INSTALLPROPERTY_HELPLINK, buf, &sz);
3956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3957 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
3958 ok(sz == 4, "Expected 4, got %d\n", sz);
3960 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
3961 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3963 /* HelpTelephone value exists */
3964 sz = MAX_PATH;
3965 lstrcpyA(buf, "apple");
3966 r = pMsiGetProductInfoExA(prodcode, usersid,
3967 MSIINSTALLCONTEXT_USERUNMANAGED,
3968 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3970 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
3971 ok(sz == 5, "Expected 5, got %d\n", sz);
3973 /* szValue and pcchValue are NULL */
3974 r = pMsiGetProductInfoExA(prodcode, usersid,
3975 MSIINSTALLCONTEXT_USERUNMANAGED,
3976 INSTALLPROPERTY_HELPTELEPHONE, NULL, NULL);
3977 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3979 /* pcchValue is exactly 5 */
3980 sz = 5;
3981 lstrcpyA(buf, "apple");
3982 r = pMsiGetProductInfoExA(prodcode, usersid,
3983 MSIINSTALLCONTEXT_USERUNMANAGED,
3984 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3985 ok(r == ERROR_MORE_DATA,
3986 "Expected ERROR_MORE_DATA, got %d\n", r);
3987 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3988 ok(sz == 10, "Expected 10, got %d\n", sz);
3990 /* szValue is NULL, pcchValue is exactly 5 */
3991 sz = 5;
3992 r = pMsiGetProductInfoExA(prodcode, usersid,
3993 MSIINSTALLCONTEXT_USERUNMANAGED,
3994 INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
3995 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3996 ok(sz == 10, "Expected 10, got %d\n", sz);
3998 /* szValue is NULL, pcchValue is MAX_PATH */
3999 sz = MAX_PATH;
4000 r = pMsiGetProductInfoExA(prodcode, usersid,
4001 MSIINSTALLCONTEXT_USERUNMANAGED,
4002 INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
4003 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4004 ok(sz == 10, "Expected 10, got %d\n", sz);
4006 /* pcchValue is exactly 0 */
4007 sz = 0;
4008 lstrcpyA(buf, "apple");
4009 r = pMsiGetProductInfoExA(prodcode, usersid,
4010 MSIINSTALLCONTEXT_USERUNMANAGED,
4011 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4012 ok(r == ERROR_MORE_DATA,
4013 "Expected ERROR_MORE_DATA, got %d\n", r);
4014 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4015 ok(sz == 10, "Expected 10, got %d\n", sz);
4017 res = RegSetValueExA(propkey, "notvalid", 0, REG_SZ, (LPBYTE)"invalid", 8);
4018 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4020 /* szProperty is not a valid property */
4021 sz = MAX_PATH;
4022 lstrcpyA(buf, "apple");
4023 r = pMsiGetProductInfoExA(prodcode, usersid,
4024 MSIINSTALLCONTEXT_USERUNMANAGED,
4025 "notvalid", buf, &sz);
4026 ok(r == ERROR_UNKNOWN_PROPERTY,
4027 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4028 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4029 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4031 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4032 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4034 /* InstallDate value exists */
4035 sz = MAX_PATH;
4036 lstrcpyA(buf, "apple");
4037 r = pMsiGetProductInfoExA(prodcode, usersid,
4038 MSIINSTALLCONTEXT_USERUNMANAGED,
4039 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4040 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4041 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4042 ok(sz == 4, "Expected 4, got %d\n", sz);
4044 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4045 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4047 /* DisplayName value exists */
4048 sz = MAX_PATH;
4049 lstrcpyA(buf, "apple");
4050 r = pMsiGetProductInfoExA(prodcode, usersid,
4051 MSIINSTALLCONTEXT_USERUNMANAGED,
4052 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4053 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4054 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4055 ok(sz == 4, "Expected 4, got %d\n", sz);
4057 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4058 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4060 /* InstallLocation value exists */
4061 sz = MAX_PATH;
4062 lstrcpyA(buf, "apple");
4063 r = pMsiGetProductInfoExA(prodcode, usersid,
4064 MSIINSTALLCONTEXT_USERUNMANAGED,
4065 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4067 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4068 ok(sz == 3, "Expected 3, got %d\n", sz);
4070 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4071 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4073 /* InstallSource value exists */
4074 sz = MAX_PATH;
4075 lstrcpyA(buf, "apple");
4076 r = pMsiGetProductInfoExA(prodcode, usersid,
4077 MSIINSTALLCONTEXT_USERUNMANAGED,
4078 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4079 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4080 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4081 ok(sz == 6, "Expected 6, got %d\n", sz);
4083 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4084 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4086 /* LocalPackage value exists */
4087 sz = MAX_PATH;
4088 lstrcpyA(buf, "apple");
4089 r = pMsiGetProductInfoExA(prodcode, usersid,
4090 MSIINSTALLCONTEXT_USERUNMANAGED,
4091 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4092 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4093 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
4094 ok(sz == 5, "Expected 5, got %d\n", sz);
4096 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4097 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4099 /* Publisher value exists */
4100 sz = MAX_PATH;
4101 lstrcpyA(buf, "apple");
4102 r = pMsiGetProductInfoExA(prodcode, usersid,
4103 MSIINSTALLCONTEXT_USERUNMANAGED,
4104 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4105 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4106 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4107 ok(sz == 3, "Expected 3, got %d\n", sz);
4109 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4110 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4112 /* URLInfoAbout value exists */
4113 sz = MAX_PATH;
4114 lstrcpyA(buf, "apple");
4115 r = pMsiGetProductInfoExA(prodcode, usersid,
4116 MSIINSTALLCONTEXT_USERUNMANAGED,
4117 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4118 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4119 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4120 ok(sz == 5, "Expected 5, got %d\n", sz);
4122 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4123 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4125 /* URLUpdateInfo value exists */
4126 sz = MAX_PATH;
4127 lstrcpyA(buf, "apple");
4128 r = pMsiGetProductInfoExA(prodcode, usersid,
4129 MSIINSTALLCONTEXT_USERUNMANAGED,
4130 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4131 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4132 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
4133 ok(sz == 6, "Expected 6, got %d\n", sz);
4135 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4136 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4138 /* VersionMinor value exists */
4139 sz = MAX_PATH;
4140 lstrcpyA(buf, "apple");
4141 r = pMsiGetProductInfoExA(prodcode, usersid,
4142 MSIINSTALLCONTEXT_USERUNMANAGED,
4143 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4144 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4145 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
4146 ok(sz == 1, "Expected 1, got %d\n", sz);
4148 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4149 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4151 /* VersionMajor value exists */
4152 sz = MAX_PATH;
4153 lstrcpyA(buf, "apple");
4154 r = pMsiGetProductInfoExA(prodcode, usersid,
4155 MSIINSTALLCONTEXT_USERUNMANAGED,
4156 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4157 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4158 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
4159 ok(sz == 1, "Expected 1, got %d\n", sz);
4161 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4162 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4164 /* DisplayVersion value exists */
4165 sz = MAX_PATH;
4166 lstrcpyA(buf, "apple");
4167 r = pMsiGetProductInfoExA(prodcode, usersid,
4168 MSIINSTALLCONTEXT_USERUNMANAGED,
4169 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4170 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4171 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
4172 ok(sz == 5, "Expected 5, got %d\n", sz);
4174 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4175 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4177 /* ProductID value exists */
4178 sz = MAX_PATH;
4179 lstrcpyA(buf, "apple");
4180 r = pMsiGetProductInfoExA(prodcode, usersid,
4181 MSIINSTALLCONTEXT_USERUNMANAGED,
4182 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4184 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
4185 ok(sz == 2, "Expected 2, got %d\n", sz);
4187 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4188 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4190 /* RegCompany value exists */
4191 sz = MAX_PATH;
4192 lstrcpyA(buf, "apple");
4193 r = pMsiGetProductInfoExA(prodcode, usersid,
4194 MSIINSTALLCONTEXT_USERUNMANAGED,
4195 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4196 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4197 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
4198 ok(sz == 4, "Expected 4, got %d\n", sz);
4200 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4201 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4203 /* RegOwner value exists */
4204 sz = MAX_PATH;
4205 lstrcpyA(buf, "apple");
4206 r = pMsiGetProductInfoExA(prodcode, usersid,
4207 MSIINSTALLCONTEXT_USERUNMANAGED,
4208 INSTALLPROPERTY_REGOWNER, buf, &sz);
4209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4210 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
4211 ok(sz == 5, "Expected 5, got %d\n", sz);
4213 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4214 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4216 /* Transforms value exists */
4217 sz = MAX_PATH;
4218 lstrcpyA(buf, "apple");
4219 r = pMsiGetProductInfoExA(prodcode, usersid,
4220 MSIINSTALLCONTEXT_USERUNMANAGED,
4221 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4222 ok(r == ERROR_UNKNOWN_PRODUCT,
4223 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4224 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4225 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4227 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4228 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4230 /* Language value exists */
4231 sz = MAX_PATH;
4232 lstrcpyA(buf, "apple");
4233 r = pMsiGetProductInfoExA(prodcode, usersid,
4234 MSIINSTALLCONTEXT_USERUNMANAGED,
4235 INSTALLPROPERTY_LANGUAGE, buf, &sz);
4236 ok(r == ERROR_UNKNOWN_PRODUCT,
4237 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4238 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4239 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4241 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4242 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4244 /* ProductName value exists */
4245 sz = MAX_PATH;
4246 lstrcpyA(buf, "apple");
4247 r = pMsiGetProductInfoExA(prodcode, usersid,
4248 MSIINSTALLCONTEXT_USERUNMANAGED,
4249 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4250 ok(r == ERROR_UNKNOWN_PRODUCT,
4251 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4252 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4253 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4255 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4256 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4258 /* FIXME */
4260 /* AssignmentType value exists */
4261 sz = MAX_PATH;
4262 lstrcpyA(buf, "apple");
4263 r = pMsiGetProductInfoExA(prodcode, usersid,
4264 MSIINSTALLCONTEXT_USERUNMANAGED,
4265 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4266 ok(r == ERROR_UNKNOWN_PRODUCT,
4267 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4268 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4269 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4271 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4272 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4274 /* PackageCode value exists */
4275 sz = MAX_PATH;
4276 lstrcpyA(buf, "apple");
4277 r = pMsiGetProductInfoExA(prodcode, usersid,
4278 MSIINSTALLCONTEXT_USERUNMANAGED,
4279 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4280 ok(r == ERROR_UNKNOWN_PRODUCT,
4281 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4282 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4283 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4285 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4286 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4288 /* Version value exists */
4289 sz = MAX_PATH;
4290 lstrcpyA(buf, "apple");
4291 r = pMsiGetProductInfoExA(prodcode, usersid,
4292 MSIINSTALLCONTEXT_USERUNMANAGED,
4293 INSTALLPROPERTY_VERSION, buf, &sz);
4294 ok(r == ERROR_UNKNOWN_PRODUCT,
4295 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4296 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4297 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4299 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4300 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4302 /* ProductIcon value exists */
4303 sz = MAX_PATH;
4304 lstrcpyA(buf, "apple");
4305 r = pMsiGetProductInfoExA(prodcode, usersid,
4306 MSIINSTALLCONTEXT_USERUNMANAGED,
4307 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4308 ok(r == ERROR_UNKNOWN_PRODUCT,
4309 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4310 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4311 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4313 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4314 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4316 /* PackageName value exists */
4317 sz = MAX_PATH;
4318 lstrcpyA(buf, "apple");
4319 r = pMsiGetProductInfoExA(prodcode, usersid,
4320 MSIINSTALLCONTEXT_USERUNMANAGED,
4321 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4322 ok(r == ERROR_UNKNOWN_PRODUCT,
4323 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4324 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4325 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4327 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4328 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4330 /* AuthorizedLUAApp value exists */
4331 sz = MAX_PATH;
4332 lstrcpyA(buf, "apple");
4333 r = pMsiGetProductInfoExA(prodcode, usersid,
4334 MSIINSTALLCONTEXT_USERUNMANAGED,
4335 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4336 ok(r == ERROR_UNKNOWN_PRODUCT,
4337 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4338 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4339 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4341 RegDeleteValueA(propkey, "AuthorizedLUAApp");
4342 RegDeleteValueA(propkey, "PackageName");
4343 RegDeleteValueA(propkey, "ProductIcon");
4344 RegDeleteValueA(propkey, "Version");
4345 RegDeleteValueA(propkey, "PackageCode");
4346 RegDeleteValueA(propkey, "AssignmentType");
4347 RegDeleteValueA(propkey, "ProductName");
4348 RegDeleteValueA(propkey, "Language");
4349 RegDeleteValueA(propkey, "Transforms");
4350 RegDeleteValueA(propkey, "RegOwner");
4351 RegDeleteValueA(propkey, "RegCompany");
4352 RegDeleteValueA(propkey, "ProductID");
4353 RegDeleteValueA(propkey, "DisplayVersion");
4354 RegDeleteValueA(propkey, "VersionMajor");
4355 RegDeleteValueA(propkey, "VersionMinor");
4356 RegDeleteValueA(propkey, "URLUpdateInfo");
4357 RegDeleteValueA(propkey, "URLInfoAbout");
4358 RegDeleteValueA(propkey, "Publisher");
4359 RegDeleteValueA(propkey, "LocalPackage");
4360 RegDeleteValueA(propkey, "InstallSource");
4361 RegDeleteValueA(propkey, "InstallLocation");
4362 RegDeleteValueA(propkey, "DisplayName");
4363 RegDeleteValueA(propkey, "InstallDate");
4364 RegDeleteValueA(propkey, "HelpTelephone");
4365 RegDeleteValueA(propkey, "HelpLink");
4366 RegDeleteValueA(propkey, "LocalPackage");
4367 RegDeleteKeyA(propkey, "");
4368 RegCloseKey(propkey);
4369 RegDeleteKeyA(localkey, "");
4370 RegCloseKey(localkey);
4372 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4373 lstrcatA(keypath, usersid);
4374 lstrcatA(keypath, "\\Installer\\Products\\");
4375 lstrcatA(keypath, prod_squashed);
4377 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
4378 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4380 /* user product key exists */
4381 sz = MAX_PATH;
4382 lstrcpyA(buf, "apple");
4383 r = pMsiGetProductInfoExA(prodcode, usersid,
4384 MSIINSTALLCONTEXT_USERUNMANAGED,
4385 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4386 ok(r == ERROR_UNKNOWN_PRODUCT,
4387 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4388 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4389 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4391 RegDeleteKeyA(userkey, "");
4392 RegCloseKey(userkey);
4394 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
4395 lstrcatA(keypath, prod_squashed);
4397 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
4398 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4400 sz = MAX_PATH;
4401 lstrcpyA(buf, "apple");
4402 r = pMsiGetProductInfoExA(prodcode, usersid,
4403 MSIINSTALLCONTEXT_USERUNMANAGED,
4404 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4406 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
4407 ok(sz == 1, "Expected 1, got %d\n", sz);
4409 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4410 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4412 /* HelpLink value exists */
4413 sz = MAX_PATH;
4414 lstrcpyA(buf, "apple");
4415 r = pMsiGetProductInfoExA(prodcode, usersid,
4416 MSIINSTALLCONTEXT_USERUNMANAGED,
4417 INSTALLPROPERTY_HELPLINK, buf, &sz);
4418 ok(r == ERROR_UNKNOWN_PROPERTY,
4419 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4420 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4421 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4423 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4424 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4426 /* HelpTelephone value exists */
4427 sz = MAX_PATH;
4428 lstrcpyA(buf, "apple");
4429 r = pMsiGetProductInfoExA(prodcode, usersid,
4430 MSIINSTALLCONTEXT_USERUNMANAGED,
4431 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4432 ok(r == ERROR_UNKNOWN_PROPERTY,
4433 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4434 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4435 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4437 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4438 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4440 /* InstallDate value exists */
4441 sz = MAX_PATH;
4442 lstrcpyA(buf, "apple");
4443 r = pMsiGetProductInfoExA(prodcode, usersid,
4444 MSIINSTALLCONTEXT_USERUNMANAGED,
4445 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4446 ok(r == ERROR_UNKNOWN_PROPERTY,
4447 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4448 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4449 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4451 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4452 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4454 /* DisplayName value exists */
4455 sz = MAX_PATH;
4456 lstrcpyA(buf, "apple");
4457 r = pMsiGetProductInfoExA(prodcode, usersid,
4458 MSIINSTALLCONTEXT_USERUNMANAGED,
4459 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4460 ok(r == ERROR_UNKNOWN_PROPERTY,
4461 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4462 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4463 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4465 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4466 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4468 /* InstallLocation value exists */
4469 sz = MAX_PATH;
4470 lstrcpyA(buf, "apple");
4471 r = pMsiGetProductInfoExA(prodcode, usersid,
4472 MSIINSTALLCONTEXT_USERUNMANAGED,
4473 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4474 ok(r == ERROR_UNKNOWN_PROPERTY,
4475 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4476 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4477 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4479 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4480 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4482 /* InstallSource value exists */
4483 sz = MAX_PATH;
4484 lstrcpyA(buf, "apple");
4485 r = pMsiGetProductInfoExA(prodcode, usersid,
4486 MSIINSTALLCONTEXT_USERUNMANAGED,
4487 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4488 ok(r == ERROR_UNKNOWN_PROPERTY,
4489 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4490 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4491 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4493 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4494 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4496 /* LocalPackage value exists */
4497 sz = MAX_PATH;
4498 lstrcpyA(buf, "apple");
4499 r = pMsiGetProductInfoExA(prodcode, usersid,
4500 MSIINSTALLCONTEXT_USERUNMANAGED,
4501 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4502 ok(r == ERROR_UNKNOWN_PROPERTY,
4503 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4504 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4505 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4507 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4508 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4510 /* Publisher value exists */
4511 sz = MAX_PATH;
4512 lstrcpyA(buf, "apple");
4513 r = pMsiGetProductInfoExA(prodcode, usersid,
4514 MSIINSTALLCONTEXT_USERUNMANAGED,
4515 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4516 ok(r == ERROR_UNKNOWN_PROPERTY,
4517 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4518 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4519 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4521 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4522 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4524 /* URLInfoAbout value exists */
4525 sz = MAX_PATH;
4526 lstrcpyA(buf, "apple");
4527 r = pMsiGetProductInfoExA(prodcode, usersid,
4528 MSIINSTALLCONTEXT_USERUNMANAGED,
4529 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4530 ok(r == ERROR_UNKNOWN_PROPERTY,
4531 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4532 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4533 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4535 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4536 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4538 /* URLUpdateInfo value exists */
4539 sz = MAX_PATH;
4540 lstrcpyA(buf, "apple");
4541 r = pMsiGetProductInfoExA(prodcode, usersid,
4542 MSIINSTALLCONTEXT_USERUNMANAGED,
4543 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4544 ok(r == ERROR_UNKNOWN_PROPERTY,
4545 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4546 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4547 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4549 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4550 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4552 /* VersionMinor value exists */
4553 sz = MAX_PATH;
4554 lstrcpyA(buf, "apple");
4555 r = pMsiGetProductInfoExA(prodcode, usersid,
4556 MSIINSTALLCONTEXT_USERUNMANAGED,
4557 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4558 ok(r == ERROR_UNKNOWN_PROPERTY,
4559 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4560 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4561 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4563 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4564 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4566 /* VersionMajor value exists */
4567 sz = MAX_PATH;
4568 lstrcpyA(buf, "apple");
4569 r = pMsiGetProductInfoExA(prodcode, usersid,
4570 MSIINSTALLCONTEXT_USERUNMANAGED,
4571 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4572 ok(r == ERROR_UNKNOWN_PROPERTY,
4573 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4574 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4575 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4577 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4578 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4580 /* DisplayVersion value exists */
4581 sz = MAX_PATH;
4582 lstrcpyA(buf, "apple");
4583 r = pMsiGetProductInfoExA(prodcode, usersid,
4584 MSIINSTALLCONTEXT_USERUNMANAGED,
4585 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4586 ok(r == ERROR_UNKNOWN_PROPERTY,
4587 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4588 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4589 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4591 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4592 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4594 /* ProductID value exists */
4595 sz = MAX_PATH;
4596 lstrcpyA(buf, "apple");
4597 r = pMsiGetProductInfoExA(prodcode, usersid,
4598 MSIINSTALLCONTEXT_USERUNMANAGED,
4599 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4600 ok(r == ERROR_UNKNOWN_PROPERTY,
4601 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4602 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4603 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4605 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4606 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4608 /* RegCompany value exists */
4609 sz = MAX_PATH;
4610 lstrcpyA(buf, "apple");
4611 r = pMsiGetProductInfoExA(prodcode, usersid,
4612 MSIINSTALLCONTEXT_USERUNMANAGED,
4613 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4614 ok(r == ERROR_UNKNOWN_PROPERTY,
4615 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4616 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4617 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4619 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4620 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4622 /* RegOwner value exists */
4623 sz = MAX_PATH;
4624 lstrcpyA(buf, "apple");
4625 r = pMsiGetProductInfoExA(prodcode, usersid,
4626 MSIINSTALLCONTEXT_USERUNMANAGED,
4627 INSTALLPROPERTY_REGOWNER, buf, &sz);
4628 ok(r == ERROR_UNKNOWN_PROPERTY,
4629 "Expected ERROR_UNKNOWN_PROPERTY, 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);
4633 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4634 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4636 /* Transforms value exists */
4637 sz = MAX_PATH;
4638 lstrcpyA(buf, "apple");
4639 r = pMsiGetProductInfoExA(prodcode, usersid,
4640 MSIINSTALLCONTEXT_USERUNMANAGED,
4641 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4642 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4643 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
4644 ok(sz == 5, "Expected 5, got %d\n", sz);
4646 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4647 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4649 /* Language value exists */
4650 sz = MAX_PATH;
4651 lstrcpyA(buf, "apple");
4652 r = pMsiGetProductInfoExA(prodcode, usersid,
4653 MSIINSTALLCONTEXT_USERUNMANAGED,
4654 INSTALLPROPERTY_LANGUAGE, buf, &sz);
4655 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4656 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
4657 ok(sz == 4, "Expected 4, got %d\n", sz);
4659 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4660 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4662 /* ProductName value exists */
4663 sz = MAX_PATH;
4664 lstrcpyA(buf, "apple");
4665 r = pMsiGetProductInfoExA(prodcode, usersid,
4666 MSIINSTALLCONTEXT_USERUNMANAGED,
4667 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4668 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4669 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4670 ok(sz == 4, "Expected 4, got %d\n", sz);
4672 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4673 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4675 /* FIXME */
4677 /* AssignmentType value exists */
4678 sz = MAX_PATH;
4679 lstrcpyA(buf, "apple");
4680 r = pMsiGetProductInfoExA(prodcode, usersid,
4681 MSIINSTALLCONTEXT_USERUNMANAGED,
4682 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4683 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4684 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4685 ok(sz == 0, "Expected 0, got %d\n", sz);
4687 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4688 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4690 /* FIXME */
4692 /* PackageCode value exists */
4693 sz = MAX_PATH;
4694 lstrcpyA(buf, "apple");
4695 r = pMsiGetProductInfoExA(prodcode, usersid,
4696 MSIINSTALLCONTEXT_USERUNMANAGED,
4697 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4698 todo_wine
4700 ok(r == ERROR_BAD_CONFIGURATION,
4701 "Expected ERROR_BAD_CONFIGURATION, 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);
4706 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4707 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4709 /* Version value exists */
4710 sz = MAX_PATH;
4711 lstrcpyA(buf, "apple");
4712 r = pMsiGetProductInfoExA(prodcode, usersid,
4713 MSIINSTALLCONTEXT_USERUNMANAGED,
4714 INSTALLPROPERTY_VERSION, buf, &sz);
4715 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4716 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
4717 ok(sz == 3, "Expected 3, got %d\n", sz);
4719 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4720 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4722 /* ProductIcon value exists */
4723 sz = MAX_PATH;
4724 lstrcpyA(buf, "apple");
4725 r = pMsiGetProductInfoExA(prodcode, usersid,
4726 MSIINSTALLCONTEXT_USERUNMANAGED,
4727 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4729 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
4730 ok(sz == 4, "Expected 4, got %d\n", sz);
4732 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4733 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4735 /* PackageName value exists */
4736 sz = MAX_PATH;
4737 lstrcpyA(buf, "apple");
4738 r = pMsiGetProductInfoExA(prodcode, usersid,
4739 MSIINSTALLCONTEXT_USERUNMANAGED,
4740 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4741 todo_wine
4743 ok(r == ERROR_UNKNOWN_PRODUCT,
4744 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4745 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4746 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4749 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4750 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4752 /* AuthorizedLUAApp value exists */
4753 sz = MAX_PATH;
4754 lstrcpyA(buf, "apple");
4755 r = pMsiGetProductInfoExA(prodcode, usersid,
4756 MSIINSTALLCONTEXT_USERUNMANAGED,
4757 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4758 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4759 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
4760 ok(sz == 4, "Expected 4, got %d\n", sz);
4762 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
4763 RegDeleteValueA(prodkey, "PackageName");
4764 RegDeleteValueA(prodkey, "ProductIcon");
4765 RegDeleteValueA(prodkey, "Version");
4766 RegDeleteValueA(prodkey, "PackageCode");
4767 RegDeleteValueA(prodkey, "AssignmentType");
4768 RegDeleteValueA(prodkey, "ProductName");
4769 RegDeleteValueA(prodkey, "Language");
4770 RegDeleteValueA(prodkey, "Transforms");
4771 RegDeleteValueA(prodkey, "RegOwner");
4772 RegDeleteValueA(prodkey, "RegCompany");
4773 RegDeleteValueA(prodkey, "ProductID");
4774 RegDeleteValueA(prodkey, "DisplayVersion");
4775 RegDeleteValueA(prodkey, "VersionMajor");
4776 RegDeleteValueA(prodkey, "VersionMinor");
4777 RegDeleteValueA(prodkey, "URLUpdateInfo");
4778 RegDeleteValueA(prodkey, "URLInfoAbout");
4779 RegDeleteValueA(prodkey, "Publisher");
4780 RegDeleteValueA(prodkey, "LocalPackage");
4781 RegDeleteValueA(prodkey, "InstallSource");
4782 RegDeleteValueA(prodkey, "InstallLocation");
4783 RegDeleteValueA(prodkey, "DisplayName");
4784 RegDeleteValueA(prodkey, "InstallDate");
4785 RegDeleteValueA(prodkey, "HelpTelephone");
4786 RegDeleteValueA(prodkey, "HelpLink");
4787 RegDeleteValueA(prodkey, "LocalPackage");
4788 RegDeleteKeyA(prodkey, "");
4789 RegCloseKey(prodkey);
4791 /* MSIINSTALLCONTEXT_USERMANAGED */
4793 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4794 lstrcatA(keypath, usersid);
4795 lstrcatA(keypath, "\\Products\\");
4796 lstrcatA(keypath, prod_squashed);
4798 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
4799 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4801 /* local user product key exists */
4802 sz = MAX_PATH;
4803 lstrcpyA(buf, "apple");
4804 r = pMsiGetProductInfoExA(prodcode, usersid,
4805 MSIINSTALLCONTEXT_USERMANAGED,
4806 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4807 ok(r == ERROR_UNKNOWN_PRODUCT,
4808 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4809 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4810 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4812 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
4813 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4815 /* InstallProperties key exists */
4816 sz = MAX_PATH;
4817 lstrcpyA(buf, "apple");
4818 r = pMsiGetProductInfoExA(prodcode, usersid,
4819 MSIINSTALLCONTEXT_USERMANAGED,
4820 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4821 ok(r == ERROR_UNKNOWN_PRODUCT,
4822 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4823 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4824 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4826 res = RegSetValueExA(propkey, "ManagedLocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4827 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4829 /* ManagedLocalPackage value exists */
4830 sz = MAX_PATH;
4831 lstrcpyA(buf, "apple");
4832 r = pMsiGetProductInfoExA(prodcode, usersid,
4833 MSIINSTALLCONTEXT_USERMANAGED,
4834 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4836 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
4837 ok(sz == 1, "Expected 1, got %d\n", sz);
4839 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4840 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4842 /* HelpLink value exists */
4843 sz = MAX_PATH;
4844 lstrcpyA(buf, "apple");
4845 r = pMsiGetProductInfoExA(prodcode, usersid,
4846 MSIINSTALLCONTEXT_USERMANAGED,
4847 INSTALLPROPERTY_HELPLINK, buf, &sz);
4848 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4849 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4850 ok(sz == 4, "Expected 4, got %d\n", sz);
4852 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4853 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
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_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4862 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
4863 ok(sz == 5, "Expected 5, got %d\n", sz);
4865 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4866 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4868 /* InstallDate value exists */
4869 sz = MAX_PATH;
4870 lstrcpyA(buf, "apple");
4871 r = pMsiGetProductInfoExA(prodcode, usersid,
4872 MSIINSTALLCONTEXT_USERMANAGED,
4873 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4874 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4875 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4876 ok(sz == 4, "Expected 4, got %d\n", sz);
4878 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4879 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4881 /* DisplayName value exists */
4882 sz = MAX_PATH;
4883 lstrcpyA(buf, "apple");
4884 r = pMsiGetProductInfoExA(prodcode, usersid,
4885 MSIINSTALLCONTEXT_USERMANAGED,
4886 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4887 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4888 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4889 ok(sz == 4, "Expected 4, got %d\n", sz);
4891 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4892 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4894 /* InstallLocation value exists */
4895 sz = MAX_PATH;
4896 lstrcpyA(buf, "apple");
4897 r = pMsiGetProductInfoExA(prodcode, usersid,
4898 MSIINSTALLCONTEXT_USERMANAGED,
4899 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4900 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4901 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4902 ok(sz == 3, "Expected 3, got %d\n", sz);
4904 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4905 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4907 /* InstallSource value exists */
4908 sz = MAX_PATH;
4909 lstrcpyA(buf, "apple");
4910 r = pMsiGetProductInfoExA(prodcode, usersid,
4911 MSIINSTALLCONTEXT_USERMANAGED,
4912 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4913 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4914 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4915 ok(sz == 6, "Expected 6, got %d\n", sz);
4917 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4918 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4920 /* LocalPackage value exists */
4921 sz = MAX_PATH;
4922 lstrcpyA(buf, "apple");
4923 r = pMsiGetProductInfoExA(prodcode, usersid,
4924 MSIINSTALLCONTEXT_USERMANAGED,
4925 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4927 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
4928 ok(sz == 5, "Expected 5, got %d\n", sz);
4930 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4931 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4933 /* Publisher value exists */
4934 sz = MAX_PATH;
4935 lstrcpyA(buf, "apple");
4936 r = pMsiGetProductInfoExA(prodcode, usersid,
4937 MSIINSTALLCONTEXT_USERMANAGED,
4938 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4939 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4940 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4941 ok(sz == 3, "Expected 3, got %d\n", sz);
4943 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4944 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4946 /* URLInfoAbout value exists */
4947 sz = MAX_PATH;
4948 lstrcpyA(buf, "apple");
4949 r = pMsiGetProductInfoExA(prodcode, usersid,
4950 MSIINSTALLCONTEXT_USERMANAGED,
4951 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4952 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4953 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4954 ok(sz == 5, "Expected 5, got %d\n", sz);
4956 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4957 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4959 /* URLUpdateInfo value exists */
4960 sz = MAX_PATH;
4961 lstrcpyA(buf, "apple");
4962 r = pMsiGetProductInfoExA(prodcode, usersid,
4963 MSIINSTALLCONTEXT_USERMANAGED,
4964 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4965 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4966 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
4967 ok(sz == 6, "Expected 6, got %d\n", sz);
4969 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4970 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4972 /* VersionMinor value exists */
4973 sz = MAX_PATH;
4974 lstrcpyA(buf, "apple");
4975 r = pMsiGetProductInfoExA(prodcode, usersid,
4976 MSIINSTALLCONTEXT_USERMANAGED,
4977 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4978 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4979 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
4980 ok(sz == 1, "Expected 1, got %d\n", sz);
4982 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4983 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4985 /* VersionMajor value exists */
4986 sz = MAX_PATH;
4987 lstrcpyA(buf, "apple");
4988 r = pMsiGetProductInfoExA(prodcode, usersid,
4989 MSIINSTALLCONTEXT_USERMANAGED,
4990 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4991 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4992 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
4993 ok(sz == 1, "Expected 1, got %d\n", sz);
4995 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4996 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4998 /* DisplayVersion value exists */
4999 sz = MAX_PATH;
5000 lstrcpyA(buf, "apple");
5001 r = pMsiGetProductInfoExA(prodcode, usersid,
5002 MSIINSTALLCONTEXT_USERMANAGED,
5003 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5004 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5005 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
5006 ok(sz == 5, "Expected 5, got %d\n", sz);
5008 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5009 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5011 /* ProductID value exists */
5012 sz = MAX_PATH;
5013 lstrcpyA(buf, "apple");
5014 r = pMsiGetProductInfoExA(prodcode, usersid,
5015 MSIINSTALLCONTEXT_USERMANAGED,
5016 INSTALLPROPERTY_PRODUCTID, buf, &sz);
5017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5018 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
5019 ok(sz == 2, "Expected 2, got %d\n", sz);
5021 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5022 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5024 /* RegCompany value exists */
5025 sz = MAX_PATH;
5026 lstrcpyA(buf, "apple");
5027 r = pMsiGetProductInfoExA(prodcode, usersid,
5028 MSIINSTALLCONTEXT_USERMANAGED,
5029 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5030 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5031 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
5032 ok(sz == 4, "Expected 4, got %d\n", sz);
5034 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5035 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5037 /* RegOwner value exists */
5038 sz = MAX_PATH;
5039 lstrcpyA(buf, "apple");
5040 r = pMsiGetProductInfoExA(prodcode, usersid,
5041 MSIINSTALLCONTEXT_USERMANAGED,
5042 INSTALLPROPERTY_REGOWNER, buf, &sz);
5043 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5044 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
5045 ok(sz == 5, "Expected 5, got %d\n", sz);
5047 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5048 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5050 /* Transforms value exists */
5051 sz = MAX_PATH;
5052 lstrcpyA(buf, "apple");
5053 r = pMsiGetProductInfoExA(prodcode, usersid,
5054 MSIINSTALLCONTEXT_USERMANAGED,
5055 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5056 ok(r == ERROR_UNKNOWN_PRODUCT,
5057 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5058 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5059 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5061 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5062 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5064 /* Language value exists */
5065 sz = MAX_PATH;
5066 lstrcpyA(buf, "apple");
5067 r = pMsiGetProductInfoExA(prodcode, usersid,
5068 MSIINSTALLCONTEXT_USERMANAGED,
5069 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5070 ok(r == ERROR_UNKNOWN_PRODUCT,
5071 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5072 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5073 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5075 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5076 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5078 /* ProductName value exists */
5079 sz = MAX_PATH;
5080 lstrcpyA(buf, "apple");
5081 r = pMsiGetProductInfoExA(prodcode, usersid,
5082 MSIINSTALLCONTEXT_USERMANAGED,
5083 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5084 ok(r == ERROR_UNKNOWN_PRODUCT,
5085 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5086 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5087 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5089 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5090 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5092 /* FIXME */
5094 /* AssignmentType value exists */
5095 sz = MAX_PATH;
5096 lstrcpyA(buf, "apple");
5097 r = pMsiGetProductInfoExA(prodcode, usersid,
5098 MSIINSTALLCONTEXT_USERMANAGED,
5099 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5100 ok(r == ERROR_UNKNOWN_PRODUCT,
5101 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5102 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5103 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5105 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5106 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5108 /* PackageCode value exists */
5109 sz = MAX_PATH;
5110 lstrcpyA(buf, "apple");
5111 r = pMsiGetProductInfoExA(prodcode, usersid,
5112 MSIINSTALLCONTEXT_USERMANAGED,
5113 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5114 ok(r == ERROR_UNKNOWN_PRODUCT,
5115 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5116 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5117 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5119 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5120 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5122 /* Version value exists */
5123 sz = MAX_PATH;
5124 lstrcpyA(buf, "apple");
5125 r = pMsiGetProductInfoExA(prodcode, usersid,
5126 MSIINSTALLCONTEXT_USERMANAGED,
5127 INSTALLPROPERTY_VERSION, buf, &sz);
5128 ok(r == ERROR_UNKNOWN_PRODUCT,
5129 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5130 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5131 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5133 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5134 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5136 /* ProductIcon value exists */
5137 sz = MAX_PATH;
5138 lstrcpyA(buf, "apple");
5139 r = pMsiGetProductInfoExA(prodcode, usersid,
5140 MSIINSTALLCONTEXT_USERMANAGED,
5141 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5142 ok(r == ERROR_UNKNOWN_PRODUCT,
5143 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5144 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5145 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5147 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5148 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5150 /* PackageName value exists */
5151 sz = MAX_PATH;
5152 lstrcpyA(buf, "apple");
5153 r = pMsiGetProductInfoExA(prodcode, usersid,
5154 MSIINSTALLCONTEXT_USERMANAGED,
5155 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5156 ok(r == ERROR_UNKNOWN_PRODUCT,
5157 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5158 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5159 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5161 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5162 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5164 /* AuthorizedLUAApp value exists */
5165 sz = MAX_PATH;
5166 lstrcpyA(buf, "apple");
5167 r = pMsiGetProductInfoExA(prodcode, usersid,
5168 MSIINSTALLCONTEXT_USERMANAGED,
5169 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5170 ok(r == ERROR_UNKNOWN_PRODUCT,
5171 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5172 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5173 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5175 RegDeleteValueA(propkey, "AuthorizedLUAApp");
5176 RegDeleteValueA(propkey, "PackageName");
5177 RegDeleteValueA(propkey, "ProductIcon");
5178 RegDeleteValueA(propkey, "Version");
5179 RegDeleteValueA(propkey, "PackageCode");
5180 RegDeleteValueA(propkey, "AssignmentType");
5181 RegDeleteValueA(propkey, "ProductName");
5182 RegDeleteValueA(propkey, "Language");
5183 RegDeleteValueA(propkey, "Transforms");
5184 RegDeleteValueA(propkey, "RegOwner");
5185 RegDeleteValueA(propkey, "RegCompany");
5186 RegDeleteValueA(propkey, "ProductID");
5187 RegDeleteValueA(propkey, "DisplayVersion");
5188 RegDeleteValueA(propkey, "VersionMajor");
5189 RegDeleteValueA(propkey, "VersionMinor");
5190 RegDeleteValueA(propkey, "URLUpdateInfo");
5191 RegDeleteValueA(propkey, "URLInfoAbout");
5192 RegDeleteValueA(propkey, "Publisher");
5193 RegDeleteValueA(propkey, "LocalPackage");
5194 RegDeleteValueA(propkey, "InstallSource");
5195 RegDeleteValueA(propkey, "InstallLocation");
5196 RegDeleteValueA(propkey, "DisplayName");
5197 RegDeleteValueA(propkey, "InstallDate");
5198 RegDeleteValueA(propkey, "HelpTelephone");
5199 RegDeleteValueA(propkey, "HelpLink");
5200 RegDeleteValueA(propkey, "ManagedLocalPackage");
5201 RegDeleteKeyA(propkey, "");
5202 RegCloseKey(propkey);
5203 RegDeleteKeyA(localkey, "");
5204 RegCloseKey(localkey);
5206 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
5207 lstrcatA(keypath, usersid);
5208 lstrcatA(keypath, "\\Installer\\Products\\");
5209 lstrcatA(keypath, prod_squashed);
5211 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
5212 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5214 /* user product key exists */
5215 sz = MAX_PATH;
5216 lstrcpyA(buf, "apple");
5217 r = pMsiGetProductInfoExA(prodcode, usersid,
5218 MSIINSTALLCONTEXT_USERMANAGED,
5219 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5220 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5221 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
5222 ok(sz == 1, "Expected 1, got %d\n", sz);
5224 RegDeleteKeyA(userkey, "");
5225 RegCloseKey(userkey);
5227 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
5228 lstrcatA(keypath, prod_squashed);
5230 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
5231 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5233 /* current user product key exists */
5234 sz = MAX_PATH;
5235 lstrcpyA(buf, "apple");
5236 r = pMsiGetProductInfoExA(prodcode, usersid,
5237 MSIINSTALLCONTEXT_USERMANAGED,
5238 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5239 ok(r == ERROR_UNKNOWN_PRODUCT,
5240 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5241 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5242 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5244 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5245 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5247 /* HelpLink value exists, user product key does not exist */
5248 sz = MAX_PATH;
5249 lstrcpyA(buf, "apple");
5250 r = pMsiGetProductInfoExA(prodcode, usersid,
5251 MSIINSTALLCONTEXT_USERMANAGED,
5252 INSTALLPROPERTY_HELPLINK, buf, &sz);
5253 ok(r == ERROR_UNKNOWN_PRODUCT,
5254 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5255 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5256 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5258 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
5259 lstrcatA(keypath, usersid);
5260 lstrcatA(keypath, "\\Installer\\Products\\");
5261 lstrcatA(keypath, prod_squashed);
5263 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
5264 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5266 res = RegSetValueExA(userkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5267 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5269 /* HelpLink value exists, user product key does exist */
5270 sz = MAX_PATH;
5271 lstrcpyA(buf, "apple");
5272 r = pMsiGetProductInfoExA(prodcode, usersid,
5273 MSIINSTALLCONTEXT_USERMANAGED,
5274 INSTALLPROPERTY_HELPLINK, buf, &sz);
5275 ok(r == ERROR_UNKNOWN_PROPERTY,
5276 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5277 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5278 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5280 res = RegSetValueExA(userkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5283 /* HelpTelephone value exists */
5284 sz = MAX_PATH;
5285 lstrcpyA(buf, "apple");
5286 r = pMsiGetProductInfoExA(prodcode, usersid,
5287 MSIINSTALLCONTEXT_USERMANAGED,
5288 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5289 ok(r == ERROR_UNKNOWN_PROPERTY,
5290 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5291 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5292 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5294 res = RegSetValueExA(userkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5295 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5297 /* InstallDate value exists */
5298 sz = MAX_PATH;
5299 lstrcpyA(buf, "apple");
5300 r = pMsiGetProductInfoExA(prodcode, usersid,
5301 MSIINSTALLCONTEXT_USERMANAGED,
5302 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5303 ok(r == ERROR_UNKNOWN_PROPERTY,
5304 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5305 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5306 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5308 res = RegSetValueExA(userkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5309 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5311 /* DisplayName value exists */
5312 sz = MAX_PATH;
5313 lstrcpyA(buf, "apple");
5314 r = pMsiGetProductInfoExA(prodcode, usersid,
5315 MSIINSTALLCONTEXT_USERMANAGED,
5316 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5317 ok(r == ERROR_UNKNOWN_PROPERTY,
5318 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5319 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5320 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5322 res = RegSetValueExA(userkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5323 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5325 /* InstallLocation value exists */
5326 sz = MAX_PATH;
5327 lstrcpyA(buf, "apple");
5328 r = pMsiGetProductInfoExA(prodcode, usersid,
5329 MSIINSTALLCONTEXT_USERMANAGED,
5330 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5331 ok(r == ERROR_UNKNOWN_PROPERTY,
5332 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5333 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5334 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5336 res = RegSetValueExA(userkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5337 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5339 /* InstallSource value exists */
5340 sz = MAX_PATH;
5341 lstrcpyA(buf, "apple");
5342 r = pMsiGetProductInfoExA(prodcode, usersid,
5343 MSIINSTALLCONTEXT_USERMANAGED,
5344 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5345 ok(r == ERROR_UNKNOWN_PROPERTY,
5346 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5347 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5348 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5350 res = RegSetValueExA(userkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5351 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5353 /* LocalPackage value exists */
5354 sz = MAX_PATH;
5355 lstrcpyA(buf, "apple");
5356 r = pMsiGetProductInfoExA(prodcode, usersid,
5357 MSIINSTALLCONTEXT_USERMANAGED,
5358 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5359 ok(r == ERROR_UNKNOWN_PROPERTY,
5360 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5361 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5362 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5364 res = RegSetValueExA(userkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5365 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5367 /* Publisher value exists */
5368 sz = MAX_PATH;
5369 lstrcpyA(buf, "apple");
5370 r = pMsiGetProductInfoExA(prodcode, usersid,
5371 MSIINSTALLCONTEXT_USERMANAGED,
5372 INSTALLPROPERTY_PUBLISHER, buf, &sz);
5373 ok(r == ERROR_UNKNOWN_PROPERTY,
5374 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5375 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5376 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5378 res = RegSetValueExA(userkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5379 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5381 /* URLInfoAbout value exists */
5382 sz = MAX_PATH;
5383 lstrcpyA(buf, "apple");
5384 r = pMsiGetProductInfoExA(prodcode, usersid,
5385 MSIINSTALLCONTEXT_USERMANAGED,
5386 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5387 ok(r == ERROR_UNKNOWN_PROPERTY,
5388 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5389 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5390 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5392 res = RegSetValueExA(userkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5393 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5395 /* URLUpdateInfo value exists */
5396 sz = MAX_PATH;
5397 lstrcpyA(buf, "apple");
5398 r = pMsiGetProductInfoExA(prodcode, usersid,
5399 MSIINSTALLCONTEXT_USERMANAGED,
5400 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5401 ok(r == ERROR_UNKNOWN_PROPERTY,
5402 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5403 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5404 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5406 res = RegSetValueExA(userkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5407 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5409 /* VersionMinor value exists */
5410 sz = MAX_PATH;
5411 lstrcpyA(buf, "apple");
5412 r = pMsiGetProductInfoExA(prodcode, usersid,
5413 MSIINSTALLCONTEXT_USERMANAGED,
5414 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5415 ok(r == ERROR_UNKNOWN_PROPERTY,
5416 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5417 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5418 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5420 res = RegSetValueExA(userkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5421 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5423 /* VersionMajor value exists */
5424 sz = MAX_PATH;
5425 lstrcpyA(buf, "apple");
5426 r = pMsiGetProductInfoExA(prodcode, usersid,
5427 MSIINSTALLCONTEXT_USERMANAGED,
5428 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5429 ok(r == ERROR_UNKNOWN_PROPERTY,
5430 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5431 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5432 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5434 res = RegSetValueExA(userkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5435 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5437 /* DisplayVersion value exists */
5438 sz = MAX_PATH;
5439 lstrcpyA(buf, "apple");
5440 r = pMsiGetProductInfoExA(prodcode, usersid,
5441 MSIINSTALLCONTEXT_USERMANAGED,
5442 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5443 ok(r == ERROR_UNKNOWN_PROPERTY,
5444 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5445 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5446 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5448 res = RegSetValueExA(userkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5449 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5451 /* ProductID value exists */
5452 sz = MAX_PATH;
5453 lstrcpyA(buf, "apple");
5454 r = pMsiGetProductInfoExA(prodcode, usersid,
5455 MSIINSTALLCONTEXT_USERMANAGED,
5456 INSTALLPROPERTY_PRODUCTID, buf, &sz);
5457 ok(r == ERROR_UNKNOWN_PROPERTY,
5458 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5459 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5460 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5462 res = RegSetValueExA(userkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5463 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5465 /* RegCompany value exists */
5466 sz = MAX_PATH;
5467 lstrcpyA(buf, "apple");
5468 r = pMsiGetProductInfoExA(prodcode, usersid,
5469 MSIINSTALLCONTEXT_USERMANAGED,
5470 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5471 ok(r == ERROR_UNKNOWN_PROPERTY,
5472 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5473 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5474 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5476 res = RegSetValueExA(userkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5479 /* RegOwner value exists */
5480 sz = MAX_PATH;
5481 lstrcpyA(buf, "apple");
5482 r = pMsiGetProductInfoExA(prodcode, usersid,
5483 MSIINSTALLCONTEXT_USERMANAGED,
5484 INSTALLPROPERTY_REGOWNER, buf, &sz);
5485 ok(r == ERROR_UNKNOWN_PROPERTY,
5486 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5487 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5488 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5490 res = RegSetValueExA(userkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5491 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5493 /* Transforms value exists */
5494 sz = MAX_PATH;
5495 lstrcpyA(buf, "apple");
5496 r = pMsiGetProductInfoExA(prodcode, usersid,
5497 MSIINSTALLCONTEXT_USERMANAGED,
5498 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5499 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5500 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
5501 ok(sz == 5, "Expected 5, got %d\n", sz);
5503 res = RegSetValueExA(userkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5504 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5506 /* Language value exists */
5507 sz = MAX_PATH;
5508 lstrcpyA(buf, "apple");
5509 r = pMsiGetProductInfoExA(prodcode, usersid,
5510 MSIINSTALLCONTEXT_USERMANAGED,
5511 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5512 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5513 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
5514 ok(sz == 4, "Expected 4, got %d\n", sz);
5516 res = RegSetValueExA(userkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5517 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5519 /* ProductName value exists */
5520 sz = MAX_PATH;
5521 lstrcpyA(buf, "apple");
5522 r = pMsiGetProductInfoExA(prodcode, usersid,
5523 MSIINSTALLCONTEXT_USERMANAGED,
5524 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5525 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5526 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5527 ok(sz == 4, "Expected 4, got %d\n", sz);
5529 res = RegSetValueExA(userkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5530 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5532 /* FIXME */
5534 /* AssignmentType value exists */
5535 sz = MAX_PATH;
5536 lstrcpyA(buf, "apple");
5537 r = pMsiGetProductInfoExA(prodcode, usersid,
5538 MSIINSTALLCONTEXT_USERMANAGED,
5539 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5540 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5541 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5542 ok(sz == 0, "Expected 0, got %d\n", sz);
5544 res = RegSetValueExA(userkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5545 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5547 /* FIXME */
5549 /* PackageCode value exists */
5550 sz = MAX_PATH;
5551 lstrcpyA(buf, "apple");
5552 r = pMsiGetProductInfoExA(prodcode, usersid,
5553 MSIINSTALLCONTEXT_USERMANAGED,
5554 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5555 todo_wine
5557 ok(r == ERROR_BAD_CONFIGURATION,
5558 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
5559 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5560 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5563 res = RegSetValueExA(userkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5564 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5566 /* Version value exists */
5567 sz = MAX_PATH;
5568 lstrcpyA(buf, "apple");
5569 r = pMsiGetProductInfoExA(prodcode, usersid,
5570 MSIINSTALLCONTEXT_USERMANAGED,
5571 INSTALLPROPERTY_VERSION, buf, &sz);
5572 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5573 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
5574 ok(sz == 3, "Expected 3, got %d\n", sz);
5576 res = RegSetValueExA(userkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5577 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5579 /* ProductIcon value exists */
5580 sz = MAX_PATH;
5581 lstrcpyA(buf, "apple");
5582 r = pMsiGetProductInfoExA(prodcode, usersid,
5583 MSIINSTALLCONTEXT_USERMANAGED,
5584 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5585 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5586 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
5587 ok(sz == 4, "Expected 4, got %d\n", sz);
5589 res = RegSetValueExA(userkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5590 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5592 /* PackageName value exists */
5593 sz = MAX_PATH;
5594 lstrcpyA(buf, "apple");
5595 r = pMsiGetProductInfoExA(prodcode, usersid,
5596 MSIINSTALLCONTEXT_USERMANAGED,
5597 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5598 todo_wine
5600 ok(r == ERROR_UNKNOWN_PRODUCT,
5601 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5602 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5603 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5606 res = RegSetValueExA(userkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5607 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5609 /* AuthorizedLUAApp value exists */
5610 sz = MAX_PATH;
5611 lstrcpyA(buf, "apple");
5612 r = pMsiGetProductInfoExA(prodcode, usersid,
5613 MSIINSTALLCONTEXT_USERMANAGED,
5614 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5615 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5616 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
5617 ok(sz == 4, "Expected 4, got %d\n", sz);
5619 RegDeleteValueA(userkey, "AuthorizedLUAApp");
5620 RegDeleteValueA(userkey, "PackageName");
5621 RegDeleteValueA(userkey, "ProductIcon");
5622 RegDeleteValueA(userkey, "Version");
5623 RegDeleteValueA(userkey, "PackageCode");
5624 RegDeleteValueA(userkey, "AssignmentType");
5625 RegDeleteValueA(userkey, "ProductName");
5626 RegDeleteValueA(userkey, "Language");
5627 RegDeleteValueA(userkey, "Transforms");
5628 RegDeleteValueA(userkey, "RegOwner");
5629 RegDeleteValueA(userkey, "RegCompany");
5630 RegDeleteValueA(userkey, "ProductID");
5631 RegDeleteValueA(userkey, "DisplayVersion");
5632 RegDeleteValueA(userkey, "VersionMajor");
5633 RegDeleteValueA(userkey, "VersionMinor");
5634 RegDeleteValueA(userkey, "URLUpdateInfo");
5635 RegDeleteValueA(userkey, "URLInfoAbout");
5636 RegDeleteValueA(userkey, "Publisher");
5637 RegDeleteValueA(userkey, "LocalPackage");
5638 RegDeleteValueA(userkey, "InstallSource");
5639 RegDeleteValueA(userkey, "InstallLocation");
5640 RegDeleteValueA(userkey, "DisplayName");
5641 RegDeleteValueA(userkey, "InstallDate");
5642 RegDeleteValueA(userkey, "HelpTelephone");
5643 RegDeleteValueA(userkey, "HelpLink");
5644 RegDeleteKeyA(userkey, "");
5645 RegCloseKey(userkey);
5646 RegDeleteKeyA(prodkey, "");
5647 RegCloseKey(prodkey);
5649 /* MSIINSTALLCONTEXT_MACHINE */
5651 /* szUserSid is non-NULL */
5652 sz = MAX_PATH;
5653 lstrcpyA(buf, "apple");
5654 r = pMsiGetProductInfoExA(prodcode, usersid,
5655 MSIINSTALLCONTEXT_MACHINE,
5656 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5657 ok(r == ERROR_INVALID_PARAMETER,
5658 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5659 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5660 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5662 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
5663 lstrcatA(keypath, prod_squashed);
5665 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
5666 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5668 /* local system product key exists */
5669 sz = MAX_PATH;
5670 lstrcpyA(buf, "apple");
5671 r = pMsiGetProductInfoExA(prodcode, NULL,
5672 MSIINSTALLCONTEXT_MACHINE,
5673 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5674 ok(r == ERROR_UNKNOWN_PRODUCT,
5675 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5676 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5677 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5679 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
5680 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5682 /* InstallProperties key exists */
5683 sz = MAX_PATH;
5684 lstrcpyA(buf, "apple");
5685 r = pMsiGetProductInfoExA(prodcode, NULL,
5686 MSIINSTALLCONTEXT_MACHINE,
5687 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5688 ok(r == ERROR_UNKNOWN_PRODUCT,
5689 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5690 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5691 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5693 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5694 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5696 /* LocalPackage value exists */
5697 sz = MAX_PATH;
5698 lstrcpyA(buf, "apple");
5699 r = pMsiGetProductInfoExA(prodcode, NULL,
5700 MSIINSTALLCONTEXT_MACHINE,
5701 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5702 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5703 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
5704 ok(sz == 1, "Expected 1, got %d\n", sz);
5706 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5707 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5709 /* HelpLink value exists */
5710 sz = MAX_PATH;
5711 lstrcpyA(buf, "apple");
5712 r = pMsiGetProductInfoExA(prodcode, NULL,
5713 MSIINSTALLCONTEXT_MACHINE,
5714 INSTALLPROPERTY_HELPLINK, buf, &sz);
5715 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5716 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
5717 ok(sz == 4, "Expected 4, got %d\n", sz);
5719 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5720 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5722 /* HelpTelephone value exists */
5723 sz = MAX_PATH;
5724 lstrcpyA(buf, "apple");
5725 r = pMsiGetProductInfoExA(prodcode, NULL,
5726 MSIINSTALLCONTEXT_MACHINE,
5727 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5729 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
5730 ok(sz == 5, "Expected 5, got %d\n", sz);
5732 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5733 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5735 /* InstallDate value exists */
5736 sz = MAX_PATH;
5737 lstrcpyA(buf, "apple");
5738 r = pMsiGetProductInfoExA(prodcode, NULL,
5739 MSIINSTALLCONTEXT_MACHINE,
5740 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5741 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5742 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
5743 ok(sz == 4, "Expected 4, got %d\n", sz);
5745 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5746 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5748 /* DisplayName value exists */
5749 sz = MAX_PATH;
5750 lstrcpyA(buf, "apple");
5751 r = pMsiGetProductInfoExA(prodcode, NULL,
5752 MSIINSTALLCONTEXT_MACHINE,
5753 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5754 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5755 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5756 ok(sz == 4, "Expected 4, got %d\n", sz);
5758 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5759 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5761 /* InstallLocation value exists */
5762 sz = MAX_PATH;
5763 lstrcpyA(buf, "apple");
5764 r = pMsiGetProductInfoExA(prodcode, NULL,
5765 MSIINSTALLCONTEXT_MACHINE,
5766 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5768 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
5769 ok(sz == 3, "Expected 3, got %d\n", sz);
5771 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5772 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5774 /* InstallSource value exists */
5775 sz = MAX_PATH;
5776 lstrcpyA(buf, "apple");
5777 r = pMsiGetProductInfoExA(prodcode, NULL,
5778 MSIINSTALLCONTEXT_MACHINE,
5779 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5780 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5781 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
5782 ok(sz == 6, "Expected 6, got %d\n", sz);
5784 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5785 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5787 /* LocalPackage value exists */
5788 sz = MAX_PATH;
5789 lstrcpyA(buf, "apple");
5790 r = pMsiGetProductInfoExA(prodcode, NULL,
5791 MSIINSTALLCONTEXT_MACHINE,
5792 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5793 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5794 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
5795 ok(sz == 5, "Expected 5, got %d\n", sz);
5797 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5798 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5800 /* Publisher value exists */
5801 sz = MAX_PATH;
5802 lstrcpyA(buf, "apple");
5803 r = pMsiGetProductInfoExA(prodcode, NULL,
5804 MSIINSTALLCONTEXT_MACHINE,
5805 INSTALLPROPERTY_PUBLISHER, buf, &sz);
5806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5807 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
5808 ok(sz == 3, "Expected 3, got %d\n", sz);
5810 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5811 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5813 /* URLInfoAbout value exists */
5814 sz = MAX_PATH;
5815 lstrcpyA(buf, "apple");
5816 r = pMsiGetProductInfoExA(prodcode, NULL,
5817 MSIINSTALLCONTEXT_MACHINE,
5818 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5819 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5820 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
5821 ok(sz == 5, "Expected 5, got %d\n", sz);
5823 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5824 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5826 /* URLUpdateInfo value exists */
5827 sz = MAX_PATH;
5828 lstrcpyA(buf, "apple");
5829 r = pMsiGetProductInfoExA(prodcode, NULL,
5830 MSIINSTALLCONTEXT_MACHINE,
5831 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5832 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5833 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
5834 ok(sz == 6, "Expected 6, got %d\n", sz);
5836 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5837 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5839 /* VersionMinor value exists */
5840 sz = MAX_PATH;
5841 lstrcpyA(buf, "apple");
5842 r = pMsiGetProductInfoExA(prodcode, NULL,
5843 MSIINSTALLCONTEXT_MACHINE,
5844 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5845 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5846 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
5847 ok(sz == 1, "Expected 1, got %d\n", sz);
5849 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5850 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5852 /* VersionMajor value exists */
5853 sz = MAX_PATH;
5854 lstrcpyA(buf, "apple");
5855 r = pMsiGetProductInfoExA(prodcode, NULL,
5856 MSIINSTALLCONTEXT_MACHINE,
5857 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5859 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5860 ok(sz == 1, "Expected 1, got %d\n", sz);
5862 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5863 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5865 /* DisplayVersion value exists */
5866 sz = MAX_PATH;
5867 lstrcpyA(buf, "apple");
5868 r = pMsiGetProductInfoExA(prodcode, NULL,
5869 MSIINSTALLCONTEXT_MACHINE,
5870 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5871 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5872 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
5873 ok(sz == 5, "Expected 5, got %d\n", sz);
5875 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5876 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5878 /* ProductID value exists */
5879 sz = MAX_PATH;
5880 lstrcpyA(buf, "apple");
5881 r = pMsiGetProductInfoExA(prodcode, NULL,
5882 MSIINSTALLCONTEXT_MACHINE,
5883 INSTALLPROPERTY_PRODUCTID, buf, &sz);
5884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5885 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
5886 ok(sz == 2, "Expected 2, got %d\n", sz);
5888 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5889 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5891 /* RegCompany value exists */
5892 sz = MAX_PATH;
5893 lstrcpyA(buf, "apple");
5894 r = pMsiGetProductInfoExA(prodcode, NULL,
5895 MSIINSTALLCONTEXT_MACHINE,
5896 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5897 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5898 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
5899 ok(sz == 4, "Expected 4, got %d\n", sz);
5901 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5902 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5904 /* RegOwner value exists */
5905 sz = MAX_PATH;
5906 lstrcpyA(buf, "apple");
5907 r = pMsiGetProductInfoExA(prodcode, NULL,
5908 MSIINSTALLCONTEXT_MACHINE,
5909 INSTALLPROPERTY_REGOWNER, buf, &sz);
5910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5911 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
5912 ok(sz == 5, "Expected 5, got %d\n", sz);
5914 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5915 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5917 /* Transforms value exists */
5918 sz = MAX_PATH;
5919 lstrcpyA(buf, "apple");
5920 r = pMsiGetProductInfoExA(prodcode, NULL,
5921 MSIINSTALLCONTEXT_MACHINE,
5922 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5923 ok(r == ERROR_UNKNOWN_PRODUCT,
5924 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5925 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5926 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5928 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5929 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5931 /* Language value exists */
5932 sz = MAX_PATH;
5933 lstrcpyA(buf, "apple");
5934 r = pMsiGetProductInfoExA(prodcode, NULL,
5935 MSIINSTALLCONTEXT_MACHINE,
5936 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5937 ok(r == ERROR_UNKNOWN_PRODUCT,
5938 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5939 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5940 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5942 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5943 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5945 /* ProductName value exists */
5946 sz = MAX_PATH;
5947 lstrcpyA(buf, "apple");
5948 r = pMsiGetProductInfoExA(prodcode, NULL,
5949 MSIINSTALLCONTEXT_MACHINE,
5950 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5951 ok(r == ERROR_UNKNOWN_PRODUCT,
5952 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5953 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5954 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5956 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5957 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5959 /* FIXME */
5961 /* AssignmentType value exists */
5962 sz = MAX_PATH;
5963 lstrcpyA(buf, "apple");
5964 r = pMsiGetProductInfoExA(prodcode, NULL,
5965 MSIINSTALLCONTEXT_MACHINE,
5966 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5967 ok(r == ERROR_UNKNOWN_PRODUCT,
5968 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5969 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5970 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5972 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5973 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5975 /* PackageCode value exists */
5976 sz = MAX_PATH;
5977 lstrcpyA(buf, "apple");
5978 r = pMsiGetProductInfoExA(prodcode, NULL,
5979 MSIINSTALLCONTEXT_MACHINE,
5980 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5981 ok(r == ERROR_UNKNOWN_PRODUCT,
5982 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5983 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5984 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5986 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5987 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5989 /* Version value exists */
5990 sz = MAX_PATH;
5991 lstrcpyA(buf, "apple");
5992 r = pMsiGetProductInfoExA(prodcode, NULL,
5993 MSIINSTALLCONTEXT_MACHINE,
5994 INSTALLPROPERTY_VERSION, buf, &sz);
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);
6000 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6001 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6003 /* ProductIcon value exists */
6004 sz = MAX_PATH;
6005 lstrcpyA(buf, "apple");
6006 r = pMsiGetProductInfoExA(prodcode, NULL,
6007 MSIINSTALLCONTEXT_MACHINE,
6008 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
6009 ok(r == ERROR_UNKNOWN_PRODUCT,
6010 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6011 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6012 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6014 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6015 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6017 /* PackageName value exists */
6018 sz = MAX_PATH;
6019 lstrcpyA(buf, "apple");
6020 r = pMsiGetProductInfoExA(prodcode, NULL,
6021 MSIINSTALLCONTEXT_MACHINE,
6022 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
6023 ok(r == ERROR_UNKNOWN_PRODUCT,
6024 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6025 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6026 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6028 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6029 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6031 /* AuthorizedLUAApp value exists */
6032 sz = MAX_PATH;
6033 lstrcpyA(buf, "apple");
6034 r = pMsiGetProductInfoExA(prodcode, NULL,
6035 MSIINSTALLCONTEXT_MACHINE,
6036 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
6037 ok(r == ERROR_UNKNOWN_PRODUCT,
6038 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6039 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6040 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6042 RegDeleteValueA(propkey, "AuthorizedLUAApp");
6043 RegDeleteValueA(propkey, "PackageName");
6044 RegDeleteValueA(propkey, "ProductIcon");
6045 RegDeleteValueA(propkey, "Version");
6046 RegDeleteValueA(propkey, "PackageCode");
6047 RegDeleteValueA(propkey, "AssignmentType");
6048 RegDeleteValueA(propkey, "ProductName");
6049 RegDeleteValueA(propkey, "Language");
6050 RegDeleteValueA(propkey, "Transforms");
6051 RegDeleteValueA(propkey, "RegOwner");
6052 RegDeleteValueA(propkey, "RegCompany");
6053 RegDeleteValueA(propkey, "ProductID");
6054 RegDeleteValueA(propkey, "DisplayVersion");
6055 RegDeleteValueA(propkey, "VersionMajor");
6056 RegDeleteValueA(propkey, "VersionMinor");
6057 RegDeleteValueA(propkey, "URLUpdateInfo");
6058 RegDeleteValueA(propkey, "URLInfoAbout");
6059 RegDeleteValueA(propkey, "Publisher");
6060 RegDeleteValueA(propkey, "LocalPackage");
6061 RegDeleteValueA(propkey, "InstallSource");
6062 RegDeleteValueA(propkey, "InstallLocation");
6063 RegDeleteValueA(propkey, "DisplayName");
6064 RegDeleteValueA(propkey, "InstallDate");
6065 RegDeleteValueA(propkey, "HelpTelephone");
6066 RegDeleteValueA(propkey, "HelpLink");
6067 RegDeleteValueA(propkey, "LocalPackage");
6068 RegDeleteKeyA(propkey, "");
6069 RegCloseKey(propkey);
6070 RegDeleteKeyA(localkey, "");
6071 RegCloseKey(localkey);
6073 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
6074 lstrcatA(keypath, prod_squashed);
6076 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6077 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6079 /* local classes product key exists */
6080 sz = MAX_PATH;
6081 lstrcpyA(buf, "apple");
6082 r = pMsiGetProductInfoExA(prodcode, NULL,
6083 MSIINSTALLCONTEXT_MACHINE,
6084 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
6085 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6086 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
6087 ok(sz == 1, "Expected 1, got %d\n", sz);
6089 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
6090 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6092 /* HelpLink value exists */
6093 sz = MAX_PATH;
6094 lstrcpyA(buf, "apple");
6095 r = pMsiGetProductInfoExA(prodcode, NULL,
6096 MSIINSTALLCONTEXT_MACHINE,
6097 INSTALLPROPERTY_HELPLINK, buf, &sz);
6098 ok(r == ERROR_UNKNOWN_PROPERTY,
6099 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6100 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6101 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6103 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
6104 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6106 /* HelpTelephone value exists */
6107 sz = MAX_PATH;
6108 lstrcpyA(buf, "apple");
6109 r = pMsiGetProductInfoExA(prodcode, NULL,
6110 MSIINSTALLCONTEXT_MACHINE,
6111 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
6112 ok(r == ERROR_UNKNOWN_PROPERTY,
6113 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6114 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6115 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6117 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
6118 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6120 /* InstallDate value exists */
6121 sz = MAX_PATH;
6122 lstrcpyA(buf, "apple");
6123 r = pMsiGetProductInfoExA(prodcode, NULL,
6124 MSIINSTALLCONTEXT_MACHINE,
6125 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
6126 ok(r == ERROR_UNKNOWN_PROPERTY,
6127 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6128 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6129 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6131 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
6132 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6134 /* DisplayName value exists */
6135 sz = MAX_PATH;
6136 lstrcpyA(buf, "apple");
6137 r = pMsiGetProductInfoExA(prodcode, NULL,
6138 MSIINSTALLCONTEXT_MACHINE,
6139 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
6140 ok(r == ERROR_UNKNOWN_PROPERTY,
6141 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6142 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6143 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6145 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6146 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6148 /* InstallLocation value exists */
6149 sz = MAX_PATH;
6150 lstrcpyA(buf, "apple");
6151 r = pMsiGetProductInfoExA(prodcode, NULL,
6152 MSIINSTALLCONTEXT_MACHINE,
6153 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
6154 ok(r == ERROR_UNKNOWN_PROPERTY,
6155 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6156 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6157 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6159 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6160 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6162 /* InstallSource value exists */
6163 sz = MAX_PATH;
6164 lstrcpyA(buf, "apple");
6165 r = pMsiGetProductInfoExA(prodcode, NULL,
6166 MSIINSTALLCONTEXT_MACHINE,
6167 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
6168 ok(r == ERROR_UNKNOWN_PROPERTY,
6169 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6170 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6171 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6173 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6174 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6176 /* LocalPackage value exists */
6177 sz = MAX_PATH;
6178 lstrcpyA(buf, "apple");
6179 r = pMsiGetProductInfoExA(prodcode, NULL,
6180 MSIINSTALLCONTEXT_MACHINE,
6181 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
6182 ok(r == ERROR_UNKNOWN_PROPERTY,
6183 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6184 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6185 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6187 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6188 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6190 /* Publisher value exists */
6191 sz = MAX_PATH;
6192 lstrcpyA(buf, "apple");
6193 r = pMsiGetProductInfoExA(prodcode, NULL,
6194 MSIINSTALLCONTEXT_MACHINE,
6195 INSTALLPROPERTY_PUBLISHER, buf, &sz);
6196 ok(r == ERROR_UNKNOWN_PROPERTY,
6197 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6198 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6199 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6201 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6202 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6204 /* URLInfoAbout value exists */
6205 sz = MAX_PATH;
6206 lstrcpyA(buf, "apple");
6207 r = pMsiGetProductInfoExA(prodcode, NULL,
6208 MSIINSTALLCONTEXT_MACHINE,
6209 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
6210 ok(r == ERROR_UNKNOWN_PROPERTY,
6211 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6212 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6213 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6215 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6216 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6218 /* URLUpdateInfo value exists */
6219 sz = MAX_PATH;
6220 lstrcpyA(buf, "apple");
6221 r = pMsiGetProductInfoExA(prodcode, NULL,
6222 MSIINSTALLCONTEXT_MACHINE,
6223 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
6224 ok(r == ERROR_UNKNOWN_PROPERTY,
6225 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6226 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6227 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6229 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6230 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6232 /* VersionMinor value exists */
6233 sz = MAX_PATH;
6234 lstrcpyA(buf, "apple");
6235 r = pMsiGetProductInfoExA(prodcode, NULL,
6236 MSIINSTALLCONTEXT_MACHINE,
6237 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
6238 ok(r == ERROR_UNKNOWN_PROPERTY,
6239 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6240 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6241 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6243 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6244 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6246 /* VersionMajor value exists */
6247 sz = MAX_PATH;
6248 lstrcpyA(buf, "apple");
6249 r = pMsiGetProductInfoExA(prodcode, NULL,
6250 MSIINSTALLCONTEXT_MACHINE,
6251 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
6252 ok(r == ERROR_UNKNOWN_PROPERTY,
6253 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6254 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6255 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6257 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6258 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6260 /* DisplayVersion value exists */
6261 sz = MAX_PATH;
6262 lstrcpyA(buf, "apple");
6263 r = pMsiGetProductInfoExA(prodcode, NULL,
6264 MSIINSTALLCONTEXT_MACHINE,
6265 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
6266 ok(r == ERROR_UNKNOWN_PROPERTY,
6267 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6268 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6269 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6271 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6272 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6274 /* ProductID value exists */
6275 sz = MAX_PATH;
6276 lstrcpyA(buf, "apple");
6277 r = pMsiGetProductInfoExA(prodcode, NULL,
6278 MSIINSTALLCONTEXT_MACHINE,
6279 INSTALLPROPERTY_PRODUCTID, buf, &sz);
6280 ok(r == ERROR_UNKNOWN_PROPERTY,
6281 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6282 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6283 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6285 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6286 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6288 /* RegCompany value exists */
6289 sz = MAX_PATH;
6290 lstrcpyA(buf, "apple");
6291 r = pMsiGetProductInfoExA(prodcode, NULL,
6292 MSIINSTALLCONTEXT_MACHINE,
6293 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
6294 ok(r == ERROR_UNKNOWN_PROPERTY,
6295 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6296 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6297 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6299 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6300 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6302 /* RegOwner value exists */
6303 sz = MAX_PATH;
6304 lstrcpyA(buf, "apple");
6305 r = pMsiGetProductInfoExA(prodcode, NULL,
6306 MSIINSTALLCONTEXT_MACHINE,
6307 INSTALLPROPERTY_REGOWNER, buf, &sz);
6308 ok(r == ERROR_UNKNOWN_PROPERTY,
6309 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6310 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6311 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6313 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6314 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6316 /* Transforms value exists */
6317 sz = MAX_PATH;
6318 lstrcpyA(buf, "apple");
6319 r = pMsiGetProductInfoExA(prodcode, NULL,
6320 MSIINSTALLCONTEXT_MACHINE,
6321 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
6322 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6323 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
6324 ok(sz == 5, "Expected 5, got %d\n", sz);
6326 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6327 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6329 /* Language value exists */
6330 sz = MAX_PATH;
6331 lstrcpyA(buf, "apple");
6332 r = pMsiGetProductInfoExA(prodcode, NULL,
6333 MSIINSTALLCONTEXT_MACHINE,
6334 INSTALLPROPERTY_LANGUAGE, buf, &sz);
6335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6336 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
6337 ok(sz == 4, "Expected 4, got %d\n", sz);
6339 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6340 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6342 /* ProductName value exists */
6343 sz = MAX_PATH;
6344 lstrcpyA(buf, "apple");
6345 r = pMsiGetProductInfoExA(prodcode, NULL,
6346 MSIINSTALLCONTEXT_MACHINE,
6347 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
6348 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6349 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6350 ok(sz == 4, "Expected 4, got %d\n", sz);
6352 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6353 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6355 /* FIXME */
6357 /* AssignmentType value exists */
6358 sz = MAX_PATH;
6359 lstrcpyA(buf, "apple");
6360 r = pMsiGetProductInfoExA(prodcode, NULL,
6361 MSIINSTALLCONTEXT_MACHINE,
6362 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
6363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6364 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
6365 ok(sz == 0, "Expected 0, got %d\n", sz);
6367 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6368 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6370 /* FIXME */
6372 /* PackageCode value exists */
6373 sz = MAX_PATH;
6374 lstrcpyA(buf, "apple");
6375 r = pMsiGetProductInfoExA(prodcode, NULL,
6376 MSIINSTALLCONTEXT_MACHINE,
6377 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
6378 todo_wine
6380 ok(r == ERROR_BAD_CONFIGURATION,
6381 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
6382 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6383 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6386 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6387 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6389 /* Version value exists */
6390 sz = MAX_PATH;
6391 lstrcpyA(buf, "apple");
6392 r = pMsiGetProductInfoExA(prodcode, NULL,
6393 MSIINSTALLCONTEXT_MACHINE,
6394 INSTALLPROPERTY_VERSION, buf, &sz);
6395 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6396 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
6397 ok(sz == 3, "Expected 3, got %d\n", sz);
6399 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6400 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6402 /* ProductIcon value exists */
6403 sz = MAX_PATH;
6404 lstrcpyA(buf, "apple");
6405 r = pMsiGetProductInfoExA(prodcode, NULL,
6406 MSIINSTALLCONTEXT_MACHINE,
6407 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
6408 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6409 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
6410 ok(sz == 4, "Expected 4, got %d\n", sz);
6412 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6413 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6415 /* PackageName value exists */
6416 sz = MAX_PATH;
6417 lstrcpyA(buf, "apple");
6418 r = pMsiGetProductInfoExA(prodcode, NULL,
6419 MSIINSTALLCONTEXT_MACHINE,
6420 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
6421 todo_wine
6423 ok(r == ERROR_UNKNOWN_PRODUCT,
6424 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6425 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6426 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6429 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6430 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6432 /* AuthorizedLUAApp value exists */
6433 sz = MAX_PATH;
6434 lstrcpyA(buf, "apple");
6435 r = pMsiGetProductInfoExA(prodcode, NULL,
6436 MSIINSTALLCONTEXT_MACHINE,
6437 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
6438 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6439 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
6440 ok(sz == 4, "Expected 4, got %d\n", sz);
6442 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
6443 RegDeleteValueA(prodkey, "PackageName");
6444 RegDeleteValueA(prodkey, "ProductIcon");
6445 RegDeleteValueA(prodkey, "Version");
6446 RegDeleteValueA(prodkey, "PackageCode");
6447 RegDeleteValueA(prodkey, "AssignmentType");
6448 RegDeleteValueA(prodkey, "ProductName");
6449 RegDeleteValueA(prodkey, "Language");
6450 RegDeleteValueA(prodkey, "Transforms");
6451 RegDeleteValueA(prodkey, "RegOwner");
6452 RegDeleteValueA(prodkey, "RegCompany");
6453 RegDeleteValueA(prodkey, "ProductID");
6454 RegDeleteValueA(prodkey, "DisplayVersion");
6455 RegDeleteValueA(prodkey, "VersionMajor");
6456 RegDeleteValueA(prodkey, "VersionMinor");
6457 RegDeleteValueA(prodkey, "URLUpdateInfo");
6458 RegDeleteValueA(prodkey, "URLInfoAbout");
6459 RegDeleteValueA(prodkey, "Publisher");
6460 RegDeleteValueA(prodkey, "LocalPackage");
6461 RegDeleteValueA(prodkey, "InstallSource");
6462 RegDeleteValueA(prodkey, "InstallLocation");
6463 RegDeleteValueA(prodkey, "DisplayName");
6464 RegDeleteValueA(prodkey, "InstallDate");
6465 RegDeleteValueA(prodkey, "HelpTelephone");
6466 RegDeleteValueA(prodkey, "HelpLink");
6467 RegDeleteKeyA(prodkey, "");
6468 RegCloseKey(prodkey);
6471 #define INIT_USERINFO() \
6472 lstrcpyA(user, "apple"); \
6473 lstrcpyA(org, "orange"); \
6474 lstrcpyA(serial, "banana"); \
6475 usersz = orgsz = serialsz = MAX_PATH;
6477 static void test_MsiGetUserInfo(void)
6479 USERINFOSTATE state;
6480 CHAR user[MAX_PATH];
6481 CHAR org[MAX_PATH];
6482 CHAR serial[MAX_PATH];
6483 DWORD usersz, orgsz, serialsz;
6484 CHAR keypath[MAX_PATH * 2];
6485 CHAR prodcode[MAX_PATH];
6486 CHAR prod_squashed[MAX_PATH];
6487 HKEY prodkey, userprod, props;
6488 LPSTR usersid;
6489 LONG res;
6491 create_test_guid(prodcode, prod_squashed);
6492 get_user_sid(&usersid);
6494 /* NULL szProduct */
6495 INIT_USERINFO();
6496 state = MsiGetUserInfoA(NULL, user, &usersz, org, &orgsz, serial, &serialsz);
6497 ok(state == USERINFOSTATE_INVALIDARG,
6498 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6499 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6500 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6501 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6502 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6503 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6504 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6506 /* empty szProductCode */
6507 INIT_USERINFO();
6508 state = MsiGetUserInfoA("", user, &usersz, org, &orgsz, serial, &serialsz);
6509 ok(state == USERINFOSTATE_INVALIDARG,
6510 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6511 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6512 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6513 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6514 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6515 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6516 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6518 /* garbage szProductCode */
6519 INIT_USERINFO();
6520 state = MsiGetUserInfoA("garbage", user, &usersz, org, &orgsz, serial, &serialsz);
6521 ok(state == USERINFOSTATE_INVALIDARG,
6522 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6523 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6524 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6525 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6526 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6527 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6528 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6530 /* guid without brackets */
6531 INIT_USERINFO();
6532 state = MsiGetUserInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
6533 user, &usersz, org, &orgsz, serial, &serialsz);
6534 ok(state == USERINFOSTATE_INVALIDARG,
6535 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6536 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6537 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6538 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6539 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6540 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6541 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6543 /* guid with brackets */
6544 INIT_USERINFO();
6545 state = MsiGetUserInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
6546 user, &usersz, org, &orgsz, serial, &serialsz);
6547 ok(state == USERINFOSTATE_UNKNOWN,
6548 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6549 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6550 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6551 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6552 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6553 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6554 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6556 /* NULL lpUserNameBuf */
6557 INIT_USERINFO();
6558 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
6559 ok(state == USERINFOSTATE_UNKNOWN,
6560 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6561 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6562 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6563 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6564 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6565 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6567 /* NULL pcchUserNameBuf */
6568 INIT_USERINFO();
6569 state = MsiGetUserInfoA(prodcode, user, NULL, org, &orgsz, serial, &serialsz);
6570 ok(state == USERINFOSTATE_INVALIDARG,
6571 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6572 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6573 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6574 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6575 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6576 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6578 /* both lpUserNameBuf and pcchUserNameBuf NULL */
6579 INIT_USERINFO();
6580 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6581 ok(state == USERINFOSTATE_UNKNOWN,
6582 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6583 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6584 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6585 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6586 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6588 /* NULL lpOrgNameBuf */
6589 INIT_USERINFO();
6590 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, &orgsz, serial, &serialsz);
6591 ok(state == USERINFOSTATE_UNKNOWN,
6592 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6593 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6594 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6595 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6596 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6597 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6599 /* NULL pcchOrgNameBuf */
6600 INIT_USERINFO();
6601 state = MsiGetUserInfoA(prodcode, user, &usersz, org, NULL, serial, &serialsz);
6602 ok(state == USERINFOSTATE_INVALIDARG,
6603 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6604 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6605 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6606 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6607 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6608 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6610 /* both lpOrgNameBuf and pcchOrgNameBuf NULL */
6611 INIT_USERINFO();
6612 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, NULL, serial, &serialsz);
6613 ok(state == USERINFOSTATE_UNKNOWN,
6614 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6615 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6616 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6617 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6618 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6620 /* NULL lpSerialBuf */
6621 INIT_USERINFO();
6622 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, &serialsz);
6623 ok(state == USERINFOSTATE_UNKNOWN,
6624 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6625 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6626 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6627 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6628 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6629 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6631 /* NULL pcchSerialBuf */
6632 INIT_USERINFO();
6633 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, NULL);
6634 ok(state == USERINFOSTATE_INVALIDARG,
6635 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6636 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6637 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6638 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6639 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6640 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6642 /* both lpSerialBuf and pcchSerialBuf NULL */
6643 INIT_USERINFO();
6644 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, NULL);
6645 ok(state == USERINFOSTATE_UNKNOWN,
6646 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6647 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6648 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6649 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6650 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6652 /* MSIINSTALLCONTEXT_USERMANAGED */
6654 /* create local system product key */
6655 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6656 lstrcatA(keypath, usersid);
6657 lstrcatA(keypath, "\\Installer\\Products\\");
6658 lstrcatA(keypath, prod_squashed);
6660 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6661 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6663 /* managed product key exists */
6664 INIT_USERINFO();
6665 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6666 ok(state == USERINFOSTATE_ABSENT,
6667 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6668 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6669 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6670 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6671 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6672 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6673 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6675 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6676 lstrcatA(keypath, "Installer\\UserData\\");
6677 lstrcatA(keypath, usersid);
6678 lstrcatA(keypath, "\\Products\\");
6679 lstrcatA(keypath, prod_squashed);
6681 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6682 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6684 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6685 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6687 /* InstallProperties key exists */
6688 INIT_USERINFO();
6689 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6690 ok(state == USERINFOSTATE_ABSENT,
6691 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6692 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6693 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6694 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6695 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6696 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6697 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6699 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6700 INIT_USERINFO();
6701 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6702 ok(state == USERINFOSTATE_ABSENT,
6703 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6704 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6705 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6706 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6707 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6709 /* RegOwner, RegCompany don't exist, out params are NULL */
6710 INIT_USERINFO();
6711 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6712 ok(state == USERINFOSTATE_ABSENT,
6713 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6714 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6715 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6717 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6718 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6720 /* RegOwner value exists */
6721 INIT_USERINFO();
6722 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6723 ok(state == USERINFOSTATE_ABSENT,
6724 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6725 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6726 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6727 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6728 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6729 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6730 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6732 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6733 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6735 /* RegCompany value exists */
6736 INIT_USERINFO();
6737 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6738 ok(state == USERINFOSTATE_ABSENT,
6739 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6740 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6741 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6742 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6743 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6744 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6745 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6747 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6748 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6750 /* ProductID value exists */
6751 INIT_USERINFO();
6752 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6753 ok(state == USERINFOSTATE_PRESENT,
6754 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6755 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6756 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6757 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6758 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6759 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6760 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6762 /* pcchUserNameBuf is too small */
6763 INIT_USERINFO();
6764 usersz = 0;
6765 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6766 ok(state == USERINFOSTATE_MOREDATA,
6767 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
6768 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6769 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6770 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6771 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6772 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6773 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6775 /* pcchUserNameBuf has no room for NULL terminator */
6776 INIT_USERINFO();
6777 usersz = 5;
6778 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6779 ok(state == USERINFOSTATE_MOREDATA,
6780 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
6781 todo_wine
6783 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6785 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6786 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6787 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6788 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6789 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6791 /* pcchUserNameBuf is too small, lpUserNameBuf is NULL */
6792 INIT_USERINFO();
6793 usersz = 0;
6794 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
6795 ok(state == USERINFOSTATE_PRESENT,
6796 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6797 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6798 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6799 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6800 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6801 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6802 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6804 RegDeleteValueA(props, "ProductID");
6805 RegDeleteValueA(props, "RegCompany");
6806 RegDeleteValueA(props, "RegOwner");
6807 RegDeleteKeyA(props, "");
6808 RegCloseKey(props);
6809 RegDeleteKeyA(userprod, "");
6810 RegCloseKey(userprod);
6811 RegDeleteKeyA(prodkey, "");
6812 RegCloseKey(prodkey);
6814 /* MSIINSTALLCONTEXT_USERUNMANAGED */
6816 /* create local system product key */
6817 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
6818 lstrcatA(keypath, prod_squashed);
6820 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
6821 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6823 /* product key exists */
6824 INIT_USERINFO();
6825 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6826 ok(state == USERINFOSTATE_ABSENT,
6827 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6828 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6829 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6830 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6831 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6832 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6833 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6835 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6836 lstrcatA(keypath, "Installer\\UserData\\");
6837 lstrcatA(keypath, usersid);
6838 lstrcatA(keypath, "\\Products\\");
6839 lstrcatA(keypath, prod_squashed);
6841 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6842 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6844 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6845 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6847 /* InstallProperties key exists */
6848 INIT_USERINFO();
6849 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6850 ok(state == USERINFOSTATE_ABSENT,
6851 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6852 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6853 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6854 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6855 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6856 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6857 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6859 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6860 INIT_USERINFO();
6861 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6862 ok(state == USERINFOSTATE_ABSENT,
6863 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6864 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6865 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6866 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6867 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6869 /* RegOwner, RegCompany don't exist, out params are NULL */
6870 INIT_USERINFO();
6871 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6872 ok(state == USERINFOSTATE_ABSENT,
6873 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6874 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6875 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6877 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6878 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6880 /* RegOwner value exists */
6881 INIT_USERINFO();
6882 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6883 ok(state == USERINFOSTATE_ABSENT,
6884 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6885 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6886 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6887 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6888 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6889 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6890 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6892 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6893 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6895 /* RegCompany value exists */
6896 INIT_USERINFO();
6897 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6898 ok(state == USERINFOSTATE_ABSENT,
6899 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6900 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6901 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6902 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6903 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6904 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6905 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6907 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6908 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6910 /* ProductID value exists */
6911 INIT_USERINFO();
6912 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6913 ok(state == USERINFOSTATE_PRESENT,
6914 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6915 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6916 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6917 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6918 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6919 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6920 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6922 RegDeleteValueA(props, "ProductID");
6923 RegDeleteValueA(props, "RegCompany");
6924 RegDeleteValueA(props, "RegOwner");
6925 RegDeleteKeyA(props, "");
6926 RegCloseKey(props);
6927 RegDeleteKeyA(userprod, "");
6928 RegCloseKey(userprod);
6929 RegDeleteKeyA(prodkey, "");
6930 RegCloseKey(prodkey);
6932 /* MSIINSTALLCONTEXT_MACHINE */
6934 /* create local system product key */
6935 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
6936 lstrcatA(keypath, prod_squashed);
6938 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6939 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6941 /* product key exists */
6942 INIT_USERINFO();
6943 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6944 ok(state == USERINFOSTATE_ABSENT,
6945 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6946 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6947 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6948 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6949 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6950 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6951 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6953 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6954 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18");
6955 lstrcatA(keypath, "\\Products\\");
6956 lstrcatA(keypath, prod_squashed);
6958 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6959 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6961 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6962 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6964 /* InstallProperties key exists */
6965 INIT_USERINFO();
6966 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6967 ok(state == USERINFOSTATE_ABSENT,
6968 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6969 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6970 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6971 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6972 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6973 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6974 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6976 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6977 INIT_USERINFO();
6978 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6979 ok(state == USERINFOSTATE_ABSENT,
6980 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6981 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6982 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6983 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6984 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6986 /* RegOwner, RegCompany don't exist, out params are NULL */
6987 INIT_USERINFO();
6988 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6989 ok(state == USERINFOSTATE_ABSENT,
6990 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6991 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6992 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6994 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6995 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6997 /* RegOwner value exists */
6998 INIT_USERINFO();
6999 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
7000 ok(state == USERINFOSTATE_ABSENT,
7001 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
7002 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
7003 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
7004 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
7005 ok(usersz == 5, "Expected 5, got %d\n", usersz);
7006 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
7007 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
7009 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
7010 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7012 /* RegCompany value exists */
7013 INIT_USERINFO();
7014 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
7015 ok(state == USERINFOSTATE_ABSENT,
7016 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
7017 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
7018 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
7019 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
7020 ok(usersz == 5, "Expected 5, got %d\n", usersz);
7021 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
7022 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
7024 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
7025 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7027 /* ProductID value exists */
7028 INIT_USERINFO();
7029 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
7030 ok(state == USERINFOSTATE_PRESENT,
7031 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
7032 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
7033 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
7034 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
7035 ok(usersz == 5, "Expected 5, got %d\n", usersz);
7036 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
7037 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
7039 RegDeleteValueA(props, "ProductID");
7040 RegDeleteValueA(props, "RegCompany");
7041 RegDeleteValueA(props, "RegOwner");
7042 RegDeleteKeyA(props, "");
7043 RegCloseKey(props);
7044 RegDeleteKeyA(userprod, "");
7045 RegCloseKey(userprod);
7046 RegDeleteKeyA(prodkey, "");
7047 RegCloseKey(prodkey);
7050 static void test_MsiOpenProduct(void)
7052 MSIHANDLE hprod, hdb;
7053 CHAR val[MAX_PATH];
7054 CHAR path[MAX_PATH];
7055 CHAR keypath[MAX_PATH*2];
7056 CHAR prodcode[MAX_PATH];
7057 CHAR prod_squashed[MAX_PATH];
7058 HKEY prodkey, userkey, props;
7059 LPSTR usersid;
7060 DWORD size;
7061 LONG res;
7062 UINT r;
7064 GetCurrentDirectoryA(MAX_PATH, path);
7065 lstrcatA(path, "\\");
7067 create_test_guid(prodcode, prod_squashed);
7068 get_user_sid(&usersid);
7070 hdb = create_package_db(prodcode);
7071 MsiCloseHandle(hdb);
7073 /* NULL szProduct */
7074 hprod = 0xdeadbeef;
7075 r = MsiOpenProductA(NULL, &hprod);
7076 ok(r == ERROR_INVALID_PARAMETER,
7077 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7078 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7080 /* empty szProduct */
7081 hprod = 0xdeadbeef;
7082 r = MsiOpenProductA("", &hprod);
7083 ok(r == ERROR_INVALID_PARAMETER,
7084 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7085 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7087 /* garbage szProduct */
7088 hprod = 0xdeadbeef;
7089 r = MsiOpenProductA("garbage", &hprod);
7090 ok(r == ERROR_INVALID_PARAMETER,
7091 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7092 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7094 /* guid without brackets */
7095 hprod = 0xdeadbeef;
7096 r = MsiOpenProductA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", &hprod);
7097 ok(r == ERROR_INVALID_PARAMETER,
7098 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7099 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7101 /* guid with brackets */
7102 hprod = 0xdeadbeef;
7103 r = MsiOpenProductA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", &hprod);
7104 ok(r == ERROR_UNKNOWN_PRODUCT,
7105 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7106 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7108 /* same length as guid, but random */
7109 hprod = 0xdeadbeef;
7110 r = MsiOpenProductA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", &hprod);
7111 ok(r == ERROR_INVALID_PARAMETER,
7112 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7113 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7115 /* hProduct is NULL */
7116 hprod = 0xdeadbeef;
7117 r = MsiOpenProductA(prodcode, NULL);
7118 ok(r == ERROR_INVALID_PARAMETER,
7119 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7120 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7122 /* MSIINSTALLCONTEXT_USERMANAGED */
7124 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7125 lstrcatA(keypath, "Installer\\Managed\\");
7126 lstrcatA(keypath, usersid);
7127 lstrcatA(keypath, "\\Installer\\Products\\");
7128 lstrcatA(keypath, prod_squashed);
7130 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
7131 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7133 /* managed product key exists */
7134 hprod = 0xdeadbeef;
7135 r = MsiOpenProductA(prodcode, &hprod);
7136 ok(r == ERROR_UNKNOWN_PRODUCT,
7137 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7138 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7140 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7141 lstrcatA(keypath, "Installer\\UserData\\");
7142 lstrcatA(keypath, usersid);
7143 lstrcatA(keypath, "\\Products\\");
7144 lstrcatA(keypath, prod_squashed);
7146 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
7147 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7149 /* user product key exists */
7150 hprod = 0xdeadbeef;
7151 r = MsiOpenProductA(prodcode, &hprod);
7152 ok(r == ERROR_UNKNOWN_PRODUCT,
7153 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7154 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7156 res = RegCreateKeyA(userkey, "InstallProperties", &props);
7157 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7159 /* InstallProperties key exists */
7160 hprod = 0xdeadbeef;
7161 r = MsiOpenProductA(prodcode, &hprod);
7162 ok(r == ERROR_UNKNOWN_PRODUCT,
7163 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7164 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7166 lstrcpyA(val, path);
7167 lstrcatA(val, "\\winetest.msi");
7168 res = RegSetValueExA(props, "ManagedLocalPackage", 0, REG_SZ,
7169 (const BYTE *)val, lstrlenA(val) + 1);
7170 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7172 /* ManagedLocalPackage value exists */
7173 hprod = 0xdeadbeef;
7174 r = MsiOpenProductA(prodcode, &hprod);
7175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7176 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
7178 size = MAX_PATH;
7179 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
7180 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7181 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
7182 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
7184 MsiCloseHandle(hprod);
7186 RegDeleteValueA(props, "ManagedLocalPackage");
7187 RegDeleteKeyA(props, "");
7188 RegCloseKey(props);
7189 RegDeleteKeyA(userkey, "");
7190 RegCloseKey(userkey);
7191 RegDeleteKeyA(prodkey, "");
7192 RegCloseKey(prodkey);
7194 /* MSIINSTALLCONTEXT_USERUNMANAGED */
7196 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
7197 lstrcatA(keypath, prod_squashed);
7199 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
7200 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7202 /* unmanaged product key exists */
7203 hprod = 0xdeadbeef;
7204 r = MsiOpenProductA(prodcode, &hprod);
7205 ok(r == ERROR_UNKNOWN_PRODUCT,
7206 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7207 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7209 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7210 lstrcatA(keypath, "Installer\\UserData\\");
7211 lstrcatA(keypath, usersid);
7212 lstrcatA(keypath, "\\Products\\");
7213 lstrcatA(keypath, prod_squashed);
7215 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
7216 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7218 /* user product key exists */
7219 hprod = 0xdeadbeef;
7220 r = MsiOpenProductA(prodcode, &hprod);
7221 ok(r == ERROR_UNKNOWN_PRODUCT,
7222 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7223 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7225 res = RegCreateKeyA(userkey, "InstallProperties", &props);
7226 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7228 /* InstallProperties key exists */
7229 hprod = 0xdeadbeef;
7230 r = MsiOpenProductA(prodcode, &hprod);
7231 ok(r == ERROR_UNKNOWN_PRODUCT,
7232 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7233 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7235 lstrcpyA(val, path);
7236 lstrcatA(val, "\\winetest.msi");
7237 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7238 (const BYTE *)val, lstrlenA(val) + 1);
7239 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7241 /* LocalPackage value exists */
7242 hprod = 0xdeadbeef;
7243 r = MsiOpenProductA(prodcode, &hprod);
7244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7245 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
7247 size = MAX_PATH;
7248 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
7249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7250 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
7251 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
7253 MsiCloseHandle(hprod);
7255 RegDeleteValueA(props, "LocalPackage");
7256 RegDeleteKeyA(props, "");
7257 RegCloseKey(props);
7258 RegDeleteKeyA(userkey, "");
7259 RegCloseKey(userkey);
7260 RegDeleteKeyA(prodkey, "");
7261 RegCloseKey(prodkey);
7263 /* MSIINSTALLCONTEXT_MACHINE */
7265 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
7266 lstrcatA(keypath, prod_squashed);
7268 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
7269 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7271 /* managed product key exists */
7272 hprod = 0xdeadbeef;
7273 r = MsiOpenProductA(prodcode, &hprod);
7274 ok(r == ERROR_UNKNOWN_PRODUCT,
7275 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7276 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7278 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7279 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
7280 lstrcatA(keypath, prod_squashed);
7282 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
7283 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7285 /* user product key exists */
7286 hprod = 0xdeadbeef;
7287 r = MsiOpenProductA(prodcode, &hprod);
7288 ok(r == ERROR_UNKNOWN_PRODUCT,
7289 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7290 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7292 res = RegCreateKeyA(userkey, "InstallProperties", &props);
7293 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7295 /* InstallProperties key exists */
7296 hprod = 0xdeadbeef;
7297 r = MsiOpenProductA(prodcode, &hprod);
7298 ok(r == ERROR_UNKNOWN_PRODUCT,
7299 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7300 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7302 lstrcpyA(val, path);
7303 lstrcatA(val, "\\winetest.msi");
7304 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7305 (const BYTE *)val, lstrlenA(val) + 1);
7306 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7308 /* LocalPackage value exists */
7309 hprod = 0xdeadbeef;
7310 r = MsiOpenProductA(prodcode, &hprod);
7311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7312 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
7314 size = MAX_PATH;
7315 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
7316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7317 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
7318 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
7320 MsiCloseHandle(hprod);
7322 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7323 (const BYTE *)"winetest.msi", 13);
7324 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7326 /* LocalPackage has just the package name */
7327 hprod = 0xdeadbeef;
7328 r = MsiOpenProductA(prodcode, &hprod);
7329 ok(r == ERROR_INSTALL_PACKAGE_OPEN_FAILED,
7330 "Expected ERROR_INSTALL_PACKAGE_OPEN_FAILED, got %d\n", r);
7331 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7333 lstrcpyA(val, path);
7334 lstrcatA(val, "\\winetest.msi");
7335 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7336 (const BYTE *)val, lstrlenA(val) + 1);
7337 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7339 DeleteFileA(msifile);
7341 /* local package does not exist */
7342 hprod = 0xdeadbeef;
7343 r = MsiOpenProductA(prodcode, &hprod);
7344 ok(r == ERROR_UNKNOWN_PRODUCT,
7345 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7346 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7348 RegDeleteValueA(props, "LocalPackage");
7349 RegDeleteKeyA(props, "");
7350 RegCloseKey(props);
7351 RegDeleteKeyA(userkey, "");
7352 RegCloseKey(userkey);
7353 RegDeleteKeyA(prodkey, "");
7354 RegCloseKey(prodkey);
7356 DeleteFileA(msifile);
7359 START_TEST(msi)
7361 init_functionpointers();
7363 test_usefeature();
7364 test_null();
7365 test_getcomponentpath();
7366 test_MsiGetFileHash();
7368 if (!pConvertSidToStringSidA)
7369 skip("ConvertSidToStringSidA not implemented\n");
7370 else
7372 /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
7373 test_MsiQueryProductState();
7374 test_MsiQueryFeatureState();
7375 test_MsiQueryComponentState();
7376 test_MsiGetComponentPath();
7377 test_MsiGetProductCode();
7378 test_MsiEnumClients();
7379 test_MsiGetProductInfo();
7380 test_MsiGetProductInfoEx();
7381 test_MsiGetUserInfo();
7382 test_MsiOpenProduct();
7385 test_MsiGetFileVersion();