push 5b66f3b36e7323272378316c923222b908f6e2d3
[wine/hacks.git] / dlls / msi / tests / msi.c
blob0e262ae78c081a83ee4ac880910517c8b9da78a9
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 state = MAGIC_ERROR;
1241 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
1242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1243 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1245 RegDeleteValueA(prodkey, "LocalPackage");
1246 RegDeleteKeyA(prodkey, "");
1247 RegDeleteValueA(compkey, prod_squashed);
1248 RegDeleteKeyA(prodkey, "");
1249 RegCloseKey(prodkey);
1250 RegCloseKey(compkey);
1252 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1254 state = MAGIC_ERROR;
1255 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1256 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1257 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1259 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1260 lstrcatA(keypath, prod_squashed);
1262 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1263 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1265 state = MAGIC_ERROR;
1266 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1267 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1268 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1270 RegDeleteKeyA(prodkey, "");
1271 RegCloseKey(prodkey);
1273 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1274 lstrcatA(keypath, usersid);
1275 lstrcatA(keypath, "\\Products\\");
1276 lstrcatA(keypath, prod_squashed);
1277 lstrcatA(keypath, "\\InstallProperties");
1279 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1280 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1282 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1283 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1285 RegCloseKey(prodkey);
1287 state = MAGIC_ERROR;
1288 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1289 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1290 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1292 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1293 lstrcatA(keypath, usersid);
1294 lstrcatA(keypath, "\\Components\\");
1295 lstrcatA(keypath, comp_squashed);
1297 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1298 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1300 /* component key exists */
1301 state = MAGIC_ERROR;
1302 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1303 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1304 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1306 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
1307 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1309 /* component\product exists */
1310 state = MAGIC_ERROR;
1311 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1312 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1313 ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
1315 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
1316 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1318 state = MAGIC_ERROR;
1319 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
1320 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1321 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1323 /* MSIINSTALLCONTEXT_USERMANAGED */
1325 state = MAGIC_ERROR;
1326 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1327 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1328 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1330 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1331 lstrcatA(keypath, prod_squashed);
1333 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1334 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1336 state = MAGIC_ERROR;
1337 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1338 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1339 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
1341 RegDeleteKeyA(prodkey, "");
1342 RegCloseKey(prodkey);
1344 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1345 lstrcatA(keypath, usersid);
1346 lstrcatA(keypath, "\\Installer\\Products\\");
1347 lstrcatA(keypath, prod_squashed);
1349 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1350 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1352 state = MAGIC_ERROR;
1353 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1354 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1355 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1357 RegDeleteKeyA(prodkey, "");
1358 RegCloseKey(prodkey);
1360 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1361 lstrcatA(keypath, usersid);
1362 lstrcatA(keypath, "\\Products\\");
1363 lstrcatA(keypath, prod_squashed);
1364 lstrcatA(keypath, "\\InstallProperties");
1366 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1367 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1369 res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
1370 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1372 state = MAGIC_ERROR;
1373 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
1374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1375 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1377 RegDeleteValueA(prodkey, "LocalPackage");
1378 RegDeleteValueA(prodkey, "ManagedLocalPackage");
1379 RegDeleteKeyA(prodkey, "");
1380 RegDeleteValueA(compkey, prod_squashed);
1381 RegDeleteKeyA(compkey, "");
1382 RegCloseKey(prodkey);
1383 RegCloseKey(compkey);
1386 static void test_MsiGetComponentPath(void)
1388 HKEY compkey, prodkey, installprop;
1389 CHAR prodcode[MAX_PATH];
1390 CHAR prod_squashed[MAX_PATH];
1391 CHAR component[MAX_PATH];
1392 CHAR comp_base85[MAX_PATH];
1393 CHAR comp_squashed[MAX_PATH];
1394 CHAR keypath[MAX_PATH];
1395 CHAR path[MAX_PATH];
1396 INSTALLSTATE state;
1397 LPSTR usersid;
1398 DWORD size, val;
1399 LONG res;
1401 create_test_guid(prodcode, prod_squashed);
1402 compose_base85_guid(component, comp_base85, comp_squashed);
1403 get_user_sid(&usersid);
1405 /* NULL szProduct */
1406 size = MAX_PATH;
1407 state = MsiGetComponentPathA(NULL, component, path, &size);
1408 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1409 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1411 /* NULL szComponent */
1412 size = MAX_PATH;
1413 state = MsiGetComponentPathA(prodcode, NULL, path, &size);
1414 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1415 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1417 /* NULL lpPathBuf */
1418 size = MAX_PATH;
1419 state = MsiGetComponentPathA(prodcode, component, NULL, &size);
1420 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1421 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1423 /* NULL pcchBuf */
1424 size = MAX_PATH;
1425 state = MsiGetComponentPathA(prodcode, component, path, NULL);
1426 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1427 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1429 /* all params valid */
1430 size = MAX_PATH;
1431 state = MsiGetComponentPathA(prodcode, component, path, &size);
1432 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1433 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1435 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1436 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1437 lstrcatA(keypath, comp_squashed);
1439 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1440 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1442 /* local system component key exists */
1443 size = MAX_PATH;
1444 state = MsiGetComponentPathA(prodcode, component, path, &size);
1445 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1446 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1448 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1449 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1451 /* product value exists */
1452 size = MAX_PATH;
1453 state = MsiGetComponentPathA(prodcode, component, path, &size);
1454 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1455 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1456 ok(size == 10, "Expected 10, got %d\n", size);
1458 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1459 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1460 lstrcatA(keypath, prod_squashed);
1461 lstrcatA(keypath, "\\InstallProperties");
1463 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1464 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1466 val = 1;
1467 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1468 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1470 /* install properties key exists */
1471 size = MAX_PATH;
1472 state = MsiGetComponentPathA(prodcode, component, path, &size);
1473 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1474 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1475 ok(size == 10, "Expected 10, got %d\n", size);
1477 create_file("C:\\imapath", "C:\\imapath", 11);
1479 /* file exists */
1480 size = MAX_PATH;
1481 state = MsiGetComponentPathA(prodcode, component, path, &size);
1482 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1483 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1484 ok(size == 10, "Expected 10, got %d\n", size);
1486 RegDeleteValueA(compkey, prod_squashed);
1487 RegDeleteKeyA(compkey, "");
1488 RegDeleteValueA(installprop, "WindowsInstaller");
1489 RegDeleteKeyA(installprop, "");
1490 RegCloseKey(compkey);
1491 RegCloseKey(installprop);
1492 DeleteFileA("C:\\imapath");
1494 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1495 lstrcatA(keypath, "Installer\\UserData\\");
1496 lstrcatA(keypath, usersid);
1497 lstrcatA(keypath, "\\Components\\");
1498 lstrcatA(keypath, comp_squashed);
1500 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1501 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1503 /* user managed component key exists */
1504 size = MAX_PATH;
1505 state = MsiGetComponentPathA(prodcode, component, path, &size);
1506 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1507 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1509 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1510 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1512 /* product value exists */
1513 size = MAX_PATH;
1514 state = MsiGetComponentPathA(prodcode, component, path, &size);
1515 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1516 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1517 ok(size == 10, "Expected 10, got %d\n", size);
1519 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1520 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1521 lstrcatA(keypath, prod_squashed);
1522 lstrcatA(keypath, "\\InstallProperties");
1524 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1525 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1527 val = 1;
1528 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1529 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1531 /* install properties key exists */
1532 size = MAX_PATH;
1533 state = MsiGetComponentPathA(prodcode, component, path, &size);
1534 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1535 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1536 ok(size == 10, "Expected 10, got %d\n", size);
1538 create_file("C:\\imapath", "C:\\imapath", 11);
1540 /* file exists */
1541 size = MAX_PATH;
1542 state = MsiGetComponentPathA(prodcode, component, path, &size);
1543 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1544 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1545 ok(size == 10, "Expected 10, got %d\n", size);
1547 RegDeleteValueA(compkey, prod_squashed);
1548 RegDeleteKeyA(compkey, "");
1549 RegDeleteValueA(installprop, "WindowsInstaller");
1550 RegDeleteKeyA(installprop, "");
1551 RegCloseKey(compkey);
1552 RegCloseKey(installprop);
1553 DeleteFileA("C:\\imapath");
1555 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1556 lstrcatA(keypath, "Installer\\Managed\\");
1557 lstrcatA(keypath, usersid);
1558 lstrcatA(keypath, "\\Installer\\Products\\");
1559 lstrcatA(keypath, prod_squashed);
1561 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1562 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1564 /* user managed product key exists */
1565 size = MAX_PATH;
1566 state = MsiGetComponentPathA(prodcode, component, path, &size);
1567 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1568 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1570 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1571 lstrcatA(keypath, "Installer\\UserData\\");
1572 lstrcatA(keypath, usersid);
1573 lstrcatA(keypath, "\\Components\\");
1574 lstrcatA(keypath, comp_squashed);
1576 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1577 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1579 /* user managed component key exists */
1580 size = MAX_PATH;
1581 state = MsiGetComponentPathA(prodcode, component, path, &size);
1582 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1583 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1585 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1586 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1588 /* product value exists */
1589 size = MAX_PATH;
1590 state = MsiGetComponentPathA(prodcode, component, path, &size);
1591 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1592 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1593 ok(size == 10, "Expected 10, got %d\n", size);
1595 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1596 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1597 lstrcatA(keypath, prod_squashed);
1598 lstrcatA(keypath, "\\InstallProperties");
1600 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1601 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1603 val = 1;
1604 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1605 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1607 /* install properties key exists */
1608 size = MAX_PATH;
1609 state = MsiGetComponentPathA(prodcode, component, path, &size);
1610 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1611 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1612 ok(size == 10, "Expected 10, got %d\n", size);
1614 create_file("C:\\imapath", "C:\\imapath", 11);
1616 /* file exists */
1617 size = MAX_PATH;
1618 state = MsiGetComponentPathA(prodcode, component, path, &size);
1619 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1620 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1621 ok(size == 10, "Expected 10, got %d\n", size);
1623 RegDeleteValueA(compkey, prod_squashed);
1624 RegDeleteKeyA(prodkey, "");
1625 RegDeleteKeyA(compkey, "");
1626 RegDeleteValueA(installprop, "WindowsInstaller");
1627 RegDeleteKeyA(installprop, "");
1628 RegCloseKey(prodkey);
1629 RegCloseKey(compkey);
1630 RegCloseKey(installprop);
1631 DeleteFileA("C:\\imapath");
1633 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1634 lstrcatA(keypath, prod_squashed);
1636 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1637 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1639 /* user unmanaged product key exists */
1640 size = MAX_PATH;
1641 state = MsiGetComponentPathA(prodcode, component, path, &size);
1642 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1643 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1645 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1646 lstrcatA(keypath, "Installer\\UserData\\");
1647 lstrcatA(keypath, usersid);
1648 lstrcatA(keypath, "\\Components\\");
1649 lstrcatA(keypath, comp_squashed);
1651 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1652 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1654 /* user unmanaged component key exists */
1655 size = MAX_PATH;
1656 state = MsiGetComponentPathA(prodcode, component, path, &size);
1657 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1658 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1660 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1661 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1663 /* product value exists */
1664 size = MAX_PATH;
1665 state = MsiGetComponentPathA(prodcode, component, path, &size);
1666 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1667 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1668 ok(size == 10, "Expected 10, got %d\n", size);
1670 create_file("C:\\imapath", "C:\\imapath", 11);
1672 /* file exists */
1673 size = MAX_PATH;
1674 state = MsiGetComponentPathA(prodcode, component, path, &size);
1675 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1676 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1677 ok(size == 10, "Expected 10, got %d\n", size);
1679 RegDeleteValueA(compkey, prod_squashed);
1680 RegDeleteKeyA(prodkey, "");
1681 RegDeleteKeyA(compkey, "");
1682 RegCloseKey(prodkey);
1683 RegCloseKey(compkey);
1684 RegCloseKey(installprop);
1685 DeleteFileA("C:\\imapath");
1687 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1688 lstrcatA(keypath, prod_squashed);
1690 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1691 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1693 /* local classes product key exists */
1694 size = MAX_PATH;
1695 state = MsiGetComponentPathA(prodcode, component, path, &size);
1696 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1697 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1699 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1700 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1701 lstrcatA(keypath, comp_squashed);
1703 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1704 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1706 /* local user component key exists */
1707 size = MAX_PATH;
1708 state = MsiGetComponentPathA(prodcode, component, path, &size);
1709 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1710 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1712 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1713 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1715 /* product value exists */
1716 size = MAX_PATH;
1717 state = MsiGetComponentPathA(prodcode, component, path, &size);
1718 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1719 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1720 ok(size == 10, "Expected 10, got %d\n", size);
1722 create_file("C:\\imapath", "C:\\imapath", 11);
1724 /* file exists */
1725 size = MAX_PATH;
1726 state = MsiGetComponentPathA(prodcode, component, path, &size);
1727 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1728 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1729 ok(size == 10, "Expected 10, got %d\n", size);
1731 RegDeleteValueA(compkey, prod_squashed);
1732 RegDeleteKeyA(prodkey, "");
1733 RegDeleteKeyA(compkey, "");
1734 RegCloseKey(prodkey);
1735 RegCloseKey(compkey);
1736 DeleteFileA("C:\\imapath");
1739 static void test_MsiGetProductCode(void)
1741 HKEY compkey, prodkey;
1742 CHAR prodcode[MAX_PATH];
1743 CHAR prod_squashed[MAX_PATH];
1744 CHAR prodcode2[MAX_PATH];
1745 CHAR prod2_squashed[MAX_PATH];
1746 CHAR component[MAX_PATH];
1747 CHAR comp_base85[MAX_PATH];
1748 CHAR comp_squashed[MAX_PATH];
1749 CHAR keypath[MAX_PATH];
1750 CHAR product[MAX_PATH];
1751 LPSTR usersid;
1752 LONG res;
1753 UINT r;
1755 create_test_guid(prodcode, prod_squashed);
1756 create_test_guid(prodcode2, prod2_squashed);
1757 compose_base85_guid(component, comp_base85, comp_squashed);
1758 get_user_sid(&usersid);
1760 /* szComponent is NULL */
1761 lstrcpyA(product, "prod");
1762 r = MsiGetProductCodeA(NULL, product);
1763 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1764 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1766 /* szComponent is empty */
1767 lstrcpyA(product, "prod");
1768 r = MsiGetProductCodeA("", product);
1769 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1770 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1772 /* garbage szComponent */
1773 lstrcpyA(product, "prod");
1774 r = MsiGetProductCodeA("garbage", product);
1775 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1776 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1778 /* guid without brackets */
1779 lstrcpyA(product, "prod");
1780 r = MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product);
1781 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1782 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1784 /* guid with brackets */
1785 lstrcpyA(product, "prod");
1786 r = MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product);
1787 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1788 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1790 /* same length as guid, but random */
1791 lstrcpyA(product, "prod");
1792 r = MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product);
1793 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1794 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1796 /* all params correct, szComponent not published */
1797 lstrcpyA(product, "prod");
1798 r = MsiGetProductCodeA(component, product);
1799 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1800 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1802 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1803 lstrcatA(keypath, "Installer\\UserData\\");
1804 lstrcatA(keypath, usersid);
1805 lstrcatA(keypath, "\\Components\\");
1806 lstrcatA(keypath, comp_squashed);
1808 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1809 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1811 /* user unmanaged component key exists */
1812 lstrcpyA(product, "prod");
1813 r = MsiGetProductCodeA(component, product);
1814 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1815 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1817 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1818 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1820 /* product value exists */
1821 lstrcpyA(product, "prod");
1822 r = MsiGetProductCodeA(component, product);
1823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1824 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1826 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1827 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1829 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1830 lstrcatA(keypath, "Installer\\Managed\\");
1831 lstrcatA(keypath, usersid);
1832 lstrcatA(keypath, "\\Installer\\Products\\");
1833 lstrcatA(keypath, prod_squashed);
1835 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1836 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1838 /* user managed product key of first product exists */
1839 lstrcpyA(product, "prod");
1840 r = MsiGetProductCodeA(component, product);
1841 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1842 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1844 RegDeleteKeyA(prodkey, "");
1845 RegCloseKey(prodkey);
1847 RegDeleteKeyA(prodkey, "");
1848 RegCloseKey(prodkey);
1850 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1851 lstrcatA(keypath, prod_squashed);
1853 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1854 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1856 /* user unmanaged product key exists */
1857 lstrcpyA(product, "prod");
1858 r = MsiGetProductCodeA(component, product);
1859 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1860 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1862 RegDeleteKeyA(prodkey, "");
1863 RegCloseKey(prodkey);
1865 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1866 lstrcatA(keypath, prod_squashed);
1868 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1869 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1871 /* local classes product key exists */
1872 lstrcpyA(product, "prod");
1873 r = MsiGetProductCodeA(component, product);
1874 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1875 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1877 RegDeleteKeyA(prodkey, "");
1878 RegCloseKey(prodkey);
1880 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1881 lstrcatA(keypath, "Installer\\Managed\\");
1882 lstrcatA(keypath, usersid);
1883 lstrcatA(keypath, "\\Installer\\Products\\");
1884 lstrcatA(keypath, prod2_squashed);
1886 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1887 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1889 /* user managed product key of second product exists */
1890 lstrcpyA(product, "prod");
1891 r = MsiGetProductCodeA(component, product);
1892 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1893 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
1895 RegDeleteKeyA(prodkey, "");
1896 RegCloseKey(prodkey);
1897 RegDeleteValueA(compkey, prod_squashed);
1898 RegDeleteValueA(compkey, prod2_squashed);
1899 RegDeleteKeyA(compkey, "");
1900 RegCloseKey(compkey);
1902 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1903 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1904 lstrcatA(keypath, comp_squashed);
1906 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1907 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1909 /* local user component key exists */
1910 lstrcpyA(product, "prod");
1911 r = MsiGetProductCodeA(component, product);
1912 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1913 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1915 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1916 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1918 /* product value exists */
1919 lstrcpyA(product, "prod");
1920 r = MsiGetProductCodeA(component, product);
1921 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1922 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1924 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1925 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1927 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1928 lstrcatA(keypath, "Installer\\Managed\\");
1929 lstrcatA(keypath, usersid);
1930 lstrcatA(keypath, "\\Installer\\Products\\");
1931 lstrcatA(keypath, prod_squashed);
1933 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1934 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1936 /* user managed product key of first product exists */
1937 lstrcpyA(product, "prod");
1938 r = MsiGetProductCodeA(component, product);
1939 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1940 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1942 RegDeleteKeyA(prodkey, "");
1943 RegCloseKey(prodkey);
1945 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1946 lstrcatA(keypath, prod_squashed);
1948 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1949 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1951 /* user unmanaged product key exists */
1952 lstrcpyA(product, "prod");
1953 r = MsiGetProductCodeA(component, product);
1954 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1955 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1957 RegDeleteKeyA(prodkey, "");
1958 RegCloseKey(prodkey);
1960 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1961 lstrcatA(keypath, prod_squashed);
1963 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1964 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1966 /* local classes product key exists */
1967 lstrcpyA(product, "prod");
1968 r = MsiGetProductCodeA(component, product);
1969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1970 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1972 RegDeleteKeyA(prodkey, "");
1973 RegCloseKey(prodkey);
1975 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1976 lstrcatA(keypath, "Installer\\Managed\\");
1977 lstrcatA(keypath, usersid);
1978 lstrcatA(keypath, "\\Installer\\Products\\");
1979 lstrcatA(keypath, prod2_squashed);
1981 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1982 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1984 /* user managed product key of second product exists */
1985 lstrcpyA(product, "prod");
1986 r = MsiGetProductCodeA(component, product);
1987 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1988 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
1990 RegDeleteKeyA(prodkey, "");
1991 RegCloseKey(prodkey);
1992 RegDeleteValueA(compkey, prod_squashed);
1993 RegDeleteValueA(compkey, prod2_squashed);
1994 RegDeleteKeyA(compkey, "");
1995 RegCloseKey(compkey);
1998 static void test_MsiEnumClients(void)
2000 HKEY compkey;
2001 CHAR prodcode[MAX_PATH];
2002 CHAR prod_squashed[MAX_PATH];
2003 CHAR prodcode2[MAX_PATH];
2004 CHAR prod2_squashed[MAX_PATH];
2005 CHAR component[MAX_PATH];
2006 CHAR comp_base85[MAX_PATH];
2007 CHAR comp_squashed[MAX_PATH];
2008 CHAR product[MAX_PATH];
2009 CHAR keypath[MAX_PATH];
2010 LPSTR usersid;
2011 LONG res;
2012 UINT r;
2014 create_test_guid(prodcode, prod_squashed);
2015 create_test_guid(prodcode2, prod2_squashed);
2016 compose_base85_guid(component, comp_base85, comp_squashed);
2017 get_user_sid(&usersid);
2019 /* NULL szComponent */
2020 product[0] = '\0';
2021 r = MsiEnumClientsA(NULL, 0, product);
2022 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2023 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2025 /* empty szComponent */
2026 product[0] = '\0';
2027 r = MsiEnumClientsA("", 0, product);
2028 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2029 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2031 /* NULL lpProductBuf */
2032 r = MsiEnumClientsA(component, 0, NULL);
2033 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2035 /* all params correct, component missing */
2036 product[0] = '\0';
2037 r = MsiEnumClientsA(component, 0, product);
2038 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2039 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2041 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2042 lstrcatA(keypath, "Installer\\UserData\\");
2043 lstrcatA(keypath, usersid);
2044 lstrcatA(keypath, "\\Components\\");
2045 lstrcatA(keypath, comp_squashed);
2047 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
2048 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2050 /* user unmanaged component key exists */
2051 product[0] = '\0';
2052 r = MsiEnumClientsA(component, 0, product);
2053 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2054 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2056 /* index > 0, no products exist */
2057 product[0] = '\0';
2058 r = MsiEnumClientsA(component, 1, 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 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2063 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2065 /* product value exists */
2066 r = MsiEnumClientsA(component, 0, product);
2067 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2068 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2070 /* try index 0 again */
2071 product[0] = '\0';
2072 r = MsiEnumClientsA(component, 0, product);
2073 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2074 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2076 /* try index 1, second product value does not exist */
2077 product[0] = '\0';
2078 r = MsiEnumClientsA(component, 1, product);
2079 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2080 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2082 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
2083 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2085 /* try index 1, second product value does exist */
2086 product[0] = '\0';
2087 r = MsiEnumClientsA(component, 1, product);
2088 todo_wine
2090 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2091 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2094 /* start the enumeration over */
2095 product[0] = '\0';
2096 r = MsiEnumClientsA(component, 0, product);
2097 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2098 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2099 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2101 /* correctly query second product */
2102 product[0] = '\0';
2103 r = MsiEnumClientsA(component, 1, product);
2104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2105 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2106 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2108 RegDeleteValueA(compkey, prod_squashed);
2109 RegDeleteValueA(compkey, prod2_squashed);
2110 RegDeleteKeyA(compkey, "");
2111 RegCloseKey(compkey);
2113 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2114 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
2115 lstrcatA(keypath, comp_squashed);
2117 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
2118 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2120 /* user local component key exists */
2121 product[0] = '\0';
2122 r = MsiEnumClientsA(component, 0, product);
2123 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2124 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2126 /* index > 0, no products exist */
2127 product[0] = '\0';
2128 r = MsiEnumClientsA(component, 1, product);
2129 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2130 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2132 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2133 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2135 /* product value exists */
2136 product[0] = '\0';
2137 r = MsiEnumClientsA(component, 0, product);
2138 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2139 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
2141 /* try index 0 again */
2142 product[0] = '\0';
2143 r = MsiEnumClientsA(component, 0, product);
2144 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2146 /* try index 1, second product value does not exist */
2147 product[0] = '\0';
2148 r = MsiEnumClientsA(component, 1, product);
2149 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
2150 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2152 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
2153 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2155 /* try index 1, second product value does exist */
2156 product[0] = '\0';
2157 r = MsiEnumClientsA(component, 1, product);
2158 todo_wine
2160 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2161 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
2164 /* start the enumeration over */
2165 product[0] = '\0';
2166 r = MsiEnumClientsA(component, 0, product);
2167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2168 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2169 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2171 /* correctly query second product */
2172 product[0] = '\0';
2173 r = MsiEnumClientsA(component, 1, product);
2174 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2175 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
2176 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
2178 RegDeleteValueA(compkey, prod_squashed);
2179 RegDeleteValueA(compkey, prod2_squashed);
2180 RegDeleteKeyA(compkey, "");
2181 RegCloseKey(compkey);
2184 static void get_version_info(LPSTR path, LPSTR *vercheck, LPDWORD verchecksz,
2185 LPSTR *langcheck, LPDWORD langchecksz)
2187 LPSTR version;
2188 VS_FIXEDFILEINFO *ffi;
2189 DWORD size = GetFileVersionInfoSizeA(path, NULL);
2190 USHORT *lang;
2192 version = HeapAlloc(GetProcessHeap(), 0, size);
2193 GetFileVersionInfoA(path, 0, size, version);
2195 VerQueryValueA(version, "\\", (LPVOID *)&ffi, &size);
2196 *vercheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
2197 sprintf(*vercheck, "%d.%d.%d.%d", HIWORD(ffi->dwFileVersionMS),
2198 LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionLS),
2199 LOWORD(ffi->dwFileVersionLS));
2200 *verchecksz = lstrlenA(*vercheck);
2202 VerQueryValue(version, "\\VarFileInfo\\Translation", (void **)&lang, &size);
2203 *langcheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
2204 sprintf(*langcheck, "%d", *lang);
2205 *langchecksz = lstrlenA(*langcheck);
2207 HeapFree(GetProcessHeap(), 0, version);
2210 static void test_MsiGetFileVersion(void)
2212 UINT r;
2213 DWORD versz, langsz;
2214 char version[MAX_PATH];
2215 char lang[MAX_PATH];
2216 char path[MAX_PATH];
2217 LPSTR vercheck, langcheck;
2218 DWORD verchecksz, langchecksz;
2220 /* NULL szFilePath */
2221 versz = MAX_PATH;
2222 langsz = MAX_PATH;
2223 lstrcpyA(version, "version");
2224 lstrcpyA(lang, "lang");
2225 r = MsiGetFileVersionA(NULL, version, &versz, lang, &langsz);
2226 ok(r == ERROR_INVALID_PARAMETER,
2227 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2228 ok(!lstrcmpA(version, "version"),
2229 "Expected version to be unchanged, got %s\n", version);
2230 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2231 ok(!lstrcmpA(lang, "lang"),
2232 "Expected lang to be unchanged, got %s\n", lang);
2233 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2235 /* empty szFilePath */
2236 versz = MAX_PATH;
2237 langsz = MAX_PATH;
2238 lstrcpyA(version, "version");
2239 lstrcpyA(lang, "lang");
2240 r = MsiGetFileVersionA("", version, &versz, lang, &langsz);
2241 ok(r == ERROR_FILE_NOT_FOUND,
2242 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2243 ok(!lstrcmpA(version, "version"),
2244 "Expected version to be unchanged, got %s\n", version);
2245 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2246 ok(!lstrcmpA(lang, "lang"),
2247 "Expected lang to be unchanged, got %s\n", lang);
2248 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2250 /* nonexistent szFilePath */
2251 versz = MAX_PATH;
2252 langsz = MAX_PATH;
2253 lstrcpyA(version, "version");
2254 lstrcpyA(lang, "lang");
2255 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2256 ok(r == ERROR_FILE_NOT_FOUND,
2257 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2258 ok(!lstrcmpA(version, "version"),
2259 "Expected version to be unchanged, got %s\n", version);
2260 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2261 ok(!lstrcmpA(lang, "lang"),
2262 "Expected lang to be unchanged, got %s\n", lang);
2263 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2265 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
2266 versz = MAX_PATH;
2267 langsz = MAX_PATH;
2268 lstrcpyA(version, "version");
2269 lstrcpyA(lang, "lang");
2270 r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz);
2271 ok(r == ERROR_INVALID_PARAMETER,
2272 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2273 ok(!lstrcmpA(version, "version"),
2274 "Expected version to be unchanged, got %s\n", version);
2275 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2276 ok(!lstrcmpA(lang, "lang"),
2277 "Expected lang to be unchanged, got %s\n", lang);
2278 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2280 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
2281 versz = MAX_PATH;
2282 langsz = MAX_PATH;
2283 lstrcpyA(version, "version");
2284 lstrcpyA(lang, "lang");
2285 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL);
2286 ok(r == ERROR_INVALID_PARAMETER,
2287 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2288 ok(!lstrcmpA(version, "version"),
2289 "Expected version to be unchanged, got %s\n", version);
2290 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2291 ok(!lstrcmpA(lang, "lang"),
2292 "Expected lang to be unchanged, got %s\n", lang);
2293 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2295 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
2296 versz = 0;
2297 langsz = MAX_PATH;
2298 lstrcpyA(version, "version");
2299 lstrcpyA(lang, "lang");
2300 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2301 ok(r == ERROR_FILE_NOT_FOUND,
2302 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2303 ok(!lstrcmpA(version, "version"),
2304 "Expected version to be unchanged, got %s\n", version);
2305 ok(versz == 0, "Expected 0, got %d\n", versz);
2306 ok(!lstrcmpA(lang, "lang"),
2307 "Expected lang to be unchanged, got %s\n", lang);
2308 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2310 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
2311 versz = MAX_PATH;
2312 langsz = 0;
2313 lstrcpyA(version, "version");
2314 lstrcpyA(lang, "lang");
2315 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
2316 ok(r == ERROR_FILE_NOT_FOUND,
2317 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2318 ok(!lstrcmpA(version, "version"),
2319 "Expected version to be unchanged, got %s\n", version);
2320 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2321 ok(!lstrcmpA(lang, "lang"),
2322 "Expected lang to be unchanged, got %s\n", lang);
2323 ok(langsz == 0, "Expected 0, got %d\n", langsz);
2325 /* nonexistent szFilePath, rest NULL */
2326 r = MsiGetFileVersionA("nonexistent", NULL, NULL, NULL, NULL);
2327 ok(r == ERROR_FILE_NOT_FOUND,
2328 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2330 create_file("ver.txt", "ver.txt", 20);
2332 /* file exists, no version information */
2333 versz = MAX_PATH;
2334 langsz = MAX_PATH;
2335 lstrcpyA(version, "version");
2336 lstrcpyA(lang, "lang");
2337 r = MsiGetFileVersionA("ver.txt", version, &versz, lang, &langsz);
2338 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2339 ok(!lstrcmpA(version, "version"),
2340 "Expected version to be unchanged, got %s\n", version);
2341 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2342 ok(!lstrcmpA(lang, "lang"),
2343 "Expected lang to be unchanged, got %s\n", lang);
2344 ok(r == ERROR_FILE_INVALID,
2345 "Expected ERROR_FILE_INVALID, got %d\n", r);
2347 DeleteFileA("ver.txt");
2349 /* relative path, has version information */
2350 versz = MAX_PATH;
2351 langsz = MAX_PATH;
2352 lstrcpyA(version, "version");
2353 lstrcpyA(lang, "lang");
2354 r = MsiGetFileVersionA("kernel32.dll", version, &versz, lang, &langsz);
2355 todo_wine
2357 ok(r == ERROR_FILE_NOT_FOUND,
2358 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2359 ok(!lstrcmpA(version, "version"),
2360 "Expected version to be unchanged, got %s\n", version);
2361 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
2362 ok(!lstrcmpA(lang, "lang"),
2363 "Expected lang to be unchanged, got %s\n", lang);
2364 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
2367 GetSystemDirectoryA(path, MAX_PATH);
2368 lstrcatA(path, "\\kernel32.dll");
2370 get_version_info(path, &vercheck, &verchecksz, &langcheck, &langchecksz);
2372 /* absolute path, has version information */
2373 versz = MAX_PATH;
2374 langsz = MAX_PATH;
2375 lstrcpyA(version, "version");
2376 lstrcpyA(lang, "lang");
2377 r = MsiGetFileVersionA(path, version, &versz, lang, &langsz);
2378 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2379 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2380 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
2381 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2382 ok(!lstrcmpA(version, vercheck),
2383 "Expected %s, got %s\n", vercheck, version);
2385 /* only check version */
2386 versz = MAX_PATH;
2387 lstrcpyA(version, "version");
2388 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
2389 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2390 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2391 ok(!lstrcmpA(version, vercheck),
2392 "Expected %s, got %s\n", vercheck, version);
2394 /* only check language */
2395 langsz = MAX_PATH;
2396 lstrcpyA(lang, "lang");
2397 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2398 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2399 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
2400 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2402 /* check neither version nor language */
2403 r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
2404 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2406 /* get pcchVersionBuf */
2407 versz = MAX_PATH;
2408 r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL);
2409 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2410 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2412 /* get pcchLangBuf */
2413 langsz = MAX_PATH;
2414 r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
2415 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2416 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2418 /* pcchVersionBuf not big enough */
2419 versz = 5;
2420 lstrcpyA(version, "version");
2421 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
2422 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2423 ok(!strncmp(version, vercheck, 4),
2424 "Expected first 4 characters of %s, got %s\n", vercheck, version);
2425 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2427 /* pcchLangBuf not big enough */
2428 langsz = 3;
2429 lstrcpyA(lang, "lang");
2430 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2431 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2432 ok(!strncmp(lang, langcheck, 2),
2433 "Expected first character of %s, got %s\n", langcheck, lang);
2434 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2436 HeapFree(GetProcessHeap(), 0, vercheck);
2437 HeapFree(GetProcessHeap(), 0, langcheck);
2440 static void test_MsiGetProductInfo(void)
2442 UINT r;
2443 LONG res;
2444 HKEY propkey, source;
2445 HKEY prodkey, localkey;
2446 CHAR prodcode[MAX_PATH];
2447 CHAR prod_squashed[MAX_PATH];
2448 CHAR packcode[MAX_PATH];
2449 CHAR pack_squashed[MAX_PATH];
2450 CHAR buf[MAX_PATH];
2451 CHAR keypath[MAX_PATH];
2452 LPSTR usersid;
2453 DWORD sz, val = 42;
2455 create_test_guid(prodcode, prod_squashed);
2456 create_test_guid(packcode, pack_squashed);
2457 get_user_sid(&usersid);
2459 /* NULL szProduct */
2460 sz = MAX_PATH;
2461 lstrcpyA(buf, "apple");
2462 r = MsiGetProductInfoA(NULL, INSTALLPROPERTY_HELPLINK, buf, &sz);
2463 ok(r == ERROR_INVALID_PARAMETER,
2464 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2465 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2466 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2468 /* empty szProduct */
2469 sz = MAX_PATH;
2470 lstrcpyA(buf, "apple");
2471 r = MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINK, buf, &sz);
2472 ok(r == ERROR_INVALID_PARAMETER,
2473 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2474 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2475 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2477 /* garbage szProduct */
2478 sz = MAX_PATH;
2479 lstrcpyA(buf, "apple");
2480 r = MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINK, buf, &sz);
2481 ok(r == ERROR_INVALID_PARAMETER,
2482 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2483 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2484 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2486 /* guid without brackets */
2487 sz = MAX_PATH;
2488 lstrcpyA(buf, "apple");
2489 r = MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
2490 INSTALLPROPERTY_HELPLINK, buf, &sz);
2491 ok(r == ERROR_INVALID_PARAMETER,
2492 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2493 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2494 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2496 /* guid with brackets */
2497 sz = MAX_PATH;
2498 lstrcpyA(buf, "apple");
2499 r = MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
2500 INSTALLPROPERTY_HELPLINK, buf, &sz);
2501 ok(r == ERROR_UNKNOWN_PRODUCT,
2502 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2503 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2504 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2506 /* same length as guid, but random */
2507 sz = MAX_PATH;
2508 lstrcpyA(buf, "apple");
2509 r = MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
2510 INSTALLPROPERTY_HELPLINK, buf, &sz);
2511 ok(r == ERROR_INVALID_PARAMETER,
2512 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2513 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2514 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2516 /* not installed, NULL szAttribute */
2517 sz = MAX_PATH;
2518 lstrcpyA(buf, "apple");
2519 r = MsiGetProductInfoA(prodcode, NULL, buf, &sz);
2520 ok(r == ERROR_INVALID_PARAMETER,
2521 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2522 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2523 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2525 /* not installed, NULL lpValueBuf */
2526 sz = MAX_PATH;
2527 lstrcpyA(buf, "apple");
2528 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2529 ok(r == ERROR_UNKNOWN_PRODUCT,
2530 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2531 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2532 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2534 /* not installed, NULL pcchValueBuf */
2535 sz = MAX_PATH;
2536 lstrcpyA(buf, "apple");
2537 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, NULL);
2538 ok(r == ERROR_INVALID_PARAMETER,
2539 "Expected ERROR_INVALID_PARAMETER, 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 /* created guid cannot possibly be an installed product code */
2544 sz = MAX_PATH;
2545 lstrcpyA(buf, "apple");
2546 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2547 ok(r == ERROR_UNKNOWN_PRODUCT,
2548 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2549 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2550 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2552 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2553 lstrcatA(keypath, usersid);
2554 lstrcatA(keypath, "\\Installer\\Products\\");
2555 lstrcatA(keypath, prod_squashed);
2557 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2558 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2560 /* managed product code exists */
2561 sz = MAX_PATH;
2562 lstrcpyA(buf, "apple");
2563 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2564 ok(r == ERROR_UNKNOWN_PROPERTY,
2565 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2566 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2567 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2569 RegDeleteKeyA(prodkey, "");
2570 RegCloseKey(prodkey);
2572 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2573 lstrcatA(keypath, usersid);
2574 lstrcatA(keypath, "\\Products\\");
2575 lstrcatA(keypath, prod_squashed);
2577 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2578 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2580 /* local user product code exists */
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 /* both local and managed product code exist */
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 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2607 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2609 /* InstallProperties key exists */
2610 sz = MAX_PATH;
2611 lstrcpyA(buf, "apple");
2612 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2613 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2614 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2615 ok(sz == 0, "Expected 0, got %d\n", sz);
2617 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2618 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2620 /* HelpLink value exists */
2621 sz = MAX_PATH;
2622 lstrcpyA(buf, "apple");
2623 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2624 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2625 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2626 ok(sz == 4, "Expected 4, got %d\n", sz);
2628 /* pcchBuf is NULL */
2629 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, NULL);
2630 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2632 /* lpValueBuf is NULL */
2633 sz = MAX_PATH;
2634 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2635 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2636 ok(sz == 4, "Expected 4, got %d\n", sz);
2638 /* lpValueBuf is NULL, pcchValueBuf is too small */
2639 sz = 2;
2640 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2641 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2642 ok(sz == 4, "Expected 4, got %d\n", sz);
2644 /* lpValueBuf is NULL, pcchValueBuf is too small */
2645 sz = 2;
2646 lstrcpyA(buf, "apple");
2647 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2648 ok(!lstrcmpA(buf, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf);
2649 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2650 ok(sz == 4, "Expected 4, got %d\n", sz);
2652 /* lpValueBuf is NULL, pcchValueBuf is exactly 4 */
2653 sz = 4;
2654 lstrcpyA(buf, "apple");
2655 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2656 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2657 ok(!lstrcmpA(buf, "apple"),
2658 "Expected buf to remain unchanged, got \"%s\"\n", buf);
2659 ok(sz == 4, "Expected 4, got %d\n", sz);
2661 res = RegSetValueExA(propkey, "IMadeThis", 0, REG_SZ, (LPBYTE)"random", 7);
2662 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2664 /* random property not supported by MSI, value exists */
2665 sz = MAX_PATH;
2666 lstrcpyA(buf, "apple");
2667 r = MsiGetProductInfoA(prodcode, "IMadeThis", buf, &sz);
2668 ok(r == ERROR_UNKNOWN_PROPERTY,
2669 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2670 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2671 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2673 RegDeleteValueA(propkey, "IMadeThis");
2674 RegDeleteValueA(propkey, "HelpLink");
2675 RegDeleteKeyA(propkey, "");
2676 RegDeleteKeyA(localkey, "");
2677 RegDeleteKeyA(prodkey, "");
2678 RegCloseKey(propkey);
2679 RegCloseKey(localkey);
2680 RegCloseKey(prodkey);
2682 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2683 lstrcatA(keypath, prod_squashed);
2685 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2686 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2688 /* user product key exists */
2689 sz = MAX_PATH;
2690 lstrcpyA(buf, "apple");
2691 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2692 ok(r == ERROR_UNKNOWN_PROPERTY,
2693 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2694 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2695 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2697 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2698 lstrcatA(keypath, usersid);
2699 lstrcatA(keypath, "\\Products\\");
2700 lstrcatA(keypath, prod_squashed);
2702 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2703 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2705 /* local user product key exists */
2706 sz = MAX_PATH;
2707 lstrcpyA(buf, "apple");
2708 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2709 ok(r == ERROR_UNKNOWN_PROPERTY,
2710 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2711 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2712 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2714 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2715 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2717 /* InstallProperties key exists */
2718 sz = MAX_PATH;
2719 lstrcpyA(buf, "apple");
2720 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2721 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2722 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2723 ok(sz == 0, "Expected 0, got %d\n", sz);
2725 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2726 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2728 /* HelpLink value exists */
2729 sz = MAX_PATH;
2730 lstrcpyA(buf, "apple");
2731 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2733 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2734 ok(sz == 4, "Expected 4, got %d\n", sz);
2736 RegDeleteValueA(propkey, "HelpLink");
2737 RegDeleteKeyA(propkey, "");
2738 RegDeleteKeyA(localkey, "");
2739 RegDeleteKeyA(prodkey, "");
2740 RegCloseKey(propkey);
2741 RegCloseKey(localkey);
2742 RegCloseKey(prodkey);
2744 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2745 lstrcatA(keypath, prod_squashed);
2747 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2748 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2750 /* classes product key exists */
2751 sz = MAX_PATH;
2752 lstrcpyA(buf, "apple");
2753 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2754 ok(r == ERROR_UNKNOWN_PROPERTY,
2755 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2756 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2757 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2759 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2760 lstrcatA(keypath, usersid);
2761 lstrcatA(keypath, "\\Products\\");
2762 lstrcatA(keypath, prod_squashed);
2764 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2765 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2767 /* local user product key exists */
2768 sz = MAX_PATH;
2769 lstrcpyA(buf, "apple");
2770 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2771 ok(r == ERROR_UNKNOWN_PROPERTY,
2772 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2773 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2774 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2776 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2777 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2779 /* InstallProperties key exists */
2780 sz = MAX_PATH;
2781 lstrcpyA(buf, "apple");
2782 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2783 ok(r == ERROR_UNKNOWN_PROPERTY,
2784 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2785 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2786 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2788 RegDeleteKeyA(propkey, "");
2789 RegDeleteKeyA(localkey, "");
2790 RegCloseKey(propkey);
2791 RegCloseKey(localkey);
2793 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2794 lstrcatA(keypath, "S-1-5-18\\\\Products\\");
2795 lstrcatA(keypath, prod_squashed);
2797 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2798 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2800 /* Local System product key exists */
2801 sz = MAX_PATH;
2802 lstrcpyA(buf, "apple");
2803 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2804 ok(r == ERROR_UNKNOWN_PROPERTY,
2805 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2806 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2807 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2809 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2810 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2812 /* InstallProperties key exists */
2813 sz = MAX_PATH;
2814 lstrcpyA(buf, "apple");
2815 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2816 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2817 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2818 ok(sz == 0, "Expected 0, got %d\n", sz);
2820 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2821 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2823 /* HelpLink value exists */
2824 sz = MAX_PATH;
2825 lstrcpyA(buf, "apple");
2826 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2827 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2828 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2829 ok(sz == 4, "Expected 4, got %d\n", sz);
2831 res = RegSetValueExA(propkey, "HelpLink", 0, REG_DWORD,
2832 (const BYTE *)&val, sizeof(DWORD));
2833 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2835 /* HelpLink type is REG_DWORD */
2836 sz = MAX_PATH;
2837 lstrcpyA(buf, "apple");
2838 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2839 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2840 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2841 ok(sz == 2, "Expected 2, got %d\n", sz);
2843 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
2844 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2846 /* DisplayName value exists */
2847 sz = MAX_PATH;
2848 lstrcpyA(buf, "apple");
2849 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
2850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2851 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
2852 ok(sz == 4, "Expected 4, got %d\n", sz);
2854 res = RegSetValueExA(propkey, "DisplayName", 0, REG_DWORD,
2855 (const BYTE *)&val, sizeof(DWORD));
2856 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2858 /* DisplayName type is REG_DWORD */
2859 sz = MAX_PATH;
2860 lstrcpyA(buf, "apple");
2861 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
2862 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2863 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2864 ok(sz == 2, "Expected 2, got %d\n", sz);
2866 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"1.1.1", 6);
2867 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2869 /* DisplayVersion value exists */
2870 sz = MAX_PATH;
2871 lstrcpyA(buf, "apple");
2872 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
2873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2874 ok(!lstrcmpA(buf, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf);
2875 ok(sz == 5, "Expected 5, got %d\n", sz);
2877 res = RegSetValueExA(propkey, "DisplayVersion", 0,
2878 REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
2879 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2881 /* DisplayVersion type is REG_DWORD */
2882 sz = MAX_PATH;
2883 lstrcpyA(buf, "apple");
2884 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
2885 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2886 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2887 ok(sz == 2, "Expected 2, got %d\n", sz);
2889 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"tele", 5);
2890 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2892 /* HelpTelephone value exists */
2893 sz = MAX_PATH;
2894 lstrcpyA(buf, "apple");
2895 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
2896 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2897 ok(!lstrcmpA(buf, "tele"), "Expected \"tele\", got \"%s\"\n", buf);
2898 ok(sz == 4, "Expected 4, got %d\n", sz);
2900 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_DWORD,
2901 (const BYTE *)&val, sizeof(DWORD));
2902 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2904 /* HelpTelephone type is REG_DWORD */
2905 sz = MAX_PATH;
2906 lstrcpyA(buf, "apple");
2907 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
2908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2909 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2910 ok(sz == 2, "Expected 2, got %d\n", sz);
2912 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
2913 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2915 /* InstallLocation value exists */
2916 sz = MAX_PATH;
2917 lstrcpyA(buf, "apple");
2918 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
2919 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2920 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
2921 ok(sz == 3, "Expected 3, got %d\n", sz);
2923 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_DWORD,
2924 (const BYTE *)&val, sizeof(DWORD));
2925 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2927 /* InstallLocation type is REG_DWORD */
2928 sz = MAX_PATH;
2929 lstrcpyA(buf, "apple");
2930 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
2931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2932 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2933 ok(sz == 2, "Expected 2, got %d\n", sz);
2935 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
2936 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2938 /* InstallSource value exists */
2939 sz = MAX_PATH;
2940 lstrcpyA(buf, "apple");
2941 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
2942 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2943 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
2944 ok(sz == 6, "Expected 6, got %d\n", sz);
2946 res = RegSetValueExA(propkey, "InstallSource", 0, REG_DWORD,
2947 (const BYTE *)&val, sizeof(DWORD));
2948 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2950 /* InstallSource type is REG_DWORD */
2951 sz = MAX_PATH;
2952 lstrcpyA(buf, "apple");
2953 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
2954 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2955 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2956 ok(sz == 2, "Expected 2, got %d\n", sz);
2958 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
2959 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2961 /* InstallDate value exists */
2962 sz = MAX_PATH;
2963 lstrcpyA(buf, "apple");
2964 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATE, buf, &sz);
2965 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2966 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
2967 ok(sz == 4, "Expected 4, got %d\n", sz);
2969 res = RegSetValueExA(propkey, "InstallDate", 0, REG_DWORD,
2970 (const BYTE *)&val, sizeof(DWORD));
2971 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2973 /* InstallDate type is REG_DWORD */
2974 sz = MAX_PATH;
2975 lstrcpyA(buf, "apple");
2976 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATE, buf, &sz);
2977 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2978 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
2979 ok(sz == 2, "Expected 2, got %d\n", sz);
2981 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
2982 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2984 /* Publisher value exists */
2985 sz = MAX_PATH;
2986 lstrcpyA(buf, "apple");
2987 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHER, buf, &sz);
2988 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2989 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
2990 ok(sz == 3, "Expected 3, got %d\n", sz);
2992 res = RegSetValueExA(propkey, "Publisher", 0, REG_DWORD,
2993 (const BYTE *)&val, sizeof(DWORD));
2994 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2996 /* Publisher type is REG_DWORD */
2997 sz = MAX_PATH;
2998 lstrcpyA(buf, "apple");
2999 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHER, buf, &sz);
3000 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3001 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3002 ok(sz == 2, "Expected 2, got %d\n", sz);
3004 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"pack", 5);
3005 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3007 /* LocalPackage value exists */
3008 sz = MAX_PATH;
3009 lstrcpyA(buf, "apple");
3010 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
3011 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3012 ok(!lstrcmpA(buf, "pack"), "Expected \"pack\", got \"%s\"\n", buf);
3013 ok(sz == 4, "Expected 4, got %d\n", sz);
3015 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_DWORD,
3016 (const BYTE *)&val, sizeof(DWORD));
3017 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3019 /* LocalPackage type is REG_DWORD */
3020 sz = MAX_PATH;
3021 lstrcpyA(buf, "apple");
3022 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
3023 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3024 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3025 ok(sz == 2, "Expected 2, got %d\n", sz);
3027 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
3028 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3030 /* UrlInfoAbout value exists */
3031 sz = MAX_PATH;
3032 lstrcpyA(buf, "apple");
3033 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
3034 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3035 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
3036 ok(sz == 5, "Expected 5, got %d\n", sz);
3038 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_DWORD,
3039 (const BYTE *)&val, sizeof(DWORD));
3040 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3042 /* UrlInfoAbout type is REG_DWORD */
3043 sz = MAX_PATH;
3044 lstrcpyA(buf, "apple");
3045 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
3046 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3047 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3048 ok(sz == 2, "Expected 2, got %d\n", sz);
3050 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_SZ, (LPBYTE)"info", 5);
3051 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3053 /* UrlUpdateInfo value exists */
3054 sz = MAX_PATH;
3055 lstrcpyA(buf, "apple");
3056 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
3057 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3058 ok(!lstrcmpA(buf, "info"), "Expected \"info\", got \"%s\"\n", buf);
3059 ok(sz == 4, "Expected 4, got %d\n", sz);
3061 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_DWORD,
3062 (const BYTE *)&val, sizeof(DWORD));
3063 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3065 /* UrlUpdateInfo type is REG_DWORD */
3066 sz = MAX_PATH;
3067 lstrcpyA(buf, "apple");
3068 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
3069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3070 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3071 ok(sz == 2, "Expected 2, got %d\n", sz);
3073 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"1", 2);
3074 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3076 /* VersionMinor value exists */
3077 sz = MAX_PATH;
3078 lstrcpyA(buf, "apple");
3079 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
3080 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3081 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
3082 ok(sz == 1, "Expected 1, got %d\n", sz);
3084 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_DWORD,
3085 (const BYTE *)&val, sizeof(DWORD));
3086 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3088 /* VersionMinor type is REG_DWORD */
3089 sz = MAX_PATH;
3090 lstrcpyA(buf, "apple");
3091 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
3092 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3093 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3094 ok(sz == 2, "Expected 2, got %d\n", sz);
3096 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"1", 2);
3097 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3099 /* VersionMajor value exists */
3100 sz = MAX_PATH;
3101 lstrcpyA(buf, "apple");
3102 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
3103 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3104 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
3105 ok(sz == 1, "Expected 1, got %d\n", sz);
3107 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_DWORD,
3108 (const BYTE *)&val, sizeof(DWORD));
3109 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3111 /* VersionMajor type is REG_DWORD */
3112 sz = MAX_PATH;
3113 lstrcpyA(buf, "apple");
3114 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
3115 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3116 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3117 ok(sz == 2, "Expected 2, got %d\n", sz);
3119 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
3120 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3122 /* ProductID value exists */
3123 sz = MAX_PATH;
3124 lstrcpyA(buf, "apple");
3125 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTID, buf, &sz);
3126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3127 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
3128 ok(sz == 2, "Expected 2, got %d\n", sz);
3130 res = RegSetValueExA(propkey, "ProductID", 0, REG_DWORD,
3131 (const BYTE *)&val, sizeof(DWORD));
3132 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3134 /* ProductID type is REG_DWORD */
3135 sz = MAX_PATH;
3136 lstrcpyA(buf, "apple");
3137 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTID, buf, &sz);
3138 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3139 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3140 ok(sz == 2, "Expected 2, got %d\n", sz);
3142 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
3143 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3145 /* RegCompany value exists */
3146 sz = MAX_PATH;
3147 lstrcpyA(buf, "apple");
3148 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANY, buf, &sz);
3149 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3150 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
3151 ok(sz == 4, "Expected 4, got %d\n", sz);
3153 res = RegSetValueExA(propkey, "RegCompany", 0, REG_DWORD,
3154 (const BYTE *)&val, sizeof(DWORD));
3155 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3157 /* RegCompany type is REG_DWORD */
3158 sz = MAX_PATH;
3159 lstrcpyA(buf, "apple");
3160 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANY, buf, &sz);
3161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3162 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3163 ok(sz == 2, "Expected 2, got %d\n", sz);
3165 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"own", 4);
3166 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3168 /* RegOwner value exists */
3169 sz = MAX_PATH;
3170 lstrcpyA(buf, "apple");
3171 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNER, buf, &sz);
3172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3173 ok(!lstrcmpA(buf, "own"), "Expected \"own\", got \"%s\"\n", buf);
3174 ok(sz == 3, "Expected 3, got %d\n", sz);
3176 res = RegSetValueExA(propkey, "RegOwner", 0, REG_DWORD,
3177 (const BYTE *)&val, sizeof(DWORD));
3178 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3180 /* RegOwner type is REG_DWORD */
3181 sz = MAX_PATH;
3182 lstrcpyA(buf, "apple");
3183 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNER, buf, &sz);
3184 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3185 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3186 ok(sz == 2, "Expected 2, got %d\n", sz);
3188 res = RegSetValueExA(propkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
3189 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3191 /* InstanceType value exists */
3192 sz = MAX_PATH;
3193 lstrcpyA(buf, "apple");
3194 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3196 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3197 ok(sz == 0, "Expected 0, got %d\n", sz);
3199 res = RegSetValueExA(propkey, "InstanceType", 0, REG_DWORD,
3200 (const BYTE *)&val, sizeof(DWORD));
3201 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3203 /* InstanceType type is REG_DWORD */
3204 sz = MAX_PATH;
3205 lstrcpyA(buf, "apple");
3206 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3208 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3209 ok(sz == 0, "Expected 0, got %d\n", sz);
3211 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
3212 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3214 /* InstanceType value exists */
3215 sz = MAX_PATH;
3216 lstrcpyA(buf, "apple");
3217 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3219 ok(!lstrcmpA(buf, "type"), "Expected \"type\", got \"%s\"\n", buf);
3220 ok(sz == 4, "Expected 4, got %d\n", sz);
3222 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_DWORD,
3223 (const BYTE *)&val, sizeof(DWORD));
3224 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3226 /* InstanceType type is REG_DWORD */
3227 sz = MAX_PATH;
3228 lstrcpyA(buf, "apple");
3229 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
3230 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3231 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3232 ok(sz == 2, "Expected 2, got %d\n", sz);
3234 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
3235 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3237 /* Transforms value exists */
3238 sz = MAX_PATH;
3239 lstrcpyA(buf, "apple");
3240 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3241 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3242 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3243 ok(sz == 0, "Expected 0, got %d\n", sz);
3245 res = RegSetValueExA(propkey, "Transforms", 0, REG_DWORD,
3246 (const BYTE *)&val, sizeof(DWORD));
3247 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3249 /* Transforms type is REG_DWORD */
3250 sz = MAX_PATH;
3251 lstrcpyA(buf, "apple");
3252 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3254 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3255 ok(sz == 0, "Expected 0, got %d\n", sz);
3257 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
3258 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3260 /* Transforms value exists */
3261 sz = MAX_PATH;
3262 lstrcpyA(buf, "apple");
3263 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3264 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3265 ok(!lstrcmpA(buf, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf);
3266 ok(sz == 6, "Expected 6, got %d\n", sz);
3268 res = RegSetValueExA(prodkey, "Transforms", 0, REG_DWORD,
3269 (const BYTE *)&val, sizeof(DWORD));
3270 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3272 /* Transforms type is REG_DWORD */
3273 sz = MAX_PATH;
3274 lstrcpyA(buf, "apple");
3275 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
3276 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3277 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3278 ok(sz == 2, "Expected 2, got %d\n", sz);
3280 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
3281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3283 /* Language value exists */
3284 sz = MAX_PATH;
3285 lstrcpyA(buf, "apple");
3286 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3288 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3289 ok(sz == 0, "Expected 0, got %d\n", sz);
3291 res = RegSetValueExA(propkey, "Language", 0, REG_DWORD,
3292 (const BYTE *)&val, sizeof(DWORD));
3293 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3295 /* Language type is REG_DWORD */
3296 sz = MAX_PATH;
3297 lstrcpyA(buf, "apple");
3298 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3300 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3301 ok(sz == 0, "Expected 0, got %d\n", sz);
3303 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
3304 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3306 /* Language value exists */
3307 sz = MAX_PATH;
3308 lstrcpyA(buf, "apple");
3309 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3310 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3311 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
3312 ok(sz == 4, "Expected 4, got %d\n", sz);
3314 res = RegSetValueExA(prodkey, "Language", 0, REG_DWORD,
3315 (const BYTE *)&val, sizeof(DWORD));
3316 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3318 /* Language type is REG_DWORD */
3319 sz = MAX_PATH;
3320 lstrcpyA(buf, "apple");
3321 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
3322 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3323 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3324 ok(sz == 2, "Expected 2, got %d\n", sz);
3326 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
3327 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3329 /* ProductName value exists */
3330 sz = MAX_PATH;
3331 lstrcpyA(buf, "apple");
3332 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3334 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3335 ok(sz == 0, "Expected 0, got %d\n", sz);
3337 res = RegSetValueExA(propkey, "ProductName", 0, REG_DWORD,
3338 (const BYTE *)&val, sizeof(DWORD));
3339 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3341 /* ProductName type is REG_DWORD */
3342 sz = MAX_PATH;
3343 lstrcpyA(buf, "apple");
3344 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3345 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3346 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3347 ok(sz == 0, "Expected 0, got %d\n", sz);
3349 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
3350 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3352 /* ProductName value exists */
3353 sz = MAX_PATH;
3354 lstrcpyA(buf, "apple");
3355 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3357 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
3358 ok(sz == 4, "Expected 4, got %d\n", sz);
3360 res = RegSetValueExA(prodkey, "ProductName", 0, REG_DWORD,
3361 (const BYTE *)&val, sizeof(DWORD));
3362 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3364 /* ProductName type is REG_DWORD */
3365 sz = MAX_PATH;
3366 lstrcpyA(buf, "apple");
3367 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
3368 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3369 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3370 ok(sz == 2, "Expected 2, got %d\n", sz);
3372 res = RegSetValueExA(propkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
3373 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3375 /* Assignment value exists */
3376 sz = MAX_PATH;
3377 lstrcpyA(buf, "apple");
3378 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3379 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3380 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3381 ok(sz == 0, "Expected 0, got %d\n", sz);
3383 res = RegSetValueExA(propkey, "Assignment", 0, REG_DWORD,
3384 (const BYTE *)&val, sizeof(DWORD));
3385 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3387 /* Assignment type is REG_DWORD */
3388 sz = MAX_PATH;
3389 lstrcpyA(buf, "apple");
3390 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3391 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3392 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3393 ok(sz == 0, "Expected 0, got %d\n", sz);
3395 res = RegSetValueExA(prodkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
3396 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3398 /* Assignment value exists */
3399 sz = MAX_PATH;
3400 lstrcpyA(buf, "apple");
3401 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3402 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3403 ok(!lstrcmpA(buf, "at"), "Expected \"at\", got \"%s\"\n", buf);
3404 ok(sz == 2, "Expected 2, got %d\n", sz);
3406 res = RegSetValueExA(prodkey, "Assignment", 0, REG_DWORD,
3407 (const BYTE *)&val, sizeof(DWORD));
3408 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3410 /* Assignment type is REG_DWORD */
3411 sz = MAX_PATH;
3412 lstrcpyA(buf, "apple");
3413 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
3414 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3415 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3416 ok(sz == 2, "Expected 2, got %d\n", sz);
3418 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
3419 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3421 /* PackageCode value exists */
3422 sz = MAX_PATH;
3423 lstrcpyA(buf, "apple");
3424 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3425 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3426 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3427 ok(sz == 0, "Expected 0, got %d\n", sz);
3429 res = RegSetValueExA(propkey, "PackageCode", 0, REG_DWORD,
3430 (const BYTE *)&val, sizeof(DWORD));
3431 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3433 /* PackageCode type is REG_DWORD */
3434 sz = MAX_PATH;
3435 lstrcpyA(buf, "apple");
3436 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3437 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3438 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3439 ok(sz == 0, "Expected 0, got %d\n", sz);
3441 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
3442 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3444 /* PackageCode value exists */
3445 sz = MAX_PATH;
3446 lstrcpyA(buf, "apple");
3447 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3448 ok(r == ERROR_BAD_CONFIGURATION,
3449 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
3450 ok(!lstrcmpA(buf, "code"), "Expected \"code\", got \"%s\"\n", buf);
3451 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3453 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_DWORD,
3454 (const BYTE *)&val, sizeof(DWORD));
3455 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3457 /* PackageCode type is REG_DWORD */
3458 sz = MAX_PATH;
3459 lstrcpyA(buf, "apple");
3460 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3461 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3462 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3463 ok(sz == 2, "Expected 2, got %d\n", sz);
3465 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)pack_squashed, 33);
3466 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3468 /* PackageCode value exists */
3469 sz = MAX_PATH;
3470 lstrcpyA(buf, "apple");
3471 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
3472 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3473 ok(!lstrcmpA(buf, packcode), "Expected \"%s\", got \"%s\"\n", packcode, buf);
3474 ok(sz == 38, "Expected 38, got %d\n", sz);
3476 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
3477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3479 /* Version value exists */
3480 sz = MAX_PATH;
3481 lstrcpyA(buf, "apple");
3482 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3483 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3484 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3485 ok(sz == 0, "Expected 0, got %d\n", sz);
3487 res = RegSetValueExA(propkey, "Version", 0, REG_DWORD,
3488 (const BYTE *)&val, sizeof(DWORD));
3489 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3491 /* Version type is REG_DWORD */
3492 sz = MAX_PATH;
3493 lstrcpyA(buf, "apple");
3494 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3495 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3496 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3497 ok(sz == 0, "Expected 0, got %d\n", sz);
3499 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
3500 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3502 /* Version value exists */
3503 sz = MAX_PATH;
3504 lstrcpyA(buf, "apple");
3505 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3506 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3507 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
3508 ok(sz == 3, "Expected 3, got %d\n", sz);
3510 res = RegSetValueExA(prodkey, "Version", 0, REG_DWORD,
3511 (const BYTE *)&val, sizeof(DWORD));
3512 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3514 /* Version type is REG_DWORD */
3515 sz = MAX_PATH;
3516 lstrcpyA(buf, "apple");
3517 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
3518 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3519 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3520 ok(sz == 2, "Expected 2, got %d\n", sz);
3522 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
3523 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3525 /* ProductIcon value exists */
3526 sz = MAX_PATH;
3527 lstrcpyA(buf, "apple");
3528 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3529 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3530 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3531 ok(sz == 0, "Expected 0, got %d\n", sz);
3533 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_DWORD,
3534 (const BYTE *)&val, sizeof(DWORD));
3535 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3537 /* ProductIcon type is REG_DWORD */
3538 sz = MAX_PATH;
3539 lstrcpyA(buf, "apple");
3540 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3541 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3542 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3543 ok(sz == 0, "Expected 0, got %d\n", sz);
3545 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
3546 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3548 /* ProductIcon value exists */
3549 sz = MAX_PATH;
3550 lstrcpyA(buf, "apple");
3551 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3553 ok(!lstrcmpA(buf, "ico"), "Expected \"ico\", got \"%s\"\n", buf);
3554 ok(sz == 3, "Expected 3, got %d\n", sz);
3556 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_DWORD,
3557 (const BYTE *)&val, sizeof(DWORD));
3558 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3560 /* ProductIcon type is REG_DWORD */
3561 sz = MAX_PATH;
3562 lstrcpyA(buf, "apple");
3563 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
3564 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3565 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3566 ok(sz == 2, "Expected 2, got %d\n", sz);
3568 res = RegCreateKeyA(prodkey, "SourceList", &source);
3569 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3571 res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
3572 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3574 sz = MAX_PATH;
3575 lstrcpyA(buf, "apple");
3576 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
3577 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3578 ok(!lstrcmpA(buf, "packname"), "Expected \"packname\", got \"%s\"\n", buf);
3579 ok(sz == 8, "Expected 8, got %d\n", sz);
3581 res = RegSetValueExA(source, "PackageName", 0, REG_DWORD,
3582 (const BYTE *)&val, sizeof(DWORD));
3583 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3585 /* PackageName type is REG_DWORD */
3586 sz = MAX_PATH;
3587 lstrcpyA(buf, "apple");
3588 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
3589 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3590 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3591 ok(sz == 2, "Expected 2, got %d\n", sz);
3593 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3594 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3596 /* Authorized value exists */
3597 sz = MAX_PATH;
3598 lstrcpyA(buf, "apple");
3599 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3600 if (r != ERROR_UNKNOWN_PROPERTY)
3602 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3603 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3604 ok(sz == 0, "Expected 0, got %d\n", sz);
3607 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_DWORD,
3608 (const BYTE *)&val, sizeof(DWORD));
3609 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3611 /* AuthorizedLUAApp type is REG_DWORD */
3612 sz = MAX_PATH;
3613 lstrcpyA(buf, "apple");
3614 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3615 if (r != ERROR_UNKNOWN_PROPERTY)
3617 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3618 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3619 ok(sz == 0, "Expected 0, got %d\n", sz);
3622 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
3623 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3625 /* Authorized value exists */
3626 sz = MAX_PATH;
3627 lstrcpyA(buf, "apple");
3628 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3629 if (r != ERROR_UNKNOWN_PROPERTY)
3631 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3632 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
3633 ok(sz == 4, "Expected 4, got %d\n", sz);
3636 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_DWORD,
3637 (const BYTE *)&val, sizeof(DWORD));
3638 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3640 /* AuthorizedLUAApp type is REG_DWORD */
3641 sz = MAX_PATH;
3642 lstrcpyA(buf, "apple");
3643 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
3644 if (r != ERROR_UNKNOWN_PROPERTY)
3646 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3647 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
3648 ok(sz == 2, "Expected 2, got %d\n", sz);
3651 RegDeleteValueA(propkey, "HelpLink");
3652 RegDeleteValueA(propkey, "DisplayName");
3653 RegDeleteValueA(propkey, "DisplayVersion");
3654 RegDeleteValueA(propkey, "HelpTelephone");
3655 RegDeleteValueA(propkey, "InstallLocation");
3656 RegDeleteValueA(propkey, "InstallSource");
3657 RegDeleteValueA(propkey, "InstallDate");
3658 RegDeleteValueA(propkey, "Publisher");
3659 RegDeleteValueA(propkey, "LocalPackage");
3660 RegDeleteValueA(propkey, "UrlInfoAbout");
3661 RegDeleteValueA(propkey, "UrlUpdateInfo");
3662 RegDeleteValueA(propkey, "VersionMinor");
3663 RegDeleteValueA(propkey, "VersionMajor");
3664 RegDeleteValueA(propkey, "ProductID");
3665 RegDeleteValueA(propkey, "RegCompany");
3666 RegDeleteValueA(propkey, "RegOwner");
3667 RegDeleteValueA(propkey, "InstanceType");
3668 RegDeleteValueA(propkey, "Transforms");
3669 RegDeleteValueA(propkey, "Language");
3670 RegDeleteValueA(propkey, "ProductName");
3671 RegDeleteValueA(propkey, "Assignment");
3672 RegDeleteValueA(propkey, "PackageCode");
3673 RegDeleteValueA(propkey, "Version");
3674 RegDeleteValueA(propkey, "ProductIcon");
3675 RegDeleteValueA(propkey, "AuthorizedLUAApp");
3676 RegDeleteKeyA(propkey, "");
3677 RegDeleteKeyA(localkey, "");
3678 RegDeleteValueA(prodkey, "InstanceType");
3679 RegDeleteValueA(prodkey, "Transforms");
3680 RegDeleteValueA(prodkey, "Language");
3681 RegDeleteValueA(prodkey, "ProductName");
3682 RegDeleteValueA(prodkey, "Assignment");
3683 RegDeleteValueA(prodkey, "PackageCode");
3684 RegDeleteValueA(prodkey, "Version");
3685 RegDeleteValueA(prodkey, "ProductIcon");
3686 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
3687 RegDeleteValueA(source, "PackageName");
3688 RegDeleteKeyA(source, "");
3689 RegDeleteKeyA(prodkey, "");
3690 RegCloseKey(propkey);
3691 RegCloseKey(localkey);
3692 RegCloseKey(source);
3693 RegCloseKey(prodkey);
3696 static void test_MsiGetProductInfoEx(void)
3698 UINT r;
3699 LONG res;
3700 HKEY propkey, userkey;
3701 HKEY prodkey, localkey;
3702 CHAR prodcode[MAX_PATH];
3703 CHAR prod_squashed[MAX_PATH];
3704 CHAR packcode[MAX_PATH];
3705 CHAR pack_squashed[MAX_PATH];
3706 CHAR buf[MAX_PATH];
3707 CHAR keypath[MAX_PATH];
3708 LPSTR usersid;
3709 DWORD sz;
3711 if (!pMsiGetProductInfoExA)
3713 skip("MsiGetProductInfoExA is not available\n");
3714 return;
3717 create_test_guid(prodcode, prod_squashed);
3718 create_test_guid(packcode, pack_squashed);
3719 get_user_sid(&usersid);
3721 /* NULL szProductCode */
3722 sz = MAX_PATH;
3723 lstrcpyA(buf, "apple");
3724 r = pMsiGetProductInfoExA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3725 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3726 ok(r == ERROR_INVALID_PARAMETER,
3727 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3728 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3729 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3731 /* empty szProductCode */
3732 sz = MAX_PATH;
3733 lstrcpyA(buf, "apple");
3734 r = pMsiGetProductInfoExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3735 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3736 ok(r == ERROR_INVALID_PARAMETER,
3737 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3738 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3739 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3741 /* garbage szProductCode */
3742 sz = MAX_PATH;
3743 lstrcpyA(buf, "apple");
3744 r = pMsiGetProductInfoExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
3745 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3746 ok(r == ERROR_INVALID_PARAMETER,
3747 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3748 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3749 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3751 /* guid without brackets */
3752 sz = MAX_PATH;
3753 lstrcpyA(buf, "apple");
3754 r = pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
3755 MSIINSTALLCONTEXT_USERUNMANAGED,
3756 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3757 ok(r == ERROR_INVALID_PARAMETER,
3758 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3759 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3760 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3762 /* guid with brackets */
3763 sz = MAX_PATH;
3764 lstrcpyA(buf, "apple");
3765 r = pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid,
3766 MSIINSTALLCONTEXT_USERUNMANAGED,
3767 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3768 ok(r == ERROR_UNKNOWN_PRODUCT,
3769 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3770 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3771 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3773 /* szValue is non-NULL while pcchValue is NULL */
3774 lstrcpyA(buf, "apple");
3775 r = pMsiGetProductInfoExA(prodcode, usersid,
3776 MSIINSTALLCONTEXT_USERUNMANAGED,
3777 INSTALLPROPERTY_PRODUCTSTATE, buf, NULL);
3778 ok(r == ERROR_INVALID_PARAMETER,
3779 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3780 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3782 /* dwContext is out of range */
3783 sz = MAX_PATH;
3784 lstrcpyA(buf, "apple");
3785 r = pMsiGetProductInfoExA(prodcode, usersid, 42,
3786 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3787 ok(r == ERROR_INVALID_PARAMETER,
3788 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3789 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3790 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3792 /* szProperty is NULL */
3793 sz = MAX_PATH;
3794 lstrcpyA(buf, "apple");
3795 r = pMsiGetProductInfoExA(prodcode, usersid,
3796 MSIINSTALLCONTEXT_USERUNMANAGED,
3797 NULL, buf, &sz);
3798 ok(r == ERROR_INVALID_PARAMETER,
3799 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3800 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3801 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3803 /* szProperty is empty */
3804 sz = MAX_PATH;
3805 lstrcpyA(buf, "apple");
3806 r = pMsiGetProductInfoExA(prodcode, usersid,
3807 MSIINSTALLCONTEXT_USERUNMANAGED,
3808 "", buf, &sz);
3809 ok(r == ERROR_INVALID_PARAMETER,
3810 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3811 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3812 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3814 /* szProperty is not a valid property */
3815 sz = MAX_PATH;
3816 lstrcpyA(buf, "apple");
3817 r = pMsiGetProductInfoExA(prodcode, usersid,
3818 MSIINSTALLCONTEXT_USERUNMANAGED,
3819 "notvalid", buf, &sz);
3820 ok(r == ERROR_UNKNOWN_PRODUCT,
3821 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3822 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3823 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3825 /* same length as guid, but random */
3826 sz = MAX_PATH;
3827 lstrcpyA(buf, "apple");
3828 r = pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid,
3829 MSIINSTALLCONTEXT_USERUNMANAGED,
3830 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3831 ok(r == ERROR_INVALID_PARAMETER,
3832 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3833 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3834 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3836 /* MSIINSTALLCONTEXT_USERUNMANAGED */
3838 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
3839 lstrcatA(keypath, usersid);
3840 lstrcatA(keypath, "\\Products\\");
3841 lstrcatA(keypath, prod_squashed);
3843 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
3844 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3846 /* local user product key exists */
3847 sz = MAX_PATH;
3848 lstrcpyA(buf, "apple");
3849 r = pMsiGetProductInfoExA(prodcode, usersid,
3850 MSIINSTALLCONTEXT_USERUNMANAGED,
3851 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3852 ok(r == ERROR_UNKNOWN_PRODUCT,
3853 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3854 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3855 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3857 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
3858 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3860 /* InstallProperties key exists */
3861 sz = MAX_PATH;
3862 lstrcpyA(buf, "apple");
3863 r = pMsiGetProductInfoExA(prodcode, usersid,
3864 MSIINSTALLCONTEXT_USERUNMANAGED,
3865 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3866 ok(r == ERROR_UNKNOWN_PRODUCT,
3867 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3868 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3869 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3871 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3872 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3874 /* LocalPackage value exists */
3875 sz = MAX_PATH;
3876 lstrcpyA(buf, "apple");
3877 r = pMsiGetProductInfoExA(prodcode, usersid,
3878 MSIINSTALLCONTEXT_USERUNMANAGED,
3879 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
3880 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3881 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
3882 ok(sz == 1, "Expected 1, got %d\n", sz);
3884 RegDeleteValueA(propkey, "LocalPackage");
3886 /* LocalPackage value must exist */
3887 sz = MAX_PATH;
3888 lstrcpyA(buf, "apple");
3889 r = pMsiGetProductInfoExA(prodcode, usersid,
3890 MSIINSTALLCONTEXT_USERUNMANAGED,
3891 INSTALLPROPERTY_HELPLINK, buf, &sz);
3892 ok(r == ERROR_UNKNOWN_PRODUCT,
3893 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3894 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3895 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3897 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
3898 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3900 /* LocalPackage exists, but HelpLink does not exist */
3901 sz = MAX_PATH;
3902 lstrcpyA(buf, "apple");
3903 r = pMsiGetProductInfoExA(prodcode, usersid,
3904 MSIINSTALLCONTEXT_USERUNMANAGED,
3905 INSTALLPROPERTY_HELPLINK, buf, &sz);
3906 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3907 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3908 ok(sz == 0, "Expected 0, got %d\n", sz);
3910 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
3911 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3913 /* HelpLink value exists */
3914 sz = MAX_PATH;
3915 lstrcpyA(buf, "apple");
3916 r = pMsiGetProductInfoExA(prodcode, usersid,
3917 MSIINSTALLCONTEXT_USERUNMANAGED,
3918 INSTALLPROPERTY_HELPLINK, buf, &sz);
3919 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3920 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
3921 ok(sz == 4, "Expected 4, got %d\n", sz);
3923 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
3924 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3926 /* HelpTelephone value exists */
3927 sz = MAX_PATH;
3928 lstrcpyA(buf, "apple");
3929 r = pMsiGetProductInfoExA(prodcode, usersid,
3930 MSIINSTALLCONTEXT_USERUNMANAGED,
3931 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3932 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3933 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
3934 ok(sz == 5, "Expected 5, got %d\n", sz);
3936 /* szValue and pcchValue are NULL */
3937 r = pMsiGetProductInfoExA(prodcode, usersid,
3938 MSIINSTALLCONTEXT_USERUNMANAGED,
3939 INSTALLPROPERTY_HELPTELEPHONE, NULL, NULL);
3940 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3942 /* pcchValue is exactly 5 */
3943 sz = 5;
3944 lstrcpyA(buf, "apple");
3945 r = pMsiGetProductInfoExA(prodcode, usersid,
3946 MSIINSTALLCONTEXT_USERUNMANAGED,
3947 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3948 ok(r == ERROR_MORE_DATA,
3949 "Expected ERROR_MORE_DATA, got %d\n", r);
3950 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
3951 ok(sz == 10, "Expected 10, got %d\n", sz);
3953 /* szValue is NULL, pcchValue is exactly 5 */
3954 sz = 5;
3955 r = pMsiGetProductInfoExA(prodcode, usersid,
3956 MSIINSTALLCONTEXT_USERUNMANAGED,
3957 INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
3958 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3959 ok(sz == 10, "Expected 10, got %d\n", sz);
3961 /* szValue is NULL, pcchValue is MAX_PATH */
3962 sz = MAX_PATH;
3963 r = pMsiGetProductInfoExA(prodcode, usersid,
3964 MSIINSTALLCONTEXT_USERUNMANAGED,
3965 INSTALLPROPERTY_HELPTELEPHONE, NULL, &sz);
3966 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3967 ok(sz == 10, "Expected 10, got %d\n", sz);
3969 /* pcchValue is exactly 0 */
3970 sz = 0;
3971 lstrcpyA(buf, "apple");
3972 r = pMsiGetProductInfoExA(prodcode, usersid,
3973 MSIINSTALLCONTEXT_USERUNMANAGED,
3974 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
3975 ok(r == ERROR_MORE_DATA,
3976 "Expected ERROR_MORE_DATA, got %d\n", r);
3977 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
3978 ok(sz == 10, "Expected 10, got %d\n", sz);
3980 res = RegSetValueExA(propkey, "notvalid", 0, REG_SZ, (LPBYTE)"invalid", 8);
3981 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3983 /* szProperty is not a valid property */
3984 sz = MAX_PATH;
3985 lstrcpyA(buf, "apple");
3986 r = pMsiGetProductInfoExA(prodcode, usersid,
3987 MSIINSTALLCONTEXT_USERUNMANAGED,
3988 "notvalid", buf, &sz);
3989 ok(r == ERROR_UNKNOWN_PROPERTY,
3990 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
3991 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
3992 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
3994 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
3995 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3997 /* InstallDate value exists */
3998 sz = MAX_PATH;
3999 lstrcpyA(buf, "apple");
4000 r = pMsiGetProductInfoExA(prodcode, usersid,
4001 MSIINSTALLCONTEXT_USERUNMANAGED,
4002 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4003 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4004 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4005 ok(sz == 4, "Expected 4, got %d\n", sz);
4007 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4008 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4010 /* DisplayName value exists */
4011 sz = MAX_PATH;
4012 lstrcpyA(buf, "apple");
4013 r = pMsiGetProductInfoExA(prodcode, usersid,
4014 MSIINSTALLCONTEXT_USERUNMANAGED,
4015 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4016 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4017 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4018 ok(sz == 4, "Expected 4, got %d\n", sz);
4020 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4021 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4023 /* InstallLocation value exists */
4024 sz = MAX_PATH;
4025 lstrcpyA(buf, "apple");
4026 r = pMsiGetProductInfoExA(prodcode, usersid,
4027 MSIINSTALLCONTEXT_USERUNMANAGED,
4028 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4030 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4031 ok(sz == 3, "Expected 3, got %d\n", sz);
4033 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4034 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4036 /* InstallSource value exists */
4037 sz = MAX_PATH;
4038 lstrcpyA(buf, "apple");
4039 r = pMsiGetProductInfoExA(prodcode, usersid,
4040 MSIINSTALLCONTEXT_USERUNMANAGED,
4041 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4043 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4044 ok(sz == 6, "Expected 6, got %d\n", sz);
4046 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4047 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4049 /* LocalPackage value exists */
4050 sz = MAX_PATH;
4051 lstrcpyA(buf, "apple");
4052 r = pMsiGetProductInfoExA(prodcode, usersid,
4053 MSIINSTALLCONTEXT_USERUNMANAGED,
4054 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4055 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4056 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
4057 ok(sz == 5, "Expected 5, got %d\n", sz);
4059 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4060 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4062 /* Publisher value exists */
4063 sz = MAX_PATH;
4064 lstrcpyA(buf, "apple");
4065 r = pMsiGetProductInfoExA(prodcode, usersid,
4066 MSIINSTALLCONTEXT_USERUNMANAGED,
4067 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4068 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4069 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4070 ok(sz == 3, "Expected 3, got %d\n", sz);
4072 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4073 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4075 /* URLInfoAbout value exists */
4076 sz = MAX_PATH;
4077 lstrcpyA(buf, "apple");
4078 r = pMsiGetProductInfoExA(prodcode, usersid,
4079 MSIINSTALLCONTEXT_USERUNMANAGED,
4080 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4082 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4083 ok(sz == 5, "Expected 5, got %d\n", sz);
4085 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4086 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4088 /* URLUpdateInfo value exists */
4089 sz = MAX_PATH;
4090 lstrcpyA(buf, "apple");
4091 r = pMsiGetProductInfoExA(prodcode, usersid,
4092 MSIINSTALLCONTEXT_USERUNMANAGED,
4093 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4095 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
4096 ok(sz == 6, "Expected 6, got %d\n", sz);
4098 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4099 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4101 /* VersionMinor value exists */
4102 sz = MAX_PATH;
4103 lstrcpyA(buf, "apple");
4104 r = pMsiGetProductInfoExA(prodcode, usersid,
4105 MSIINSTALLCONTEXT_USERUNMANAGED,
4106 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4107 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4108 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
4109 ok(sz == 1, "Expected 1, got %d\n", sz);
4111 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4112 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4114 /* VersionMajor value exists */
4115 sz = MAX_PATH;
4116 lstrcpyA(buf, "apple");
4117 r = pMsiGetProductInfoExA(prodcode, usersid,
4118 MSIINSTALLCONTEXT_USERUNMANAGED,
4119 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4120 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4121 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
4122 ok(sz == 1, "Expected 1, got %d\n", sz);
4124 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4125 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4127 /* DisplayVersion value exists */
4128 sz = MAX_PATH;
4129 lstrcpyA(buf, "apple");
4130 r = pMsiGetProductInfoExA(prodcode, usersid,
4131 MSIINSTALLCONTEXT_USERUNMANAGED,
4132 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4134 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
4135 ok(sz == 5, "Expected 5, got %d\n", sz);
4137 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4138 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4140 /* ProductID value exists */
4141 sz = MAX_PATH;
4142 lstrcpyA(buf, "apple");
4143 r = pMsiGetProductInfoExA(prodcode, usersid,
4144 MSIINSTALLCONTEXT_USERUNMANAGED,
4145 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4147 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
4148 ok(sz == 2, "Expected 2, got %d\n", sz);
4150 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4151 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4153 /* RegCompany value exists */
4154 sz = MAX_PATH;
4155 lstrcpyA(buf, "apple");
4156 r = pMsiGetProductInfoExA(prodcode, usersid,
4157 MSIINSTALLCONTEXT_USERUNMANAGED,
4158 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4160 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
4161 ok(sz == 4, "Expected 4, got %d\n", sz);
4163 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4164 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4166 /* RegOwner value exists */
4167 sz = MAX_PATH;
4168 lstrcpyA(buf, "apple");
4169 r = pMsiGetProductInfoExA(prodcode, usersid,
4170 MSIINSTALLCONTEXT_USERUNMANAGED,
4171 INSTALLPROPERTY_REGOWNER, buf, &sz);
4172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4173 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
4174 ok(sz == 5, "Expected 5, got %d\n", sz);
4176 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4177 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4179 /* Transforms value exists */
4180 sz = MAX_PATH;
4181 lstrcpyA(buf, "apple");
4182 r = pMsiGetProductInfoExA(prodcode, usersid,
4183 MSIINSTALLCONTEXT_USERUNMANAGED,
4184 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4185 ok(r == ERROR_UNKNOWN_PRODUCT,
4186 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4187 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4188 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4190 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4191 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4193 /* Language value exists */
4194 sz = MAX_PATH;
4195 lstrcpyA(buf, "apple");
4196 r = pMsiGetProductInfoExA(prodcode, usersid,
4197 MSIINSTALLCONTEXT_USERUNMANAGED,
4198 INSTALLPROPERTY_LANGUAGE, buf, &sz);
4199 ok(r == ERROR_UNKNOWN_PRODUCT,
4200 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4201 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4202 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4204 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4205 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4207 /* ProductName value exists */
4208 sz = MAX_PATH;
4209 lstrcpyA(buf, "apple");
4210 r = pMsiGetProductInfoExA(prodcode, usersid,
4211 MSIINSTALLCONTEXT_USERUNMANAGED,
4212 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4213 ok(r == ERROR_UNKNOWN_PRODUCT,
4214 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4215 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4216 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4218 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4219 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4221 /* FIXME */
4223 /* AssignmentType value exists */
4224 sz = MAX_PATH;
4225 lstrcpyA(buf, "apple");
4226 r = pMsiGetProductInfoExA(prodcode, usersid,
4227 MSIINSTALLCONTEXT_USERUNMANAGED,
4228 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4229 ok(r == ERROR_UNKNOWN_PRODUCT,
4230 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4231 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4232 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4234 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4235 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4237 /* PackageCode value exists */
4238 sz = MAX_PATH;
4239 lstrcpyA(buf, "apple");
4240 r = pMsiGetProductInfoExA(prodcode, usersid,
4241 MSIINSTALLCONTEXT_USERUNMANAGED,
4242 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4243 ok(r == ERROR_UNKNOWN_PRODUCT,
4244 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4245 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4246 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4248 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4249 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4251 /* Version value exists */
4252 sz = MAX_PATH;
4253 lstrcpyA(buf, "apple");
4254 r = pMsiGetProductInfoExA(prodcode, usersid,
4255 MSIINSTALLCONTEXT_USERUNMANAGED,
4256 INSTALLPROPERTY_VERSION, buf, &sz);
4257 ok(r == ERROR_UNKNOWN_PRODUCT,
4258 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4259 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4260 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4262 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4263 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4265 /* ProductIcon value exists */
4266 sz = MAX_PATH;
4267 lstrcpyA(buf, "apple");
4268 r = pMsiGetProductInfoExA(prodcode, usersid,
4269 MSIINSTALLCONTEXT_USERUNMANAGED,
4270 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4271 ok(r == ERROR_UNKNOWN_PRODUCT,
4272 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4273 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4274 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4276 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4277 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4279 /* PackageName value exists */
4280 sz = MAX_PATH;
4281 lstrcpyA(buf, "apple");
4282 r = pMsiGetProductInfoExA(prodcode, usersid,
4283 MSIINSTALLCONTEXT_USERUNMANAGED,
4284 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4285 ok(r == ERROR_UNKNOWN_PRODUCT,
4286 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4287 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4288 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4290 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4291 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4293 /* AuthorizedLUAApp value exists */
4294 sz = MAX_PATH;
4295 lstrcpyA(buf, "apple");
4296 r = pMsiGetProductInfoExA(prodcode, usersid,
4297 MSIINSTALLCONTEXT_USERUNMANAGED,
4298 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4299 ok(r == ERROR_UNKNOWN_PRODUCT,
4300 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4301 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4302 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4304 RegDeleteValueA(propkey, "AuthorizedLUAApp");
4305 RegDeleteValueA(propkey, "PackageName");
4306 RegDeleteValueA(propkey, "ProductIcon");
4307 RegDeleteValueA(propkey, "Version");
4308 RegDeleteValueA(propkey, "PackageCode");
4309 RegDeleteValueA(propkey, "AssignmentType");
4310 RegDeleteValueA(propkey, "ProductName");
4311 RegDeleteValueA(propkey, "Language");
4312 RegDeleteValueA(propkey, "Transforms");
4313 RegDeleteValueA(propkey, "RegOwner");
4314 RegDeleteValueA(propkey, "RegCompany");
4315 RegDeleteValueA(propkey, "ProductID");
4316 RegDeleteValueA(propkey, "DisplayVersion");
4317 RegDeleteValueA(propkey, "VersionMajor");
4318 RegDeleteValueA(propkey, "VersionMinor");
4319 RegDeleteValueA(propkey, "URLUpdateInfo");
4320 RegDeleteValueA(propkey, "URLInfoAbout");
4321 RegDeleteValueA(propkey, "Publisher");
4322 RegDeleteValueA(propkey, "LocalPackage");
4323 RegDeleteValueA(propkey, "InstallSource");
4324 RegDeleteValueA(propkey, "InstallLocation");
4325 RegDeleteValueA(propkey, "DisplayName");
4326 RegDeleteValueA(propkey, "InstallDate");
4327 RegDeleteValueA(propkey, "HelpTelephone");
4328 RegDeleteValueA(propkey, "HelpLink");
4329 RegDeleteValueA(propkey, "LocalPackage");
4330 RegDeleteKeyA(propkey, "");
4331 RegCloseKey(propkey);
4332 RegDeleteKeyA(localkey, "");
4333 RegCloseKey(localkey);
4335 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4336 lstrcatA(keypath, usersid);
4337 lstrcatA(keypath, "\\Installer\\Products\\");
4338 lstrcatA(keypath, prod_squashed);
4340 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
4341 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4343 /* user product key exists */
4344 sz = MAX_PATH;
4345 lstrcpyA(buf, "apple");
4346 r = pMsiGetProductInfoExA(prodcode, usersid,
4347 MSIINSTALLCONTEXT_USERUNMANAGED,
4348 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4349 ok(r == ERROR_UNKNOWN_PRODUCT,
4350 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4351 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4352 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4354 RegDeleteKeyA(userkey, "");
4355 RegCloseKey(userkey);
4357 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
4358 lstrcatA(keypath, prod_squashed);
4360 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
4361 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4363 sz = MAX_PATH;
4364 lstrcpyA(buf, "apple");
4365 r = pMsiGetProductInfoExA(prodcode, usersid,
4366 MSIINSTALLCONTEXT_USERUNMANAGED,
4367 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4368 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4369 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
4370 ok(sz == 1, "Expected 1, got %d\n", sz);
4372 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4373 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4375 /* HelpLink value exists */
4376 sz = MAX_PATH;
4377 lstrcpyA(buf, "apple");
4378 r = pMsiGetProductInfoExA(prodcode, usersid,
4379 MSIINSTALLCONTEXT_USERUNMANAGED,
4380 INSTALLPROPERTY_HELPLINK, buf, &sz);
4381 ok(r == ERROR_UNKNOWN_PROPERTY,
4382 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4383 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4384 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4386 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4387 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4389 /* HelpTelephone value exists */
4390 sz = MAX_PATH;
4391 lstrcpyA(buf, "apple");
4392 r = pMsiGetProductInfoExA(prodcode, usersid,
4393 MSIINSTALLCONTEXT_USERUNMANAGED,
4394 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4395 ok(r == ERROR_UNKNOWN_PROPERTY,
4396 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4397 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4398 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4400 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4401 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4403 /* InstallDate value exists */
4404 sz = MAX_PATH;
4405 lstrcpyA(buf, "apple");
4406 r = pMsiGetProductInfoExA(prodcode, usersid,
4407 MSIINSTALLCONTEXT_USERUNMANAGED,
4408 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4409 ok(r == ERROR_UNKNOWN_PROPERTY,
4410 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4411 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4412 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4414 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4415 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4417 /* DisplayName value exists */
4418 sz = MAX_PATH;
4419 lstrcpyA(buf, "apple");
4420 r = pMsiGetProductInfoExA(prodcode, usersid,
4421 MSIINSTALLCONTEXT_USERUNMANAGED,
4422 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4423 ok(r == ERROR_UNKNOWN_PROPERTY,
4424 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4425 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4426 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4428 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4429 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4431 /* InstallLocation value exists */
4432 sz = MAX_PATH;
4433 lstrcpyA(buf, "apple");
4434 r = pMsiGetProductInfoExA(prodcode, usersid,
4435 MSIINSTALLCONTEXT_USERUNMANAGED,
4436 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4437 ok(r == ERROR_UNKNOWN_PROPERTY,
4438 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4439 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4440 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4442 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4443 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4445 /* InstallSource value exists */
4446 sz = MAX_PATH;
4447 lstrcpyA(buf, "apple");
4448 r = pMsiGetProductInfoExA(prodcode, usersid,
4449 MSIINSTALLCONTEXT_USERUNMANAGED,
4450 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4451 ok(r == ERROR_UNKNOWN_PROPERTY,
4452 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4453 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4454 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4456 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4457 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4459 /* LocalPackage value exists */
4460 sz = MAX_PATH;
4461 lstrcpyA(buf, "apple");
4462 r = pMsiGetProductInfoExA(prodcode, usersid,
4463 MSIINSTALLCONTEXT_USERUNMANAGED,
4464 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4465 ok(r == ERROR_UNKNOWN_PROPERTY,
4466 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4467 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4468 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4470 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4471 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4473 /* Publisher value exists */
4474 sz = MAX_PATH;
4475 lstrcpyA(buf, "apple");
4476 r = pMsiGetProductInfoExA(prodcode, usersid,
4477 MSIINSTALLCONTEXT_USERUNMANAGED,
4478 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4479 ok(r == ERROR_UNKNOWN_PROPERTY,
4480 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4481 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4482 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4484 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4485 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4487 /* URLInfoAbout value exists */
4488 sz = MAX_PATH;
4489 lstrcpyA(buf, "apple");
4490 r = pMsiGetProductInfoExA(prodcode, usersid,
4491 MSIINSTALLCONTEXT_USERUNMANAGED,
4492 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4493 ok(r == ERROR_UNKNOWN_PROPERTY,
4494 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4495 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4496 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4498 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4499 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4501 /* URLUpdateInfo value exists */
4502 sz = MAX_PATH;
4503 lstrcpyA(buf, "apple");
4504 r = pMsiGetProductInfoExA(prodcode, usersid,
4505 MSIINSTALLCONTEXT_USERUNMANAGED,
4506 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4507 ok(r == ERROR_UNKNOWN_PROPERTY,
4508 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4509 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4510 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4512 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4513 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4515 /* VersionMinor value exists */
4516 sz = MAX_PATH;
4517 lstrcpyA(buf, "apple");
4518 r = pMsiGetProductInfoExA(prodcode, usersid,
4519 MSIINSTALLCONTEXT_USERUNMANAGED,
4520 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4521 ok(r == ERROR_UNKNOWN_PROPERTY,
4522 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4523 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4524 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4526 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4527 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4529 /* VersionMajor value exists */
4530 sz = MAX_PATH;
4531 lstrcpyA(buf, "apple");
4532 r = pMsiGetProductInfoExA(prodcode, usersid,
4533 MSIINSTALLCONTEXT_USERUNMANAGED,
4534 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4535 ok(r == ERROR_UNKNOWN_PROPERTY,
4536 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4537 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4538 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4540 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4541 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4543 /* DisplayVersion value exists */
4544 sz = MAX_PATH;
4545 lstrcpyA(buf, "apple");
4546 r = pMsiGetProductInfoExA(prodcode, usersid,
4547 MSIINSTALLCONTEXT_USERUNMANAGED,
4548 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4549 ok(r == ERROR_UNKNOWN_PROPERTY,
4550 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4551 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4552 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4554 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4555 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4557 /* ProductID value exists */
4558 sz = MAX_PATH;
4559 lstrcpyA(buf, "apple");
4560 r = pMsiGetProductInfoExA(prodcode, usersid,
4561 MSIINSTALLCONTEXT_USERUNMANAGED,
4562 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4563 ok(r == ERROR_UNKNOWN_PROPERTY,
4564 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4565 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4566 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4568 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4569 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4571 /* RegCompany value exists */
4572 sz = MAX_PATH;
4573 lstrcpyA(buf, "apple");
4574 r = pMsiGetProductInfoExA(prodcode, usersid,
4575 MSIINSTALLCONTEXT_USERUNMANAGED,
4576 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4577 ok(r == ERROR_UNKNOWN_PROPERTY,
4578 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4579 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4580 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4582 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4583 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4585 /* RegOwner value exists */
4586 sz = MAX_PATH;
4587 lstrcpyA(buf, "apple");
4588 r = pMsiGetProductInfoExA(prodcode, usersid,
4589 MSIINSTALLCONTEXT_USERUNMANAGED,
4590 INSTALLPROPERTY_REGOWNER, buf, &sz);
4591 ok(r == ERROR_UNKNOWN_PROPERTY,
4592 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4593 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4594 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4596 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
4597 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4599 /* Transforms value exists */
4600 sz = MAX_PATH;
4601 lstrcpyA(buf, "apple");
4602 r = pMsiGetProductInfoExA(prodcode, usersid,
4603 MSIINSTALLCONTEXT_USERUNMANAGED,
4604 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
4605 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4606 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
4607 ok(sz == 5, "Expected 5, got %d\n", sz);
4609 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
4610 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4612 /* Language value exists */
4613 sz = MAX_PATH;
4614 lstrcpyA(buf, "apple");
4615 r = pMsiGetProductInfoExA(prodcode, usersid,
4616 MSIINSTALLCONTEXT_USERUNMANAGED,
4617 INSTALLPROPERTY_LANGUAGE, buf, &sz);
4618 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4619 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
4620 ok(sz == 4, "Expected 4, got %d\n", sz);
4622 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
4623 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4625 /* ProductName value exists */
4626 sz = MAX_PATH;
4627 lstrcpyA(buf, "apple");
4628 r = pMsiGetProductInfoExA(prodcode, usersid,
4629 MSIINSTALLCONTEXT_USERUNMANAGED,
4630 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
4631 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4632 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4633 ok(sz == 4, "Expected 4, got %d\n", sz);
4635 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
4636 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4638 /* FIXME */
4640 /* AssignmentType value exists */
4641 sz = MAX_PATH;
4642 lstrcpyA(buf, "apple");
4643 r = pMsiGetProductInfoExA(prodcode, usersid,
4644 MSIINSTALLCONTEXT_USERUNMANAGED,
4645 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
4646 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4647 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4648 ok(sz == 0, "Expected 0, got %d\n", sz);
4650 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
4651 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4653 /* FIXME */
4655 /* PackageCode value exists */
4656 sz = MAX_PATH;
4657 lstrcpyA(buf, "apple");
4658 r = pMsiGetProductInfoExA(prodcode, usersid,
4659 MSIINSTALLCONTEXT_USERUNMANAGED,
4660 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
4661 todo_wine
4663 ok(r == ERROR_BAD_CONFIGURATION,
4664 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
4665 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4666 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4669 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
4670 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4672 /* Version value exists */
4673 sz = MAX_PATH;
4674 lstrcpyA(buf, "apple");
4675 r = pMsiGetProductInfoExA(prodcode, usersid,
4676 MSIINSTALLCONTEXT_USERUNMANAGED,
4677 INSTALLPROPERTY_VERSION, buf, &sz);
4678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4679 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
4680 ok(sz == 3, "Expected 3, got %d\n", sz);
4682 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
4683 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4685 /* ProductIcon value exists */
4686 sz = MAX_PATH;
4687 lstrcpyA(buf, "apple");
4688 r = pMsiGetProductInfoExA(prodcode, usersid,
4689 MSIINSTALLCONTEXT_USERUNMANAGED,
4690 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
4691 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4692 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
4693 ok(sz == 4, "Expected 4, got %d\n", sz);
4695 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
4696 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4698 /* PackageName value exists */
4699 sz = MAX_PATH;
4700 lstrcpyA(buf, "apple");
4701 r = pMsiGetProductInfoExA(prodcode, usersid,
4702 MSIINSTALLCONTEXT_USERUNMANAGED,
4703 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
4704 todo_wine
4706 ok(r == ERROR_UNKNOWN_PRODUCT,
4707 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4708 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4709 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4712 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
4713 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4715 /* AuthorizedLUAApp value exists */
4716 sz = MAX_PATH;
4717 lstrcpyA(buf, "apple");
4718 r = pMsiGetProductInfoExA(prodcode, usersid,
4719 MSIINSTALLCONTEXT_USERUNMANAGED,
4720 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
4721 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4722 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
4723 ok(sz == 4, "Expected 4, got %d\n", sz);
4725 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
4726 RegDeleteValueA(prodkey, "PackageName");
4727 RegDeleteValueA(prodkey, "ProductIcon");
4728 RegDeleteValueA(prodkey, "Version");
4729 RegDeleteValueA(prodkey, "PackageCode");
4730 RegDeleteValueA(prodkey, "AssignmentType");
4731 RegDeleteValueA(prodkey, "ProductName");
4732 RegDeleteValueA(prodkey, "Language");
4733 RegDeleteValueA(prodkey, "Transforms");
4734 RegDeleteValueA(prodkey, "RegOwner");
4735 RegDeleteValueA(prodkey, "RegCompany");
4736 RegDeleteValueA(prodkey, "ProductID");
4737 RegDeleteValueA(prodkey, "DisplayVersion");
4738 RegDeleteValueA(prodkey, "VersionMajor");
4739 RegDeleteValueA(prodkey, "VersionMinor");
4740 RegDeleteValueA(prodkey, "URLUpdateInfo");
4741 RegDeleteValueA(prodkey, "URLInfoAbout");
4742 RegDeleteValueA(prodkey, "Publisher");
4743 RegDeleteValueA(prodkey, "LocalPackage");
4744 RegDeleteValueA(prodkey, "InstallSource");
4745 RegDeleteValueA(prodkey, "InstallLocation");
4746 RegDeleteValueA(prodkey, "DisplayName");
4747 RegDeleteValueA(prodkey, "InstallDate");
4748 RegDeleteValueA(prodkey, "HelpTelephone");
4749 RegDeleteValueA(prodkey, "HelpLink");
4750 RegDeleteValueA(prodkey, "LocalPackage");
4751 RegDeleteKeyA(prodkey, "");
4752 RegCloseKey(prodkey);
4754 /* MSIINSTALLCONTEXT_USERMANAGED */
4756 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4757 lstrcatA(keypath, usersid);
4758 lstrcatA(keypath, "\\Products\\");
4759 lstrcatA(keypath, prod_squashed);
4761 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
4762 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4764 /* local user product key exists */
4765 sz = MAX_PATH;
4766 lstrcpyA(buf, "apple");
4767 r = pMsiGetProductInfoExA(prodcode, usersid,
4768 MSIINSTALLCONTEXT_USERMANAGED,
4769 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4770 ok(r == ERROR_UNKNOWN_PRODUCT,
4771 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4772 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4773 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4775 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
4776 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4778 /* InstallProperties key exists */
4779 sz = MAX_PATH;
4780 lstrcpyA(buf, "apple");
4781 r = pMsiGetProductInfoExA(prodcode, usersid,
4782 MSIINSTALLCONTEXT_USERMANAGED,
4783 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4784 ok(r == ERROR_UNKNOWN_PRODUCT,
4785 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4786 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4787 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4789 res = RegSetValueExA(propkey, "ManagedLocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4790 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4792 /* ManagedLocalPackage value exists */
4793 sz = MAX_PATH;
4794 lstrcpyA(buf, "apple");
4795 r = pMsiGetProductInfoExA(prodcode, usersid,
4796 MSIINSTALLCONTEXT_USERMANAGED,
4797 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
4798 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4799 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
4800 ok(sz == 1, "Expected 1, got %d\n", sz);
4802 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4803 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4805 /* HelpLink value exists */
4806 sz = MAX_PATH;
4807 lstrcpyA(buf, "apple");
4808 r = pMsiGetProductInfoExA(prodcode, usersid,
4809 MSIINSTALLCONTEXT_USERMANAGED,
4810 INSTALLPROPERTY_HELPLINK, buf, &sz);
4811 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4812 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4813 ok(sz == 4, "Expected 4, got %d\n", sz);
4815 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
4816 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4818 /* HelpTelephone value exists */
4819 sz = MAX_PATH;
4820 lstrcpyA(buf, "apple");
4821 r = pMsiGetProductInfoExA(prodcode, usersid,
4822 MSIINSTALLCONTEXT_USERMANAGED,
4823 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
4824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4825 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
4826 ok(sz == 5, "Expected 5, got %d\n", sz);
4828 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4829 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4831 /* InstallDate value exists */
4832 sz = MAX_PATH;
4833 lstrcpyA(buf, "apple");
4834 r = pMsiGetProductInfoExA(prodcode, usersid,
4835 MSIINSTALLCONTEXT_USERMANAGED,
4836 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
4837 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4838 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4839 ok(sz == 4, "Expected 4, got %d\n", sz);
4841 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4842 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4844 /* DisplayName value exists */
4845 sz = MAX_PATH;
4846 lstrcpyA(buf, "apple");
4847 r = pMsiGetProductInfoExA(prodcode, usersid,
4848 MSIINSTALLCONTEXT_USERMANAGED,
4849 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
4850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4851 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4852 ok(sz == 4, "Expected 4, got %d\n", sz);
4854 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4855 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4857 /* InstallLocation value exists */
4858 sz = MAX_PATH;
4859 lstrcpyA(buf, "apple");
4860 r = pMsiGetProductInfoExA(prodcode, usersid,
4861 MSIINSTALLCONTEXT_USERMANAGED,
4862 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
4863 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4864 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4865 ok(sz == 3, "Expected 3, got %d\n", sz);
4867 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4868 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4870 /* InstallSource value exists */
4871 sz = MAX_PATH;
4872 lstrcpyA(buf, "apple");
4873 r = pMsiGetProductInfoExA(prodcode, usersid,
4874 MSIINSTALLCONTEXT_USERMANAGED,
4875 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
4876 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4877 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4878 ok(sz == 6, "Expected 6, got %d\n", sz);
4880 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
4881 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4883 /* LocalPackage value exists */
4884 sz = MAX_PATH;
4885 lstrcpyA(buf, "apple");
4886 r = pMsiGetProductInfoExA(prodcode, usersid,
4887 MSIINSTALLCONTEXT_USERMANAGED,
4888 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
4889 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4890 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
4891 ok(sz == 5, "Expected 5, got %d\n", sz);
4893 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4894 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4896 /* Publisher value exists */
4897 sz = MAX_PATH;
4898 lstrcpyA(buf, "apple");
4899 r = pMsiGetProductInfoExA(prodcode, usersid,
4900 MSIINSTALLCONTEXT_USERMANAGED,
4901 INSTALLPROPERTY_PUBLISHER, buf, &sz);
4902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4903 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4904 ok(sz == 3, "Expected 3, got %d\n", sz);
4906 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4907 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4909 /* URLInfoAbout value exists */
4910 sz = MAX_PATH;
4911 lstrcpyA(buf, "apple");
4912 r = pMsiGetProductInfoExA(prodcode, usersid,
4913 MSIINSTALLCONTEXT_USERMANAGED,
4914 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
4915 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4916 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4917 ok(sz == 5, "Expected 5, got %d\n", sz);
4919 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
4920 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4922 /* URLUpdateInfo value exists */
4923 sz = MAX_PATH;
4924 lstrcpyA(buf, "apple");
4925 r = pMsiGetProductInfoExA(prodcode, usersid,
4926 MSIINSTALLCONTEXT_USERMANAGED,
4927 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
4928 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4929 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
4930 ok(sz == 6, "Expected 6, got %d\n", sz);
4932 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
4933 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4935 /* VersionMinor value exists */
4936 sz = MAX_PATH;
4937 lstrcpyA(buf, "apple");
4938 r = pMsiGetProductInfoExA(prodcode, usersid,
4939 MSIINSTALLCONTEXT_USERMANAGED,
4940 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
4941 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4942 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
4943 ok(sz == 1, "Expected 1, got %d\n", sz);
4945 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
4946 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4948 /* VersionMajor value exists */
4949 sz = MAX_PATH;
4950 lstrcpyA(buf, "apple");
4951 r = pMsiGetProductInfoExA(prodcode, usersid,
4952 MSIINSTALLCONTEXT_USERMANAGED,
4953 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
4954 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4955 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
4956 ok(sz == 1, "Expected 1, got %d\n", sz);
4958 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
4959 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4961 /* DisplayVersion value exists */
4962 sz = MAX_PATH;
4963 lstrcpyA(buf, "apple");
4964 r = pMsiGetProductInfoExA(prodcode, usersid,
4965 MSIINSTALLCONTEXT_USERMANAGED,
4966 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
4967 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4968 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
4969 ok(sz == 5, "Expected 5, got %d\n", sz);
4971 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4972 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4974 /* ProductID value exists */
4975 sz = MAX_PATH;
4976 lstrcpyA(buf, "apple");
4977 r = pMsiGetProductInfoExA(prodcode, usersid,
4978 MSIINSTALLCONTEXT_USERMANAGED,
4979 INSTALLPROPERTY_PRODUCTID, buf, &sz);
4980 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4981 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
4982 ok(sz == 2, "Expected 2, got %d\n", sz);
4984 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4985 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4987 /* RegCompany value exists */
4988 sz = MAX_PATH;
4989 lstrcpyA(buf, "apple");
4990 r = pMsiGetProductInfoExA(prodcode, usersid,
4991 MSIINSTALLCONTEXT_USERMANAGED,
4992 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
4993 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4994 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
4995 ok(sz == 4, "Expected 4, got %d\n", sz);
4997 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
4998 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5000 /* RegOwner value exists */
5001 sz = MAX_PATH;
5002 lstrcpyA(buf, "apple");
5003 r = pMsiGetProductInfoExA(prodcode, usersid,
5004 MSIINSTALLCONTEXT_USERMANAGED,
5005 INSTALLPROPERTY_REGOWNER, buf, &sz);
5006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5007 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
5008 ok(sz == 5, "Expected 5, got %d\n", sz);
5010 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5011 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5013 /* Transforms value exists */
5014 sz = MAX_PATH;
5015 lstrcpyA(buf, "apple");
5016 r = pMsiGetProductInfoExA(prodcode, usersid,
5017 MSIINSTALLCONTEXT_USERMANAGED,
5018 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5019 ok(r == ERROR_UNKNOWN_PRODUCT,
5020 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5021 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5022 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5024 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5025 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5027 /* Language value exists */
5028 sz = MAX_PATH;
5029 lstrcpyA(buf, "apple");
5030 r = pMsiGetProductInfoExA(prodcode, usersid,
5031 MSIINSTALLCONTEXT_USERMANAGED,
5032 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5033 ok(r == ERROR_UNKNOWN_PRODUCT,
5034 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5035 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5036 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5038 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5039 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5041 /* ProductName value exists */
5042 sz = MAX_PATH;
5043 lstrcpyA(buf, "apple");
5044 r = pMsiGetProductInfoExA(prodcode, usersid,
5045 MSIINSTALLCONTEXT_USERMANAGED,
5046 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5047 ok(r == ERROR_UNKNOWN_PRODUCT,
5048 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5049 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5050 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5052 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5053 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5055 /* FIXME */
5057 /* AssignmentType value exists */
5058 sz = MAX_PATH;
5059 lstrcpyA(buf, "apple");
5060 r = pMsiGetProductInfoExA(prodcode, usersid,
5061 MSIINSTALLCONTEXT_USERMANAGED,
5062 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5063 ok(r == ERROR_UNKNOWN_PRODUCT,
5064 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5065 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5066 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5068 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5069 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5071 /* PackageCode value exists */
5072 sz = MAX_PATH;
5073 lstrcpyA(buf, "apple");
5074 r = pMsiGetProductInfoExA(prodcode, usersid,
5075 MSIINSTALLCONTEXT_USERMANAGED,
5076 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5077 ok(r == ERROR_UNKNOWN_PRODUCT,
5078 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5079 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5080 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5082 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5083 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5085 /* Version value exists */
5086 sz = MAX_PATH;
5087 lstrcpyA(buf, "apple");
5088 r = pMsiGetProductInfoExA(prodcode, usersid,
5089 MSIINSTALLCONTEXT_USERMANAGED,
5090 INSTALLPROPERTY_VERSION, buf, &sz);
5091 ok(r == ERROR_UNKNOWN_PRODUCT,
5092 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5093 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5094 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5096 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5097 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5099 /* ProductIcon value exists */
5100 sz = MAX_PATH;
5101 lstrcpyA(buf, "apple");
5102 r = pMsiGetProductInfoExA(prodcode, usersid,
5103 MSIINSTALLCONTEXT_USERMANAGED,
5104 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5105 ok(r == ERROR_UNKNOWN_PRODUCT,
5106 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5107 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5108 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5110 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5111 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5113 /* PackageName value exists */
5114 sz = MAX_PATH;
5115 lstrcpyA(buf, "apple");
5116 r = pMsiGetProductInfoExA(prodcode, usersid,
5117 MSIINSTALLCONTEXT_USERMANAGED,
5118 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5119 ok(r == ERROR_UNKNOWN_PRODUCT,
5120 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5121 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5122 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5124 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5125 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5127 /* AuthorizedLUAApp value exists */
5128 sz = MAX_PATH;
5129 lstrcpyA(buf, "apple");
5130 r = pMsiGetProductInfoExA(prodcode, usersid,
5131 MSIINSTALLCONTEXT_USERMANAGED,
5132 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5133 ok(r == ERROR_UNKNOWN_PRODUCT,
5134 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5135 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5136 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5138 RegDeleteValueA(propkey, "AuthorizedLUAApp");
5139 RegDeleteValueA(propkey, "PackageName");
5140 RegDeleteValueA(propkey, "ProductIcon");
5141 RegDeleteValueA(propkey, "Version");
5142 RegDeleteValueA(propkey, "PackageCode");
5143 RegDeleteValueA(propkey, "AssignmentType");
5144 RegDeleteValueA(propkey, "ProductName");
5145 RegDeleteValueA(propkey, "Language");
5146 RegDeleteValueA(propkey, "Transforms");
5147 RegDeleteValueA(propkey, "RegOwner");
5148 RegDeleteValueA(propkey, "RegCompany");
5149 RegDeleteValueA(propkey, "ProductID");
5150 RegDeleteValueA(propkey, "DisplayVersion");
5151 RegDeleteValueA(propkey, "VersionMajor");
5152 RegDeleteValueA(propkey, "VersionMinor");
5153 RegDeleteValueA(propkey, "URLUpdateInfo");
5154 RegDeleteValueA(propkey, "URLInfoAbout");
5155 RegDeleteValueA(propkey, "Publisher");
5156 RegDeleteValueA(propkey, "LocalPackage");
5157 RegDeleteValueA(propkey, "InstallSource");
5158 RegDeleteValueA(propkey, "InstallLocation");
5159 RegDeleteValueA(propkey, "DisplayName");
5160 RegDeleteValueA(propkey, "InstallDate");
5161 RegDeleteValueA(propkey, "HelpTelephone");
5162 RegDeleteValueA(propkey, "HelpLink");
5163 RegDeleteValueA(propkey, "ManagedLocalPackage");
5164 RegDeleteKeyA(propkey, "");
5165 RegCloseKey(propkey);
5166 RegDeleteKeyA(localkey, "");
5167 RegCloseKey(localkey);
5169 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
5170 lstrcatA(keypath, usersid);
5171 lstrcatA(keypath, "\\Installer\\Products\\");
5172 lstrcatA(keypath, prod_squashed);
5174 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
5175 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5177 /* user product key exists */
5178 sz = MAX_PATH;
5179 lstrcpyA(buf, "apple");
5180 r = pMsiGetProductInfoExA(prodcode, usersid,
5181 MSIINSTALLCONTEXT_USERMANAGED,
5182 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5184 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
5185 ok(sz == 1, "Expected 1, got %d\n", sz);
5187 RegDeleteKeyA(userkey, "");
5188 RegCloseKey(userkey);
5190 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
5191 lstrcatA(keypath, prod_squashed);
5193 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
5194 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5196 /* current user product key exists */
5197 sz = MAX_PATH;
5198 lstrcpyA(buf, "apple");
5199 r = pMsiGetProductInfoExA(prodcode, usersid,
5200 MSIINSTALLCONTEXT_USERMANAGED,
5201 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5202 ok(r == ERROR_UNKNOWN_PRODUCT,
5203 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5204 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5205 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5207 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5208 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5210 /* HelpLink value exists, user product key does not exist */
5211 sz = MAX_PATH;
5212 lstrcpyA(buf, "apple");
5213 r = pMsiGetProductInfoExA(prodcode, usersid,
5214 MSIINSTALLCONTEXT_USERMANAGED,
5215 INSTALLPROPERTY_HELPLINK, buf, &sz);
5216 ok(r == ERROR_UNKNOWN_PRODUCT,
5217 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5218 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5219 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5221 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
5222 lstrcatA(keypath, usersid);
5223 lstrcatA(keypath, "\\Installer\\Products\\");
5224 lstrcatA(keypath, prod_squashed);
5226 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
5227 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5229 res = RegSetValueExA(userkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5230 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5232 /* HelpLink value exists, user product key does exist */
5233 sz = MAX_PATH;
5234 lstrcpyA(buf, "apple");
5235 r = pMsiGetProductInfoExA(prodcode, usersid,
5236 MSIINSTALLCONTEXT_USERMANAGED,
5237 INSTALLPROPERTY_HELPLINK, buf, &sz);
5238 ok(r == ERROR_UNKNOWN_PROPERTY,
5239 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5240 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5241 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5243 res = RegSetValueExA(userkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5244 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5246 /* HelpTelephone value exists */
5247 sz = MAX_PATH;
5248 lstrcpyA(buf, "apple");
5249 r = pMsiGetProductInfoExA(prodcode, usersid,
5250 MSIINSTALLCONTEXT_USERMANAGED,
5251 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5252 ok(r == ERROR_UNKNOWN_PROPERTY,
5253 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5254 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5255 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5257 res = RegSetValueExA(userkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5258 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5260 /* InstallDate value exists */
5261 sz = MAX_PATH;
5262 lstrcpyA(buf, "apple");
5263 r = pMsiGetProductInfoExA(prodcode, usersid,
5264 MSIINSTALLCONTEXT_USERMANAGED,
5265 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5266 ok(r == ERROR_UNKNOWN_PROPERTY,
5267 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5268 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5269 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5271 res = RegSetValueExA(userkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5272 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5274 /* DisplayName value exists */
5275 sz = MAX_PATH;
5276 lstrcpyA(buf, "apple");
5277 r = pMsiGetProductInfoExA(prodcode, usersid,
5278 MSIINSTALLCONTEXT_USERMANAGED,
5279 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5280 ok(r == ERROR_UNKNOWN_PROPERTY,
5281 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5282 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5283 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5285 res = RegSetValueExA(userkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5286 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5288 /* InstallLocation value exists */
5289 sz = MAX_PATH;
5290 lstrcpyA(buf, "apple");
5291 r = pMsiGetProductInfoExA(prodcode, usersid,
5292 MSIINSTALLCONTEXT_USERMANAGED,
5293 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5294 ok(r == ERROR_UNKNOWN_PROPERTY,
5295 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5296 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5297 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5299 res = RegSetValueExA(userkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5300 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5302 /* InstallSource value exists */
5303 sz = MAX_PATH;
5304 lstrcpyA(buf, "apple");
5305 r = pMsiGetProductInfoExA(prodcode, usersid,
5306 MSIINSTALLCONTEXT_USERMANAGED,
5307 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5308 ok(r == ERROR_UNKNOWN_PROPERTY,
5309 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5310 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5311 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5313 res = RegSetValueExA(userkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5314 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5316 /* LocalPackage value exists */
5317 sz = MAX_PATH;
5318 lstrcpyA(buf, "apple");
5319 r = pMsiGetProductInfoExA(prodcode, usersid,
5320 MSIINSTALLCONTEXT_USERMANAGED,
5321 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5322 ok(r == ERROR_UNKNOWN_PROPERTY,
5323 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5324 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5325 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5327 res = RegSetValueExA(userkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5328 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5330 /* Publisher value exists */
5331 sz = MAX_PATH;
5332 lstrcpyA(buf, "apple");
5333 r = pMsiGetProductInfoExA(prodcode, usersid,
5334 MSIINSTALLCONTEXT_USERMANAGED,
5335 INSTALLPROPERTY_PUBLISHER, buf, &sz);
5336 ok(r == ERROR_UNKNOWN_PROPERTY,
5337 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5338 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5339 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5341 res = RegSetValueExA(userkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5342 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5344 /* URLInfoAbout value exists */
5345 sz = MAX_PATH;
5346 lstrcpyA(buf, "apple");
5347 r = pMsiGetProductInfoExA(prodcode, usersid,
5348 MSIINSTALLCONTEXT_USERMANAGED,
5349 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5350 ok(r == ERROR_UNKNOWN_PROPERTY,
5351 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5352 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5353 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5355 res = RegSetValueExA(userkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5356 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5358 /* URLUpdateInfo value exists */
5359 sz = MAX_PATH;
5360 lstrcpyA(buf, "apple");
5361 r = pMsiGetProductInfoExA(prodcode, usersid,
5362 MSIINSTALLCONTEXT_USERMANAGED,
5363 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5364 ok(r == ERROR_UNKNOWN_PROPERTY,
5365 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5366 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5367 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5369 res = RegSetValueExA(userkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5370 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5372 /* VersionMinor value exists */
5373 sz = MAX_PATH;
5374 lstrcpyA(buf, "apple");
5375 r = pMsiGetProductInfoExA(prodcode, usersid,
5376 MSIINSTALLCONTEXT_USERMANAGED,
5377 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5378 ok(r == ERROR_UNKNOWN_PROPERTY,
5379 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5380 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5381 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5383 res = RegSetValueExA(userkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5384 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5386 /* VersionMajor value exists */
5387 sz = MAX_PATH;
5388 lstrcpyA(buf, "apple");
5389 r = pMsiGetProductInfoExA(prodcode, usersid,
5390 MSIINSTALLCONTEXT_USERMANAGED,
5391 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5392 ok(r == ERROR_UNKNOWN_PROPERTY,
5393 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5394 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5395 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5397 res = RegSetValueExA(userkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5398 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5400 /* DisplayVersion value exists */
5401 sz = MAX_PATH;
5402 lstrcpyA(buf, "apple");
5403 r = pMsiGetProductInfoExA(prodcode, usersid,
5404 MSIINSTALLCONTEXT_USERMANAGED,
5405 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5406 ok(r == ERROR_UNKNOWN_PROPERTY,
5407 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5408 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5409 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5411 res = RegSetValueExA(userkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5412 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5414 /* ProductID value exists */
5415 sz = MAX_PATH;
5416 lstrcpyA(buf, "apple");
5417 r = pMsiGetProductInfoExA(prodcode, usersid,
5418 MSIINSTALLCONTEXT_USERMANAGED,
5419 INSTALLPROPERTY_PRODUCTID, buf, &sz);
5420 ok(r == ERROR_UNKNOWN_PROPERTY,
5421 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5422 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5423 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5425 res = RegSetValueExA(userkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5426 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5428 /* RegCompany value exists */
5429 sz = MAX_PATH;
5430 lstrcpyA(buf, "apple");
5431 r = pMsiGetProductInfoExA(prodcode, usersid,
5432 MSIINSTALLCONTEXT_USERMANAGED,
5433 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5434 ok(r == ERROR_UNKNOWN_PROPERTY,
5435 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5436 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5437 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5439 res = RegSetValueExA(userkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5440 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5442 /* RegOwner value exists */
5443 sz = MAX_PATH;
5444 lstrcpyA(buf, "apple");
5445 r = pMsiGetProductInfoExA(prodcode, usersid,
5446 MSIINSTALLCONTEXT_USERMANAGED,
5447 INSTALLPROPERTY_REGOWNER, buf, &sz);
5448 ok(r == ERROR_UNKNOWN_PROPERTY,
5449 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5450 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5451 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5453 res = RegSetValueExA(userkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5454 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5456 /* Transforms value exists */
5457 sz = MAX_PATH;
5458 lstrcpyA(buf, "apple");
5459 r = pMsiGetProductInfoExA(prodcode, usersid,
5460 MSIINSTALLCONTEXT_USERMANAGED,
5461 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5462 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5463 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
5464 ok(sz == 5, "Expected 5, got %d\n", sz);
5466 res = RegSetValueExA(userkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5467 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5469 /* Language value exists */
5470 sz = MAX_PATH;
5471 lstrcpyA(buf, "apple");
5472 r = pMsiGetProductInfoExA(prodcode, usersid,
5473 MSIINSTALLCONTEXT_USERMANAGED,
5474 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5475 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5476 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
5477 ok(sz == 4, "Expected 4, got %d\n", sz);
5479 res = RegSetValueExA(userkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5480 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5482 /* ProductName value exists */
5483 sz = MAX_PATH;
5484 lstrcpyA(buf, "apple");
5485 r = pMsiGetProductInfoExA(prodcode, usersid,
5486 MSIINSTALLCONTEXT_USERMANAGED,
5487 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5488 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5489 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5490 ok(sz == 4, "Expected 4, got %d\n", sz);
5492 res = RegSetValueExA(userkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5493 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5495 /* FIXME */
5497 /* AssignmentType value exists */
5498 sz = MAX_PATH;
5499 lstrcpyA(buf, "apple");
5500 r = pMsiGetProductInfoExA(prodcode, usersid,
5501 MSIINSTALLCONTEXT_USERMANAGED,
5502 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5503 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5504 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5505 ok(sz == 0, "Expected 0, got %d\n", sz);
5507 res = RegSetValueExA(userkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5508 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5510 /* FIXME */
5512 /* PackageCode value exists */
5513 sz = MAX_PATH;
5514 lstrcpyA(buf, "apple");
5515 r = pMsiGetProductInfoExA(prodcode, usersid,
5516 MSIINSTALLCONTEXT_USERMANAGED,
5517 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5518 todo_wine
5520 ok(r == ERROR_BAD_CONFIGURATION,
5521 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
5522 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5523 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5526 res = RegSetValueExA(userkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5527 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5529 /* Version value exists */
5530 sz = MAX_PATH;
5531 lstrcpyA(buf, "apple");
5532 r = pMsiGetProductInfoExA(prodcode, usersid,
5533 MSIINSTALLCONTEXT_USERMANAGED,
5534 INSTALLPROPERTY_VERSION, buf, &sz);
5535 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5536 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
5537 ok(sz == 3, "Expected 3, got %d\n", sz);
5539 res = RegSetValueExA(userkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5542 /* ProductIcon value exists */
5543 sz = MAX_PATH;
5544 lstrcpyA(buf, "apple");
5545 r = pMsiGetProductInfoExA(prodcode, usersid,
5546 MSIINSTALLCONTEXT_USERMANAGED,
5547 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5549 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
5550 ok(sz == 4, "Expected 4, got %d\n", sz);
5552 res = RegSetValueExA(userkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5553 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5555 /* PackageName value exists */
5556 sz = MAX_PATH;
5557 lstrcpyA(buf, "apple");
5558 r = pMsiGetProductInfoExA(prodcode, usersid,
5559 MSIINSTALLCONTEXT_USERMANAGED,
5560 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5561 todo_wine
5563 ok(r == ERROR_UNKNOWN_PRODUCT,
5564 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5565 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5566 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5569 res = RegSetValueExA(userkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5570 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5572 /* AuthorizedLUAApp value exists */
5573 sz = MAX_PATH;
5574 lstrcpyA(buf, "apple");
5575 r = pMsiGetProductInfoExA(prodcode, usersid,
5576 MSIINSTALLCONTEXT_USERMANAGED,
5577 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
5578 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5579 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
5580 ok(sz == 4, "Expected 4, got %d\n", sz);
5582 RegDeleteValueA(userkey, "AuthorizedLUAApp");
5583 RegDeleteValueA(userkey, "PackageName");
5584 RegDeleteValueA(userkey, "ProductIcon");
5585 RegDeleteValueA(userkey, "Version");
5586 RegDeleteValueA(userkey, "PackageCode");
5587 RegDeleteValueA(userkey, "AssignmentType");
5588 RegDeleteValueA(userkey, "ProductName");
5589 RegDeleteValueA(userkey, "Language");
5590 RegDeleteValueA(userkey, "Transforms");
5591 RegDeleteValueA(userkey, "RegOwner");
5592 RegDeleteValueA(userkey, "RegCompany");
5593 RegDeleteValueA(userkey, "ProductID");
5594 RegDeleteValueA(userkey, "DisplayVersion");
5595 RegDeleteValueA(userkey, "VersionMajor");
5596 RegDeleteValueA(userkey, "VersionMinor");
5597 RegDeleteValueA(userkey, "URLUpdateInfo");
5598 RegDeleteValueA(userkey, "URLInfoAbout");
5599 RegDeleteValueA(userkey, "Publisher");
5600 RegDeleteValueA(userkey, "LocalPackage");
5601 RegDeleteValueA(userkey, "InstallSource");
5602 RegDeleteValueA(userkey, "InstallLocation");
5603 RegDeleteValueA(userkey, "DisplayName");
5604 RegDeleteValueA(userkey, "InstallDate");
5605 RegDeleteValueA(userkey, "HelpTelephone");
5606 RegDeleteValueA(userkey, "HelpLink");
5607 RegDeleteKeyA(userkey, "");
5608 RegCloseKey(userkey);
5609 RegDeleteKeyA(prodkey, "");
5610 RegCloseKey(prodkey);
5612 /* MSIINSTALLCONTEXT_MACHINE */
5614 /* szUserSid is non-NULL */
5615 sz = MAX_PATH;
5616 lstrcpyA(buf, "apple");
5617 r = pMsiGetProductInfoExA(prodcode, usersid,
5618 MSIINSTALLCONTEXT_MACHINE,
5619 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5620 ok(r == ERROR_INVALID_PARAMETER,
5621 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5622 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5623 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5625 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
5626 lstrcatA(keypath, prod_squashed);
5628 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
5629 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5631 /* local system product key exists */
5632 sz = MAX_PATH;
5633 lstrcpyA(buf, "apple");
5634 r = pMsiGetProductInfoExA(prodcode, NULL,
5635 MSIINSTALLCONTEXT_MACHINE,
5636 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5637 ok(r == ERROR_UNKNOWN_PRODUCT,
5638 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5639 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5640 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5642 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
5643 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5645 /* InstallProperties key exists */
5646 sz = MAX_PATH;
5647 lstrcpyA(buf, "apple");
5648 r = pMsiGetProductInfoExA(prodcode, NULL,
5649 MSIINSTALLCONTEXT_MACHINE,
5650 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5651 ok(r == ERROR_UNKNOWN_PRODUCT,
5652 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5653 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5654 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5656 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5657 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5659 /* LocalPackage value exists */
5660 sz = MAX_PATH;
5661 lstrcpyA(buf, "apple");
5662 r = pMsiGetProductInfoExA(prodcode, NULL,
5663 MSIINSTALLCONTEXT_MACHINE,
5664 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
5665 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5666 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
5667 ok(sz == 1, "Expected 1, got %d\n", sz);
5669 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5670 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5672 /* HelpLink value exists */
5673 sz = MAX_PATH;
5674 lstrcpyA(buf, "apple");
5675 r = pMsiGetProductInfoExA(prodcode, NULL,
5676 MSIINSTALLCONTEXT_MACHINE,
5677 INSTALLPROPERTY_HELPLINK, buf, &sz);
5678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5679 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
5680 ok(sz == 4, "Expected 4, got %d\n", sz);
5682 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5683 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5685 /* HelpTelephone value exists */
5686 sz = MAX_PATH;
5687 lstrcpyA(buf, "apple");
5688 r = pMsiGetProductInfoExA(prodcode, NULL,
5689 MSIINSTALLCONTEXT_MACHINE,
5690 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
5691 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5692 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
5693 ok(sz == 5, "Expected 5, got %d\n", sz);
5695 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5696 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5698 /* InstallDate value exists */
5699 sz = MAX_PATH;
5700 lstrcpyA(buf, "apple");
5701 r = pMsiGetProductInfoExA(prodcode, NULL,
5702 MSIINSTALLCONTEXT_MACHINE,
5703 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
5704 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5705 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
5706 ok(sz == 4, "Expected 4, got %d\n", sz);
5708 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5709 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5711 /* DisplayName value exists */
5712 sz = MAX_PATH;
5713 lstrcpyA(buf, "apple");
5714 r = pMsiGetProductInfoExA(prodcode, NULL,
5715 MSIINSTALLCONTEXT_MACHINE,
5716 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
5717 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5718 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5719 ok(sz == 4, "Expected 4, got %d\n", sz);
5721 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5722 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5724 /* InstallLocation value exists */
5725 sz = MAX_PATH;
5726 lstrcpyA(buf, "apple");
5727 r = pMsiGetProductInfoExA(prodcode, NULL,
5728 MSIINSTALLCONTEXT_MACHINE,
5729 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
5730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5731 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
5732 ok(sz == 3, "Expected 3, got %d\n", sz);
5734 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5735 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5737 /* InstallSource value exists */
5738 sz = MAX_PATH;
5739 lstrcpyA(buf, "apple");
5740 r = pMsiGetProductInfoExA(prodcode, NULL,
5741 MSIINSTALLCONTEXT_MACHINE,
5742 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
5743 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5744 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
5745 ok(sz == 6, "Expected 6, got %d\n", sz);
5747 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5748 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5750 /* LocalPackage value exists */
5751 sz = MAX_PATH;
5752 lstrcpyA(buf, "apple");
5753 r = pMsiGetProductInfoExA(prodcode, NULL,
5754 MSIINSTALLCONTEXT_MACHINE,
5755 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
5756 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5757 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
5758 ok(sz == 5, "Expected 5, got %d\n", sz);
5760 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5761 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5763 /* Publisher value exists */
5764 sz = MAX_PATH;
5765 lstrcpyA(buf, "apple");
5766 r = pMsiGetProductInfoExA(prodcode, NULL,
5767 MSIINSTALLCONTEXT_MACHINE,
5768 INSTALLPROPERTY_PUBLISHER, buf, &sz);
5769 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5770 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
5771 ok(sz == 3, "Expected 3, got %d\n", sz);
5773 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5774 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5776 /* URLInfoAbout value exists */
5777 sz = MAX_PATH;
5778 lstrcpyA(buf, "apple");
5779 r = pMsiGetProductInfoExA(prodcode, NULL,
5780 MSIINSTALLCONTEXT_MACHINE,
5781 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
5782 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5783 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
5784 ok(sz == 5, "Expected 5, got %d\n", sz);
5786 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5787 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5789 /* URLUpdateInfo value exists */
5790 sz = MAX_PATH;
5791 lstrcpyA(buf, "apple");
5792 r = pMsiGetProductInfoExA(prodcode, NULL,
5793 MSIINSTALLCONTEXT_MACHINE,
5794 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
5795 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5796 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
5797 ok(sz == 6, "Expected 6, got %d\n", sz);
5799 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5800 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5802 /* VersionMinor value exists */
5803 sz = MAX_PATH;
5804 lstrcpyA(buf, "apple");
5805 r = pMsiGetProductInfoExA(prodcode, NULL,
5806 MSIINSTALLCONTEXT_MACHINE,
5807 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
5808 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5809 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
5810 ok(sz == 1, "Expected 1, got %d\n", sz);
5812 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5813 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5815 /* VersionMajor value exists */
5816 sz = MAX_PATH;
5817 lstrcpyA(buf, "apple");
5818 r = pMsiGetProductInfoExA(prodcode, NULL,
5819 MSIINSTALLCONTEXT_MACHINE,
5820 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
5821 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5822 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5823 ok(sz == 1, "Expected 1, got %d\n", sz);
5825 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
5826 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5828 /* DisplayVersion value exists */
5829 sz = MAX_PATH;
5830 lstrcpyA(buf, "apple");
5831 r = pMsiGetProductInfoExA(prodcode, NULL,
5832 MSIINSTALLCONTEXT_MACHINE,
5833 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
5834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5835 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
5836 ok(sz == 5, "Expected 5, got %d\n", sz);
5838 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5839 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5841 /* ProductID value exists */
5842 sz = MAX_PATH;
5843 lstrcpyA(buf, "apple");
5844 r = pMsiGetProductInfoExA(prodcode, NULL,
5845 MSIINSTALLCONTEXT_MACHINE,
5846 INSTALLPROPERTY_PRODUCTID, buf, &sz);
5847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5848 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
5849 ok(sz == 2, "Expected 2, got %d\n", sz);
5851 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5852 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5854 /* RegCompany value exists */
5855 sz = MAX_PATH;
5856 lstrcpyA(buf, "apple");
5857 r = pMsiGetProductInfoExA(prodcode, NULL,
5858 MSIINSTALLCONTEXT_MACHINE,
5859 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
5860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5861 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
5862 ok(sz == 4, "Expected 4, got %d\n", sz);
5864 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
5865 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5867 /* RegOwner value exists */
5868 sz = MAX_PATH;
5869 lstrcpyA(buf, "apple");
5870 r = pMsiGetProductInfoExA(prodcode, NULL,
5871 MSIINSTALLCONTEXT_MACHINE,
5872 INSTALLPROPERTY_REGOWNER, buf, &sz);
5873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5874 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
5875 ok(sz == 5, "Expected 5, got %d\n", sz);
5877 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
5878 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5880 /* Transforms value exists */
5881 sz = MAX_PATH;
5882 lstrcpyA(buf, "apple");
5883 r = pMsiGetProductInfoExA(prodcode, NULL,
5884 MSIINSTALLCONTEXT_MACHINE,
5885 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
5886 ok(r == ERROR_UNKNOWN_PRODUCT,
5887 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5888 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5889 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5891 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5892 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5894 /* Language value exists */
5895 sz = MAX_PATH;
5896 lstrcpyA(buf, "apple");
5897 r = pMsiGetProductInfoExA(prodcode, NULL,
5898 MSIINSTALLCONTEXT_MACHINE,
5899 INSTALLPROPERTY_LANGUAGE, buf, &sz);
5900 ok(r == ERROR_UNKNOWN_PRODUCT,
5901 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5902 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5903 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5905 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5906 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5908 /* ProductName value exists */
5909 sz = MAX_PATH;
5910 lstrcpyA(buf, "apple");
5911 r = pMsiGetProductInfoExA(prodcode, NULL,
5912 MSIINSTALLCONTEXT_MACHINE,
5913 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
5914 ok(r == ERROR_UNKNOWN_PRODUCT,
5915 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5916 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5917 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5919 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
5920 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5922 /* FIXME */
5924 /* AssignmentType value exists */
5925 sz = MAX_PATH;
5926 lstrcpyA(buf, "apple");
5927 r = pMsiGetProductInfoExA(prodcode, NULL,
5928 MSIINSTALLCONTEXT_MACHINE,
5929 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
5930 ok(r == ERROR_UNKNOWN_PRODUCT,
5931 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5932 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5933 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5935 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5936 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5938 /* PackageCode value exists */
5939 sz = MAX_PATH;
5940 lstrcpyA(buf, "apple");
5941 r = pMsiGetProductInfoExA(prodcode, NULL,
5942 MSIINSTALLCONTEXT_MACHINE,
5943 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
5944 ok(r == ERROR_UNKNOWN_PRODUCT,
5945 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5946 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5947 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5949 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5950 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5952 /* Version value exists */
5953 sz = MAX_PATH;
5954 lstrcpyA(buf, "apple");
5955 r = pMsiGetProductInfoExA(prodcode, NULL,
5956 MSIINSTALLCONTEXT_MACHINE,
5957 INSTALLPROPERTY_VERSION, buf, &sz);
5958 ok(r == ERROR_UNKNOWN_PRODUCT,
5959 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5960 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5961 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5963 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
5964 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5966 /* ProductIcon value exists */
5967 sz = MAX_PATH;
5968 lstrcpyA(buf, "apple");
5969 r = pMsiGetProductInfoExA(prodcode, NULL,
5970 MSIINSTALLCONTEXT_MACHINE,
5971 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
5972 ok(r == ERROR_UNKNOWN_PRODUCT,
5973 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5974 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5975 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5977 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
5978 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5980 /* PackageName value exists */
5981 sz = MAX_PATH;
5982 lstrcpyA(buf, "apple");
5983 r = pMsiGetProductInfoExA(prodcode, NULL,
5984 MSIINSTALLCONTEXT_MACHINE,
5985 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
5986 ok(r == ERROR_UNKNOWN_PRODUCT,
5987 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5988 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5989 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5991 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5992 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5994 /* AuthorizedLUAApp value exists */
5995 sz = MAX_PATH;
5996 lstrcpyA(buf, "apple");
5997 r = pMsiGetProductInfoExA(prodcode, NULL,
5998 MSIINSTALLCONTEXT_MACHINE,
5999 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
6000 ok(r == ERROR_UNKNOWN_PRODUCT,
6001 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6002 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6003 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6005 RegDeleteValueA(propkey, "AuthorizedLUAApp");
6006 RegDeleteValueA(propkey, "PackageName");
6007 RegDeleteValueA(propkey, "ProductIcon");
6008 RegDeleteValueA(propkey, "Version");
6009 RegDeleteValueA(propkey, "PackageCode");
6010 RegDeleteValueA(propkey, "AssignmentType");
6011 RegDeleteValueA(propkey, "ProductName");
6012 RegDeleteValueA(propkey, "Language");
6013 RegDeleteValueA(propkey, "Transforms");
6014 RegDeleteValueA(propkey, "RegOwner");
6015 RegDeleteValueA(propkey, "RegCompany");
6016 RegDeleteValueA(propkey, "ProductID");
6017 RegDeleteValueA(propkey, "DisplayVersion");
6018 RegDeleteValueA(propkey, "VersionMajor");
6019 RegDeleteValueA(propkey, "VersionMinor");
6020 RegDeleteValueA(propkey, "URLUpdateInfo");
6021 RegDeleteValueA(propkey, "URLInfoAbout");
6022 RegDeleteValueA(propkey, "Publisher");
6023 RegDeleteValueA(propkey, "LocalPackage");
6024 RegDeleteValueA(propkey, "InstallSource");
6025 RegDeleteValueA(propkey, "InstallLocation");
6026 RegDeleteValueA(propkey, "DisplayName");
6027 RegDeleteValueA(propkey, "InstallDate");
6028 RegDeleteValueA(propkey, "HelpTelephone");
6029 RegDeleteValueA(propkey, "HelpLink");
6030 RegDeleteValueA(propkey, "LocalPackage");
6031 RegDeleteKeyA(propkey, "");
6032 RegCloseKey(propkey);
6033 RegDeleteKeyA(localkey, "");
6034 RegCloseKey(localkey);
6036 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
6037 lstrcatA(keypath, prod_squashed);
6039 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6040 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6042 /* local classes product key exists */
6043 sz = MAX_PATH;
6044 lstrcpyA(buf, "apple");
6045 r = pMsiGetProductInfoExA(prodcode, NULL,
6046 MSIINSTALLCONTEXT_MACHINE,
6047 INSTALLPROPERTY_PRODUCTSTATE, buf, &sz);
6048 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6049 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
6050 ok(sz == 1, "Expected 1, got %d\n", sz);
6052 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
6053 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6055 /* HelpLink value exists */
6056 sz = MAX_PATH;
6057 lstrcpyA(buf, "apple");
6058 r = pMsiGetProductInfoExA(prodcode, NULL,
6059 MSIINSTALLCONTEXT_MACHINE,
6060 INSTALLPROPERTY_HELPLINK, buf, &sz);
6061 ok(r == ERROR_UNKNOWN_PROPERTY,
6062 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6063 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6064 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6066 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
6067 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6069 /* HelpTelephone value exists */
6070 sz = MAX_PATH;
6071 lstrcpyA(buf, "apple");
6072 r = pMsiGetProductInfoExA(prodcode, NULL,
6073 MSIINSTALLCONTEXT_MACHINE,
6074 INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
6075 ok(r == ERROR_UNKNOWN_PROPERTY,
6076 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6077 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6078 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6080 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
6081 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6083 /* InstallDate value exists */
6084 sz = MAX_PATH;
6085 lstrcpyA(buf, "apple");
6086 r = pMsiGetProductInfoExA(prodcode, NULL,
6087 MSIINSTALLCONTEXT_MACHINE,
6088 INSTALLPROPERTY_INSTALLDATE, buf, &sz);
6089 ok(r == ERROR_UNKNOWN_PROPERTY,
6090 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6091 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6092 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6094 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
6095 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6097 /* DisplayName value exists */
6098 sz = MAX_PATH;
6099 lstrcpyA(buf, "apple");
6100 r = pMsiGetProductInfoExA(prodcode, NULL,
6101 MSIINSTALLCONTEXT_MACHINE,
6102 INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
6103 ok(r == ERROR_UNKNOWN_PROPERTY,
6104 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6105 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6106 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6108 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6109 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6111 /* InstallLocation value exists */
6112 sz = MAX_PATH;
6113 lstrcpyA(buf, "apple");
6114 r = pMsiGetProductInfoExA(prodcode, NULL,
6115 MSIINSTALLCONTEXT_MACHINE,
6116 INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
6117 ok(r == ERROR_UNKNOWN_PROPERTY,
6118 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6119 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6120 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6122 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6123 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6125 /* InstallSource value exists */
6126 sz = MAX_PATH;
6127 lstrcpyA(buf, "apple");
6128 r = pMsiGetProductInfoExA(prodcode, NULL,
6129 MSIINSTALLCONTEXT_MACHINE,
6130 INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
6131 ok(r == ERROR_UNKNOWN_PROPERTY,
6132 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6133 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6134 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6136 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6137 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6139 /* LocalPackage value exists */
6140 sz = MAX_PATH;
6141 lstrcpyA(buf, "apple");
6142 r = pMsiGetProductInfoExA(prodcode, NULL,
6143 MSIINSTALLCONTEXT_MACHINE,
6144 INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
6145 ok(r == ERROR_UNKNOWN_PROPERTY,
6146 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6147 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6148 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6150 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6151 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6153 /* Publisher value exists */
6154 sz = MAX_PATH;
6155 lstrcpyA(buf, "apple");
6156 r = pMsiGetProductInfoExA(prodcode, NULL,
6157 MSIINSTALLCONTEXT_MACHINE,
6158 INSTALLPROPERTY_PUBLISHER, buf, &sz);
6159 ok(r == ERROR_UNKNOWN_PROPERTY,
6160 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6161 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6162 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6164 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6165 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6167 /* URLInfoAbout value exists */
6168 sz = MAX_PATH;
6169 lstrcpyA(buf, "apple");
6170 r = pMsiGetProductInfoExA(prodcode, NULL,
6171 MSIINSTALLCONTEXT_MACHINE,
6172 INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
6173 ok(r == ERROR_UNKNOWN_PROPERTY,
6174 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6175 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6176 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6178 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6179 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6181 /* URLUpdateInfo value exists */
6182 sz = MAX_PATH;
6183 lstrcpyA(buf, "apple");
6184 r = pMsiGetProductInfoExA(prodcode, NULL,
6185 MSIINSTALLCONTEXT_MACHINE,
6186 INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
6187 ok(r == ERROR_UNKNOWN_PROPERTY,
6188 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6189 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6190 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6192 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6193 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6195 /* VersionMinor value exists */
6196 sz = MAX_PATH;
6197 lstrcpyA(buf, "apple");
6198 r = pMsiGetProductInfoExA(prodcode, NULL,
6199 MSIINSTALLCONTEXT_MACHINE,
6200 INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
6201 ok(r == ERROR_UNKNOWN_PROPERTY,
6202 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6203 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6204 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6206 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6207 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6209 /* VersionMajor value exists */
6210 sz = MAX_PATH;
6211 lstrcpyA(buf, "apple");
6212 r = pMsiGetProductInfoExA(prodcode, NULL,
6213 MSIINSTALLCONTEXT_MACHINE,
6214 INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
6215 ok(r == ERROR_UNKNOWN_PROPERTY,
6216 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6217 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6218 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6220 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6221 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6223 /* DisplayVersion value exists */
6224 sz = MAX_PATH;
6225 lstrcpyA(buf, "apple");
6226 r = pMsiGetProductInfoExA(prodcode, NULL,
6227 MSIINSTALLCONTEXT_MACHINE,
6228 INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
6229 ok(r == ERROR_UNKNOWN_PROPERTY,
6230 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6231 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6232 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6234 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6235 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6237 /* ProductID value exists */
6238 sz = MAX_PATH;
6239 lstrcpyA(buf, "apple");
6240 r = pMsiGetProductInfoExA(prodcode, NULL,
6241 MSIINSTALLCONTEXT_MACHINE,
6242 INSTALLPROPERTY_PRODUCTID, buf, &sz);
6243 ok(r == ERROR_UNKNOWN_PROPERTY,
6244 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6245 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6246 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6248 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6249 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6251 /* RegCompany value exists */
6252 sz = MAX_PATH;
6253 lstrcpyA(buf, "apple");
6254 r = pMsiGetProductInfoExA(prodcode, NULL,
6255 MSIINSTALLCONTEXT_MACHINE,
6256 INSTALLPROPERTY_REGCOMPANY, buf, &sz);
6257 ok(r == ERROR_UNKNOWN_PROPERTY,
6258 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6259 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6260 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6262 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6263 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6265 /* RegOwner value exists */
6266 sz = MAX_PATH;
6267 lstrcpyA(buf, "apple");
6268 r = pMsiGetProductInfoExA(prodcode, NULL,
6269 MSIINSTALLCONTEXT_MACHINE,
6270 INSTALLPROPERTY_REGOWNER, buf, &sz);
6271 ok(r == ERROR_UNKNOWN_PROPERTY,
6272 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6273 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6274 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6276 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6277 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6279 /* Transforms value exists */
6280 sz = MAX_PATH;
6281 lstrcpyA(buf, "apple");
6282 r = pMsiGetProductInfoExA(prodcode, NULL,
6283 MSIINSTALLCONTEXT_MACHINE,
6284 INSTALLPROPERTY_TRANSFORMS, buf, &sz);
6285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6286 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
6287 ok(sz == 5, "Expected 5, got %d\n", sz);
6289 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6290 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6292 /* Language value exists */
6293 sz = MAX_PATH;
6294 lstrcpyA(buf, "apple");
6295 r = pMsiGetProductInfoExA(prodcode, NULL,
6296 MSIINSTALLCONTEXT_MACHINE,
6297 INSTALLPROPERTY_LANGUAGE, buf, &sz);
6298 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6299 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
6300 ok(sz == 4, "Expected 4, got %d\n", sz);
6302 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6303 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6305 /* ProductName value exists */
6306 sz = MAX_PATH;
6307 lstrcpyA(buf, "apple");
6308 r = pMsiGetProductInfoExA(prodcode, NULL,
6309 MSIINSTALLCONTEXT_MACHINE,
6310 INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
6311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6312 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6313 ok(sz == 4, "Expected 4, got %d\n", sz);
6315 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6316 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6318 /* FIXME */
6320 /* AssignmentType value exists */
6321 sz = MAX_PATH;
6322 lstrcpyA(buf, "apple");
6323 r = pMsiGetProductInfoExA(prodcode, NULL,
6324 MSIINSTALLCONTEXT_MACHINE,
6325 INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
6326 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6327 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
6328 ok(sz == 0, "Expected 0, got %d\n", sz);
6330 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6331 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6333 /* FIXME */
6335 /* PackageCode value exists */
6336 sz = MAX_PATH;
6337 lstrcpyA(buf, "apple");
6338 r = pMsiGetProductInfoExA(prodcode, NULL,
6339 MSIINSTALLCONTEXT_MACHINE,
6340 INSTALLPROPERTY_PACKAGECODE, buf, &sz);
6341 todo_wine
6343 ok(r == ERROR_BAD_CONFIGURATION,
6344 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
6345 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6346 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6349 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6350 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6352 /* Version value exists */
6353 sz = MAX_PATH;
6354 lstrcpyA(buf, "apple");
6355 r = pMsiGetProductInfoExA(prodcode, NULL,
6356 MSIINSTALLCONTEXT_MACHINE,
6357 INSTALLPROPERTY_VERSION, buf, &sz);
6358 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6359 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
6360 ok(sz == 3, "Expected 3, got %d\n", sz);
6362 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6363 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6365 /* ProductIcon value exists */
6366 sz = MAX_PATH;
6367 lstrcpyA(buf, "apple");
6368 r = pMsiGetProductInfoExA(prodcode, NULL,
6369 MSIINSTALLCONTEXT_MACHINE,
6370 INSTALLPROPERTY_PRODUCTICON, buf, &sz);
6371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6372 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
6373 ok(sz == 4, "Expected 4, got %d\n", sz);
6375 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6376 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6378 /* PackageName value exists */
6379 sz = MAX_PATH;
6380 lstrcpyA(buf, "apple");
6381 r = pMsiGetProductInfoExA(prodcode, NULL,
6382 MSIINSTALLCONTEXT_MACHINE,
6383 INSTALLPROPERTY_PACKAGENAME, buf, &sz);
6384 todo_wine
6386 ok(r == ERROR_UNKNOWN_PRODUCT,
6387 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6388 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6389 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6392 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6393 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6395 /* AuthorizedLUAApp value exists */
6396 sz = MAX_PATH;
6397 lstrcpyA(buf, "apple");
6398 r = pMsiGetProductInfoExA(prodcode, NULL,
6399 MSIINSTALLCONTEXT_MACHINE,
6400 INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
6401 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6402 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
6403 ok(sz == 4, "Expected 4, got %d\n", sz);
6405 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
6406 RegDeleteValueA(prodkey, "PackageName");
6407 RegDeleteValueA(prodkey, "ProductIcon");
6408 RegDeleteValueA(prodkey, "Version");
6409 RegDeleteValueA(prodkey, "PackageCode");
6410 RegDeleteValueA(prodkey, "AssignmentType");
6411 RegDeleteValueA(prodkey, "ProductName");
6412 RegDeleteValueA(prodkey, "Language");
6413 RegDeleteValueA(prodkey, "Transforms");
6414 RegDeleteValueA(prodkey, "RegOwner");
6415 RegDeleteValueA(prodkey, "RegCompany");
6416 RegDeleteValueA(prodkey, "ProductID");
6417 RegDeleteValueA(prodkey, "DisplayVersion");
6418 RegDeleteValueA(prodkey, "VersionMajor");
6419 RegDeleteValueA(prodkey, "VersionMinor");
6420 RegDeleteValueA(prodkey, "URLUpdateInfo");
6421 RegDeleteValueA(prodkey, "URLInfoAbout");
6422 RegDeleteValueA(prodkey, "Publisher");
6423 RegDeleteValueA(prodkey, "LocalPackage");
6424 RegDeleteValueA(prodkey, "InstallSource");
6425 RegDeleteValueA(prodkey, "InstallLocation");
6426 RegDeleteValueA(prodkey, "DisplayName");
6427 RegDeleteValueA(prodkey, "InstallDate");
6428 RegDeleteValueA(prodkey, "HelpTelephone");
6429 RegDeleteValueA(prodkey, "HelpLink");
6430 RegDeleteKeyA(prodkey, "");
6431 RegCloseKey(prodkey);
6434 #define INIT_USERINFO() \
6435 lstrcpyA(user, "apple"); \
6436 lstrcpyA(org, "orange"); \
6437 lstrcpyA(serial, "banana"); \
6438 usersz = orgsz = serialsz = MAX_PATH;
6440 static void test_MsiGetUserInfo(void)
6442 USERINFOSTATE state;
6443 CHAR user[MAX_PATH];
6444 CHAR org[MAX_PATH];
6445 CHAR serial[MAX_PATH];
6446 DWORD usersz, orgsz, serialsz;
6447 CHAR keypath[MAX_PATH * 2];
6448 CHAR prodcode[MAX_PATH];
6449 CHAR prod_squashed[MAX_PATH];
6450 HKEY prodkey, userprod, props;
6451 LPSTR usersid;
6452 LONG res;
6454 create_test_guid(prodcode, prod_squashed);
6455 get_user_sid(&usersid);
6457 /* NULL szProduct */
6458 INIT_USERINFO();
6459 state = MsiGetUserInfoA(NULL, user, &usersz, org, &orgsz, serial, &serialsz);
6460 ok(state == USERINFOSTATE_INVALIDARG,
6461 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6462 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6463 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6464 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6465 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6466 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6467 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6469 /* empty szProductCode */
6470 INIT_USERINFO();
6471 state = MsiGetUserInfoA("", user, &usersz, org, &orgsz, serial, &serialsz);
6472 ok(state == USERINFOSTATE_INVALIDARG,
6473 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6474 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6475 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6476 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6477 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6478 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6479 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6481 /* garbage szProductCode */
6482 INIT_USERINFO();
6483 state = MsiGetUserInfoA("garbage", user, &usersz, org, &orgsz, serial, &serialsz);
6484 ok(state == USERINFOSTATE_INVALIDARG,
6485 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6486 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6487 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6488 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6489 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6490 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6491 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6493 /* guid without brackets */
6494 INIT_USERINFO();
6495 state = MsiGetUserInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
6496 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 /* guid with brackets */
6507 INIT_USERINFO();
6508 state = MsiGetUserInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
6509 user, &usersz, org, &orgsz, serial, &serialsz);
6510 ok(state == USERINFOSTATE_UNKNOWN,
6511 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6512 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6513 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6514 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6515 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6516 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6517 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6519 /* NULL lpUserNameBuf */
6520 INIT_USERINFO();
6521 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
6522 ok(state == USERINFOSTATE_UNKNOWN,
6523 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
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 /* NULL pcchUserNameBuf */
6531 INIT_USERINFO();
6532 state = MsiGetUserInfoA(prodcode, user, NULL, org, &orgsz, serial, &serialsz);
6533 ok(state == USERINFOSTATE_INVALIDARG,
6534 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6535 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6536 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6537 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6538 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6539 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6541 /* both lpUserNameBuf and pcchUserNameBuf NULL */
6542 INIT_USERINFO();
6543 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6544 ok(state == USERINFOSTATE_UNKNOWN,
6545 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6546 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6547 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6548 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6549 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6551 /* NULL lpOrgNameBuf */
6552 INIT_USERINFO();
6553 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, &orgsz, serial, &serialsz);
6554 ok(state == USERINFOSTATE_UNKNOWN,
6555 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6556 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6557 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6558 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6559 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6560 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6562 /* NULL pcchOrgNameBuf */
6563 INIT_USERINFO();
6564 state = MsiGetUserInfoA(prodcode, user, &usersz, org, NULL, serial, &serialsz);
6565 ok(state == USERINFOSTATE_INVALIDARG,
6566 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6567 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6568 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6569 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6570 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6571 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6573 /* both lpOrgNameBuf and pcchOrgNameBuf NULL */
6574 INIT_USERINFO();
6575 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, NULL, serial, &serialsz);
6576 ok(state == USERINFOSTATE_UNKNOWN,
6577 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6578 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6579 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6580 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6581 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6583 /* NULL lpSerialBuf */
6584 INIT_USERINFO();
6585 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, &serialsz);
6586 ok(state == USERINFOSTATE_UNKNOWN,
6587 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6588 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6589 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6590 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6591 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6592 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6594 /* NULL pcchSerialBuf */
6595 INIT_USERINFO();
6596 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, NULL);
6597 ok(state == USERINFOSTATE_INVALIDARG,
6598 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
6599 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6600 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6601 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6602 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6603 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6605 /* both lpSerialBuf and pcchSerialBuf NULL */
6606 INIT_USERINFO();
6607 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, NULL);
6608 ok(state == USERINFOSTATE_UNKNOWN,
6609 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
6610 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6611 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6612 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6613 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6615 /* MSIINSTALLCONTEXT_USERMANAGED */
6617 /* create local system product key */
6618 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6619 lstrcatA(keypath, usersid);
6620 lstrcatA(keypath, "\\Installer\\Products\\");
6621 lstrcatA(keypath, prod_squashed);
6623 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6624 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6626 /* managed product key exists */
6627 INIT_USERINFO();
6628 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6629 ok(state == USERINFOSTATE_ABSENT,
6630 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6631 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6632 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6633 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6634 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6635 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6636 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6638 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6639 lstrcatA(keypath, "Installer\\UserData\\");
6640 lstrcatA(keypath, usersid);
6641 lstrcatA(keypath, "\\Products\\");
6642 lstrcatA(keypath, prod_squashed);
6644 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6645 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6647 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6648 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6650 /* InstallProperties key exists */
6651 INIT_USERINFO();
6652 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6653 ok(state == USERINFOSTATE_ABSENT,
6654 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6655 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6656 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6657 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6658 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6659 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6660 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6662 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6663 INIT_USERINFO();
6664 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6665 ok(state == USERINFOSTATE_ABSENT,
6666 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6667 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6668 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6669 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6670 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6672 /* RegOwner, RegCompany don't exist, out params are NULL */
6673 INIT_USERINFO();
6674 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6675 ok(state == USERINFOSTATE_ABSENT,
6676 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6677 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6678 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6680 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6681 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6683 /* RegOwner value exists */
6684 INIT_USERINFO();
6685 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6686 ok(state == USERINFOSTATE_ABSENT,
6687 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6688 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6689 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6690 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6691 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6692 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6693 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6695 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6696 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6698 /* RegCompany value exists */
6699 INIT_USERINFO();
6700 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6701 ok(state == USERINFOSTATE_ABSENT,
6702 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6703 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6704 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6705 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6706 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6707 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6708 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6710 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6711 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6713 /* ProductID value exists */
6714 INIT_USERINFO();
6715 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6716 ok(state == USERINFOSTATE_PRESENT,
6717 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6718 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6719 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6720 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6721 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6722 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6723 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6725 /* pcchUserNameBuf is too small */
6726 INIT_USERINFO();
6727 usersz = 0;
6728 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6729 ok(state == USERINFOSTATE_MOREDATA,
6730 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
6731 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6732 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6733 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6734 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6735 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6736 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6738 /* pcchUserNameBuf has no room for NULL terminator */
6739 INIT_USERINFO();
6740 usersz = 5;
6741 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6742 ok(state == USERINFOSTATE_MOREDATA,
6743 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
6744 todo_wine
6746 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6748 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6749 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6750 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6751 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6752 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6754 /* pcchUserNameBuf is too small, lpUserNameBuf is NULL */
6755 INIT_USERINFO();
6756 usersz = 0;
6757 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
6758 ok(state == USERINFOSTATE_PRESENT,
6759 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6760 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6761 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6762 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6763 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6764 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6765 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6767 RegDeleteValueA(props, "ProductID");
6768 RegDeleteValueA(props, "RegCompany");
6769 RegDeleteValueA(props, "RegOwner");
6770 RegDeleteKeyA(props, "");
6771 RegCloseKey(props);
6772 RegDeleteKeyA(userprod, "");
6773 RegCloseKey(userprod);
6774 RegDeleteKeyA(prodkey, "");
6775 RegCloseKey(prodkey);
6777 /* MSIINSTALLCONTEXT_USERUNMANAGED */
6779 /* create local system product key */
6780 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
6781 lstrcatA(keypath, prod_squashed);
6783 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
6784 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6786 /* product key exists */
6787 INIT_USERINFO();
6788 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6789 ok(state == USERINFOSTATE_ABSENT,
6790 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6791 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6792 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6793 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6794 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6795 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6796 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6798 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6799 lstrcatA(keypath, "Installer\\UserData\\");
6800 lstrcatA(keypath, usersid);
6801 lstrcatA(keypath, "\\Products\\");
6802 lstrcatA(keypath, prod_squashed);
6804 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6805 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6807 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6808 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6810 /* InstallProperties key exists */
6811 INIT_USERINFO();
6812 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6813 ok(state == USERINFOSTATE_ABSENT,
6814 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6815 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6816 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6817 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6818 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6819 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6820 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6822 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6823 INIT_USERINFO();
6824 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6825 ok(state == USERINFOSTATE_ABSENT,
6826 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6827 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6828 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6829 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6830 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6832 /* RegOwner, RegCompany don't exist, out params are NULL */
6833 INIT_USERINFO();
6834 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6835 ok(state == USERINFOSTATE_ABSENT,
6836 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6837 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6838 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6840 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6841 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6843 /* RegOwner value exists */
6844 INIT_USERINFO();
6845 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6846 ok(state == USERINFOSTATE_ABSENT,
6847 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6848 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6849 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6850 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6851 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6852 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6853 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6855 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6856 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6858 /* RegCompany value exists */
6859 INIT_USERINFO();
6860 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6861 ok(state == USERINFOSTATE_ABSENT,
6862 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6863 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6864 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6865 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6866 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6867 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6868 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6870 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6871 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6873 /* ProductID value exists */
6874 INIT_USERINFO();
6875 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6876 ok(state == USERINFOSTATE_PRESENT,
6877 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6878 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6879 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6880 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6881 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6882 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6883 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
6885 RegDeleteValueA(props, "ProductID");
6886 RegDeleteValueA(props, "RegCompany");
6887 RegDeleteValueA(props, "RegOwner");
6888 RegDeleteKeyA(props, "");
6889 RegCloseKey(props);
6890 RegDeleteKeyA(userprod, "");
6891 RegCloseKey(userprod);
6892 RegDeleteKeyA(prodkey, "");
6893 RegCloseKey(prodkey);
6895 /* MSIINSTALLCONTEXT_MACHINE */
6897 /* create local system product key */
6898 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
6899 lstrcatA(keypath, prod_squashed);
6901 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
6902 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6904 /* product key exists */
6905 INIT_USERINFO();
6906 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6907 ok(state == USERINFOSTATE_ABSENT,
6908 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6909 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6910 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6911 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6912 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
6913 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6914 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6916 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
6917 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18");
6918 lstrcatA(keypath, "\\Products\\");
6919 lstrcatA(keypath, prod_squashed);
6921 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userprod);
6922 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6924 res = RegCreateKeyA(userprod, "InstallProperties", &props);
6925 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6927 /* InstallProperties key exists */
6928 INIT_USERINFO();
6929 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6930 ok(state == USERINFOSTATE_ABSENT,
6931 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6932 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
6933 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
6934 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6935 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
6936 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
6937 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
6939 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
6940 INIT_USERINFO();
6941 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
6942 ok(state == USERINFOSTATE_ABSENT,
6943 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6944 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6945 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6946 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6947 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6949 /* RegOwner, RegCompany don't exist, out params are NULL */
6950 INIT_USERINFO();
6951 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
6952 ok(state == USERINFOSTATE_ABSENT,
6953 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6954 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6955 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6957 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6958 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6960 /* RegOwner value exists */
6961 INIT_USERINFO();
6962 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6963 ok(state == USERINFOSTATE_ABSENT,
6964 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6965 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6966 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
6967 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6968 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6969 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
6970 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6972 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
6973 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6975 /* RegCompany value exists */
6976 INIT_USERINFO();
6977 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6978 ok(state == USERINFOSTATE_ABSENT,
6979 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
6980 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6981 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6982 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
6983 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6984 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
6985 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
6987 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
6988 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6990 /* ProductID value exists */
6991 INIT_USERINFO();
6992 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
6993 ok(state == USERINFOSTATE_PRESENT,
6994 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
6995 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
6996 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
6997 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
6998 ok(usersz == 5, "Expected 5, got %d\n", usersz);
6999 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
7000 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
7002 RegDeleteValueA(props, "ProductID");
7003 RegDeleteValueA(props, "RegCompany");
7004 RegDeleteValueA(props, "RegOwner");
7005 RegDeleteKeyA(props, "");
7006 RegCloseKey(props);
7007 RegDeleteKeyA(userprod, "");
7008 RegCloseKey(userprod);
7009 RegDeleteKeyA(prodkey, "");
7010 RegCloseKey(prodkey);
7013 static void test_MsiOpenProduct(void)
7015 MSIHANDLE hprod, hdb;
7016 CHAR val[MAX_PATH];
7017 CHAR path[MAX_PATH];
7018 CHAR keypath[MAX_PATH*2];
7019 CHAR prodcode[MAX_PATH];
7020 CHAR prod_squashed[MAX_PATH];
7021 HKEY prodkey, userkey, props;
7022 LPSTR usersid;
7023 DWORD size;
7024 LONG res;
7025 UINT r;
7027 GetCurrentDirectoryA(MAX_PATH, path);
7028 lstrcatA(path, "\\");
7030 create_test_guid(prodcode, prod_squashed);
7031 get_user_sid(&usersid);
7033 hdb = create_package_db(prodcode);
7034 MsiCloseHandle(hdb);
7036 /* NULL szProduct */
7037 hprod = 0xdeadbeef;
7038 r = MsiOpenProductA(NULL, &hprod);
7039 ok(r == ERROR_INVALID_PARAMETER,
7040 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7041 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7043 /* empty szProduct */
7044 hprod = 0xdeadbeef;
7045 r = MsiOpenProductA("", &hprod);
7046 ok(r == ERROR_INVALID_PARAMETER,
7047 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7048 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7050 /* garbage szProduct */
7051 hprod = 0xdeadbeef;
7052 r = MsiOpenProductA("garbage", &hprod);
7053 ok(r == ERROR_INVALID_PARAMETER,
7054 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7055 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7057 /* guid without brackets */
7058 hprod = 0xdeadbeef;
7059 r = MsiOpenProductA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", &hprod);
7060 ok(r == ERROR_INVALID_PARAMETER,
7061 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7062 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7064 /* guid with brackets */
7065 hprod = 0xdeadbeef;
7066 r = MsiOpenProductA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", &hprod);
7067 ok(r == ERROR_UNKNOWN_PRODUCT,
7068 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7069 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7071 /* same length as guid, but random */
7072 hprod = 0xdeadbeef;
7073 r = MsiOpenProductA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", &hprod);
7074 ok(r == ERROR_INVALID_PARAMETER,
7075 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7076 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7078 /* hProduct is NULL */
7079 hprod = 0xdeadbeef;
7080 r = MsiOpenProductA(prodcode, NULL);
7081 ok(r == ERROR_INVALID_PARAMETER,
7082 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7083 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7085 /* MSIINSTALLCONTEXT_USERMANAGED */
7087 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7088 lstrcatA(keypath, "Installer\\Managed\\");
7089 lstrcatA(keypath, usersid);
7090 lstrcatA(keypath, "\\Installer\\Products\\");
7091 lstrcatA(keypath, prod_squashed);
7093 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
7094 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7096 /* managed product key exists */
7097 hprod = 0xdeadbeef;
7098 r = MsiOpenProductA(prodcode, &hprod);
7099 ok(r == ERROR_UNKNOWN_PRODUCT,
7100 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7101 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7103 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7104 lstrcatA(keypath, "Installer\\UserData\\");
7105 lstrcatA(keypath, usersid);
7106 lstrcatA(keypath, "\\Products\\");
7107 lstrcatA(keypath, prod_squashed);
7109 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
7110 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7112 /* user product key exists */
7113 hprod = 0xdeadbeef;
7114 r = MsiOpenProductA(prodcode, &hprod);
7115 ok(r == ERROR_UNKNOWN_PRODUCT,
7116 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7117 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7119 res = RegCreateKeyA(userkey, "InstallProperties", &props);
7120 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7122 /* InstallProperties key exists */
7123 hprod = 0xdeadbeef;
7124 r = MsiOpenProductA(prodcode, &hprod);
7125 ok(r == ERROR_UNKNOWN_PRODUCT,
7126 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7127 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7129 lstrcpyA(val, path);
7130 lstrcatA(val, "\\winetest.msi");
7131 res = RegSetValueExA(props, "ManagedLocalPackage", 0, REG_SZ,
7132 (const BYTE *)val, lstrlenA(val) + 1);
7133 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7135 /* ManagedLocalPackage value exists */
7136 hprod = 0xdeadbeef;
7137 r = MsiOpenProductA(prodcode, &hprod);
7138 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7139 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
7141 size = MAX_PATH;
7142 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
7143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7144 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
7145 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
7147 MsiCloseHandle(hprod);
7149 RegDeleteValueA(props, "ManagedLocalPackage");
7150 RegDeleteKeyA(props, "");
7151 RegCloseKey(props);
7152 RegDeleteKeyA(userkey, "");
7153 RegCloseKey(userkey);
7154 RegDeleteKeyA(prodkey, "");
7155 RegCloseKey(prodkey);
7157 /* MSIINSTALLCONTEXT_USERUNMANAGED */
7159 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
7160 lstrcatA(keypath, prod_squashed);
7162 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
7163 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7165 /* unmanaged product key exists */
7166 hprod = 0xdeadbeef;
7167 r = MsiOpenProductA(prodcode, &hprod);
7168 ok(r == ERROR_UNKNOWN_PRODUCT,
7169 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7170 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7172 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7173 lstrcatA(keypath, "Installer\\UserData\\");
7174 lstrcatA(keypath, usersid);
7175 lstrcatA(keypath, "\\Products\\");
7176 lstrcatA(keypath, prod_squashed);
7178 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
7179 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7181 /* user product key exists */
7182 hprod = 0xdeadbeef;
7183 r = MsiOpenProductA(prodcode, &hprod);
7184 ok(r == ERROR_UNKNOWN_PRODUCT,
7185 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7186 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7188 res = RegCreateKeyA(userkey, "InstallProperties", &props);
7189 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7191 /* InstallProperties key exists */
7192 hprod = 0xdeadbeef;
7193 r = MsiOpenProductA(prodcode, &hprod);
7194 ok(r == ERROR_UNKNOWN_PRODUCT,
7195 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7196 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7198 lstrcpyA(val, path);
7199 lstrcatA(val, "\\winetest.msi");
7200 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7201 (const BYTE *)val, lstrlenA(val) + 1);
7202 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7204 /* LocalPackage value exists */
7205 hprod = 0xdeadbeef;
7206 r = MsiOpenProductA(prodcode, &hprod);
7207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7208 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
7210 size = MAX_PATH;
7211 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
7212 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7213 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
7214 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
7216 MsiCloseHandle(hprod);
7218 RegDeleteValueA(props, "LocalPackage");
7219 RegDeleteKeyA(props, "");
7220 RegCloseKey(props);
7221 RegDeleteKeyA(userkey, "");
7222 RegCloseKey(userkey);
7223 RegDeleteKeyA(prodkey, "");
7224 RegCloseKey(prodkey);
7226 /* MSIINSTALLCONTEXT_MACHINE */
7228 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
7229 lstrcatA(keypath, prod_squashed);
7231 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
7232 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7234 /* managed product key exists */
7235 hprod = 0xdeadbeef;
7236 r = MsiOpenProductA(prodcode, &hprod);
7237 ok(r == ERROR_UNKNOWN_PRODUCT,
7238 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7239 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7241 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
7242 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
7243 lstrcatA(keypath, prod_squashed);
7245 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &userkey);
7246 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7248 /* user product key exists */
7249 hprod = 0xdeadbeef;
7250 r = MsiOpenProductA(prodcode, &hprod);
7251 ok(r == ERROR_UNKNOWN_PRODUCT,
7252 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7253 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7255 res = RegCreateKeyA(userkey, "InstallProperties", &props);
7256 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7258 /* InstallProperties key exists */
7259 hprod = 0xdeadbeef;
7260 r = MsiOpenProductA(prodcode, &hprod);
7261 ok(r == ERROR_UNKNOWN_PRODUCT,
7262 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7263 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7265 lstrcpyA(val, path);
7266 lstrcatA(val, "\\winetest.msi");
7267 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7268 (const BYTE *)val, lstrlenA(val) + 1);
7269 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7271 /* LocalPackage value exists */
7272 hprod = 0xdeadbeef;
7273 r = MsiOpenProductA(prodcode, &hprod);
7274 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7275 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
7277 size = MAX_PATH;
7278 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
7279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7280 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
7281 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
7283 MsiCloseHandle(hprod);
7285 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7286 (const BYTE *)"winetest.msi", 13);
7287 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7289 /* LocalPackage has just the package name */
7290 hprod = 0xdeadbeef;
7291 r = MsiOpenProductA(prodcode, &hprod);
7292 ok(r == ERROR_INSTALL_PACKAGE_OPEN_FAILED,
7293 "Expected ERROR_INSTALL_PACKAGE_OPEN_FAILED, got %d\n", r);
7294 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7296 lstrcpyA(val, path);
7297 lstrcatA(val, "\\winetest.msi");
7298 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7299 (const BYTE *)val, lstrlenA(val) + 1);
7300 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7302 DeleteFileA(msifile);
7304 /* local package does not exist */
7305 hprod = 0xdeadbeef;
7306 r = MsiOpenProductA(prodcode, &hprod);
7307 ok(r == ERROR_UNKNOWN_PRODUCT,
7308 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7309 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
7311 RegDeleteValueA(props, "LocalPackage");
7312 RegDeleteKeyA(props, "");
7313 RegCloseKey(props);
7314 RegDeleteKeyA(userkey, "");
7315 RegCloseKey(userkey);
7316 RegDeleteKeyA(prodkey, "");
7317 RegCloseKey(prodkey);
7319 DeleteFileA(msifile);
7322 START_TEST(msi)
7324 init_functionpointers();
7326 test_usefeature();
7327 test_null();
7328 test_getcomponentpath();
7329 test_MsiGetFileHash();
7331 if (!pConvertSidToStringSidA)
7332 skip("ConvertSidToStringSidA not implemented\n");
7333 else
7335 /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
7336 test_MsiQueryProductState();
7337 test_MsiQueryFeatureState();
7338 test_MsiQueryComponentState();
7339 test_MsiGetComponentPath();
7340 test_MsiGetProductCode();
7341 test_MsiEnumClients();
7342 test_MsiGetProductInfo();
7343 test_MsiGetProductInfoEx();
7344 test_MsiGetUserInfo();
7345 test_MsiOpenProduct();
7348 test_MsiGetFileVersion();