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
29 #include "wine/test.h"
31 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
33 static INSTALLSTATE (WINAPI *pMsiGetComponentPathA)
34 (LPCSTR, LPCSTR, LPSTR, DWORD*);
35 static UINT (WINAPI *pMsiGetFileHashA)
36 (LPCSTR, DWORD, PMSIFILEHASHINFO);
37 static UINT (WINAPI *pMsiOpenPackageExA)
38 (LPCSTR, DWORD, MSIHANDLE*);
39 static UINT (WINAPI *pMsiOpenPackageExW)
40 (LPCWSTR, DWORD, MSIHANDLE*);
41 static UINT (WINAPI *pMsiQueryComponentStateA)
42 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
43 static INSTALLSTATE (WINAPI *pMsiUseFeatureExA)
44 (LPCSTR, LPCSTR ,DWORD, DWORD );
46 static void init_functionpointers(void)
48 HMODULE hmsi = GetModuleHandleA("msi.dll");
49 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
51 #define GET_PROC(dll, func) \
52 p ## func = (void *)GetProcAddress(dll, #func); \
54 trace("GetProcAddress(%s) failed\n", #func);
56 GET_PROC(hmsi, MsiGetComponentPathA)
57 GET_PROC(hmsi, MsiGetFileHashA)
58 GET_PROC(hmsi, MsiOpenPackageExA)
59 GET_PROC(hmsi, MsiOpenPackageExW)
60 GET_PROC(hmsi, MsiQueryComponentStateA)
61 GET_PROC(hmsi, MsiUseFeatureExA)
63 GET_PROC(hadvapi32, ConvertSidToStringSidA)
68 static void test_usefeature(void)
72 if (!pMsiUseFeatureExA)
74 skip("MsiUseFeatureExA not implemented\n");
78 r = MsiQueryFeatureState(NULL,NULL);
79 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
81 r = MsiQueryFeatureState("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL);
82 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
84 r = pMsiUseFeatureExA(NULL,NULL,0,0);
85 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
87 r = pMsiUseFeatureExA(NULL, "WORDVIEWFiles", -2, 1 );
88 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
90 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
92 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
94 r = pMsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
95 "WORDVIEWFiles", -2, 0 );
96 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
98 r = pMsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
99 "WORDVIEWFiles", -2, 0 );
100 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
102 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
103 "WORDVIEWFiles", -2, 1 );
104 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
107 static void test_null(void)
112 DWORD dwType, cbData;
113 LPBYTE lpData = NULL;
116 r = pMsiOpenPackageExW(NULL, 0, &hpkg);
117 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
119 state = MsiQueryProductStateW(NULL);
120 ok( state == INSTALLSTATE_INVALIDARG, "wrong return\n");
122 r = MsiEnumFeaturesW(NULL,0,NULL,NULL);
123 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
125 r = MsiConfigureFeatureW(NULL, NULL, 0);
126 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
128 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", NULL, 0);
129 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
131 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", "foo", 0);
132 ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
134 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", "foo", INSTALLSTATE_DEFAULT);
135 ok( r == ERROR_UNKNOWN_PRODUCT, "wrong error %d\n", r);
137 /* make sure empty string to MsiGetProductInfo is not a handle to default registry value, saving and restoring the
138 * necessary registry values */
140 /* empty product string */
141 r = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", &hkey);
142 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
144 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
145 ok ( r == ERROR_SUCCESS || r == ERROR_FILE_NOT_FOUND, "wrong error %d\n", r);
146 if ( r == ERROR_SUCCESS )
148 lpData = HeapAlloc(GetProcessHeap(), 0, cbData);
150 skip("Out of memory\n");
153 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
154 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
158 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
159 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
161 r = MsiGetProductInfoA("", "", NULL, NULL);
162 ok ( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
166 r = RegSetValueExA(hkey, NULL, 0, dwType, lpData, cbData);
167 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
169 HeapFree(GetProcessHeap(), 0, lpData);
173 r = RegDeleteValueA(hkey, NULL);
174 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
177 r = RegCloseKey(hkey);
178 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
180 /* empty attribute */
181 r = RegCreateKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", &hkey);
182 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
184 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
185 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
187 r = MsiGetProductInfoA("{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", "", NULL, NULL);
188 ok ( r == ERROR_UNKNOWN_PROPERTY, "wrong error %d\n", r);
190 r = RegCloseKey(hkey);
191 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
193 r = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}");
194 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
197 static void test_getcomponentpath(void)
203 if(!pMsiGetComponentPathA)
206 r = pMsiGetComponentPathA( NULL, NULL, NULL, NULL );
207 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
209 r = pMsiGetComponentPathA( "bogus", "bogus", NULL, NULL );
210 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
212 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL, NULL );
213 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
217 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer, &sz );
218 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
220 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}",
221 "{00000000-0000-0000-0000-000000000000}", buffer, &sz );
222 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
224 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
225 "{00000000-0000-0000-0000-00000000}", buffer, &sz );
226 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
228 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
229 "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer, &sz );
230 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
232 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}",
233 "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer, &sz );
234 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
237 static void create_file(LPCSTR name, LPCSTR data, DWORD size)
242 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
243 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
244 WriteFile(file, data, strlen(data), &written, NULL);
248 SetFilePointer(file, size, NULL, FILE_BEGIN);
255 #define HASHSIZE sizeof(MSIFILEHASHINFO)
261 MSIFILEHASHINFO hash;
266 { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 },
270 { "C:\\Program Files\\msitest\\caesar\n", 0,
272 { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 },
276 { "C:\\Program Files\\msitest\\caesar\n", 500,
278 { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 },
283 static void test_MsiGetFileHash(void)
285 const char name[] = "msitest.bin";
287 MSIFILEHASHINFO hash;
290 if (!pMsiGetFileHashA)
292 skip("MsiGetFileHash not implemented\n");
296 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
298 /* szFilePath is NULL */
299 r = pMsiGetFileHashA(NULL, 0, &hash);
300 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
302 /* szFilePath is empty */
303 r = pMsiGetFileHashA("", 0, &hash);
304 ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %d\n", r);
306 /* szFilePath is nonexistent */
307 r = pMsiGetFileHashA(name, 0, &hash);
308 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
310 /* dwOptions is non-zero */
311 r = pMsiGetFileHashA(name, 1, &hash);
312 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
314 /* pHash.dwFileHashInfoSize is not correct */
315 hash.dwFileHashInfoSize = 0;
316 r = pMsiGetFileHashA(name, 0, &hash);
317 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
320 r = pMsiGetFileHashA(name, 0, NULL);
321 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
323 for (i = 0; i < sizeof(hash_data) / sizeof(hash_data[0]); i++)
325 create_file(name, hash_data[i].data, hash_data[i].size);
327 memset(&hash, 0, sizeof(MSIFILEHASHINFO));
328 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
330 r = pMsiGetFileHashA(name, 0, &hash);
331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
332 ok(!memcmp(&hash, &hash_data[i].hash, HASHSIZE), "Hash incorrect\n");
338 /* copied from dlls/msi/registry.c */
339 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
344 if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
358 out[17+i*2] = in[n++];
359 out[16+i*2] = in[n++];
364 out[17+i*2] = in[n++];
365 out[16+i*2] = in[n++];
371 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
373 WCHAR guidW[MAX_PATH];
374 WCHAR squashedW[MAX_PATH];
379 hr = CoCreateGuid(&guid);
380 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
382 size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
383 ok(size == 39, "Expected 39, got %d\n", hr);
385 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
386 squash_guid(guidW, squashedW);
387 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
390 static void get_user_sid(LPSTR *usersid)
397 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
399 GetTokenInformation(token, TokenUser, (void *)buf, size, &size);
400 user = (PTOKEN_USER)buf;
401 pConvertSidToStringSidA(user->User.Sid, usersid);
404 static void test_MsiQueryProductState(void)
406 CHAR prodcode[MAX_PATH];
407 CHAR prod_squashed[MAX_PATH];
408 CHAR keypath[MAX_PATH*2];
412 HKEY userkey, localkey, props;
415 create_test_guid(prodcode, prod_squashed);
416 get_user_sid(&usersid);
419 state = MsiQueryProductStateA(NULL);
420 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
423 state = MsiQueryProductStateA("");
424 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
426 /* garbage prodcode */
427 state = MsiQueryProductStateA("garbage");
428 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
430 /* guid without brackets */
431 state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
432 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
434 /* guid with brackets */
435 state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
436 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
438 /* same length as guid, but random */
439 state = MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
440 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
442 /* created guid cannot possibly be an installed product code */
443 state = MsiQueryProductStateA(prodcode);
444 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
446 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
447 lstrcatA(keypath, prod_squashed);
449 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
450 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
452 /* user product key exists */
453 state = MsiQueryProductStateA(prodcode);
454 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
456 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
457 lstrcatA(keypath, prodcode);
459 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
460 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
462 /* local uninstall key exists */
463 state = MsiQueryProductStateA(prodcode);
464 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
467 res = RegSetValueExA(localkey, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
468 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
470 /* WindowsInstaller value exists */
471 state = MsiQueryProductStateA(prodcode);
472 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
474 RegDeleteValueA(localkey, "WindowsInstaller");
475 RegDeleteKeyA(localkey, "");
477 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
478 lstrcatA(keypath, usersid);
479 lstrcatA(keypath, "\\Products\\");
480 lstrcatA(keypath, prod_squashed);
482 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
483 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
485 /* local product key exists */
486 state = MsiQueryProductStateA(prodcode);
487 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
489 res = RegCreateKeyA(localkey, "InstallProperties", &props);
490 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
492 /* install properties key exists */
493 state = MsiQueryProductStateA(prodcode);
494 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
497 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
498 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
500 /* WindowsInstaller value exists */
501 state = MsiQueryProductStateA(prodcode);
502 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
505 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
506 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
508 /* WindowsInstaller value is not 1 */
509 state = MsiQueryProductStateA(prodcode);
510 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
512 RegDeleteKeyA(userkey, "");
514 /* user product key does not exist */
515 state = MsiQueryProductStateA(prodcode);
516 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
519 RegDeleteValueA(props, "WindowsInstaller");
520 RegDeleteKeyA(props, "");
521 RegDeleteKeyA(localkey, "");
522 RegCloseKey(userkey);
523 RegCloseKey(localkey);
527 static const char table_enc85[] =
528 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
529 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
533 * Encodes a base85 guid given a GUID pointer
534 * Caller should provide a 21 character buffer for the encoded string.
536 * returns TRUE if successful, FALSE if not
538 static BOOL encode_base85_guid( GUID *guid, LPWSTR str )
540 unsigned int x, *p, i;
542 p = (unsigned int*) guid;
546 *str++ = table_enc85[x%85];
548 *str++ = table_enc85[x%85];
550 *str++ = table_enc85[x%85];
552 *str++ = table_enc85[x%85];
554 *str++ = table_enc85[x%85];
561 static void compose_base85_guid(LPSTR component, LPSTR comp_base85, LPSTR squashed)
563 WCHAR guidW[MAX_PATH];
564 WCHAR base85W[MAX_PATH];
565 WCHAR squashedW[MAX_PATH];
570 hr = CoCreateGuid(&guid);
571 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
573 size = StringFromGUID2(&guid, (LPOLESTR)guidW, MAX_PATH);
574 ok(size == 39, "Expected 39, got %d\n", hr);
576 WideCharToMultiByte(CP_ACP, 0, guidW, size, component, MAX_PATH, NULL, NULL);
577 encode_base85_guid(&guid, base85W);
578 WideCharToMultiByte(CP_ACP, 0, base85W, -1, comp_base85, MAX_PATH, NULL, NULL);
579 squash_guid(guidW, squashedW);
580 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
583 static void test_MsiQueryFeatureState(void)
585 HKEY userkey, localkey, compkey;
586 CHAR prodcode[MAX_PATH];
587 CHAR prod_squashed[MAX_PATH];
588 CHAR component[MAX_PATH];
589 CHAR comp_base85[MAX_PATH];
590 CHAR comp_squashed[MAX_PATH];
591 CHAR keypath[MAX_PATH*2];
596 create_test_guid(prodcode, prod_squashed);
597 compose_base85_guid(component, comp_base85, comp_squashed);
598 get_user_sid(&usersid);
601 state = MsiQueryFeatureStateA(NULL, "feature");
602 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
605 state = MsiQueryFeatureStateA("", "feature");
606 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
608 /* garbage prodcode */
609 state = MsiQueryFeatureStateA("garbage", "feature");
610 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
612 /* guid without brackets */
613 state = MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
614 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
616 /* guid with brackets */
617 state = MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
618 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
620 /* same length as guid, but random */
621 state = MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
622 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
625 state = MsiQueryFeatureStateA(prodcode, NULL);
626 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
628 /* empty szFeature */
629 state = MsiQueryFeatureStateA(prodcode, "");
630 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
632 /* feature key does not exist yet */
633 state = MsiQueryFeatureStateA(prodcode, "feature");
634 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
636 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Features\\");
637 lstrcatA(keypath, prod_squashed);
639 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
640 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
642 /* feature key exists */
643 state = MsiQueryFeatureStateA(prodcode, "feature");
644 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
646 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 8);
647 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
649 state = MsiQueryFeatureStateA(prodcode, "feature");
650 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
652 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
653 lstrcatA(keypath, usersid);
654 lstrcatA(keypath, "\\Products\\");
655 lstrcatA(keypath, prod_squashed);
656 lstrcatA(keypath, "\\Features");
658 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
659 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
661 state = MsiQueryFeatureStateA(prodcode, "feature");
662 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
664 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
665 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
667 state = MsiQueryFeatureStateA(prodcode, "feature");
668 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
670 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
671 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
673 state = MsiQueryFeatureStateA(prodcode, "feature");
674 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
676 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
677 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
679 state = MsiQueryFeatureStateA(prodcode, "feature");
680 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
682 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 21);
683 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
685 state = MsiQueryFeatureStateA(prodcode, "feature");
686 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
688 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
689 lstrcatA(keypath, usersid);
690 lstrcatA(keypath, "\\Components\\");
691 lstrcatA(keypath, comp_squashed);
693 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
694 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
696 state = MsiQueryFeatureStateA(prodcode, "feature");
697 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
699 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
700 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
702 state = MsiQueryFeatureStateA(prodcode, "feature");
703 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
705 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 1);
706 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
708 state = MsiQueryFeatureStateA(prodcode, "feature");
709 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
711 RegDeleteValueA(compkey, prod_squashed);
712 RegDeleteValueA(compkey, "");
713 RegDeleteValueA(localkey, "feature");
714 RegDeleteValueA(userkey, "feature");
715 RegDeleteKeyA(userkey, "");
716 RegCloseKey(compkey);
717 RegCloseKey(localkey);
718 RegCloseKey(userkey);
721 static void test_MsiQueryComponentState(void)
723 HKEY compkey, prodkey;
724 CHAR prodcode[MAX_PATH];
725 CHAR prod_squashed[MAX_PATH];
726 CHAR component[MAX_PATH];
727 CHAR comp_base85[MAX_PATH];
728 CHAR comp_squashed[MAX_PATH];
729 CHAR keypath[MAX_PATH];
735 static const INSTALLSTATE MAGIC_ERROR = 0xdeadbeef;
737 if (!pMsiQueryComponentStateA)
739 skip("MsiQueryComponentStateA not implemented\n");
743 create_test_guid(prodcode, prod_squashed);
744 compose_base85_guid(component, comp_base85, comp_squashed);
745 get_user_sid(&usersid);
747 /* NULL szProductCode */
749 r = pMsiQueryComponentStateA(NULL, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
750 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
751 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
753 /* empty szProductCode */
755 r = pMsiQueryComponentStateA("", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
756 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
757 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
759 /* random szProductCode */
761 r = pMsiQueryComponentStateA("random", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
762 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
763 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
765 /* GUID-length szProductCode */
767 r = pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
768 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
769 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
771 /* GUID-length with brackets */
773 r = pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
774 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
775 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
779 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
780 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
781 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
784 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
785 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
786 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
788 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
789 lstrcatA(keypath, prod_squashed);
791 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
792 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
795 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
796 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
797 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
799 RegDeleteKeyA(prodkey, "");
800 RegCloseKey(prodkey);
802 /* create local system product key */
803 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
804 lstrcatA(keypath, prod_squashed);
805 lstrcatA(keypath, "\\InstallProperties");
807 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
808 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
810 /* local system product key exists */
812 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
813 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
814 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
816 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
817 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
819 /* LocalPackage value exists */
821 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
822 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
823 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
825 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
826 lstrcatA(keypath, comp_squashed);
828 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
829 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
831 /* component key exists */
833 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
834 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
835 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
837 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
838 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
840 /* component\product exists */
842 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
843 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
844 ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
846 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
847 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
850 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
851 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
852 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
854 RegDeleteValueA(prodkey, "LocalPackage");
855 RegDeleteKeyA(prodkey, "");
856 RegDeleteValueA(compkey, prod_squashed);
857 RegDeleteKeyA(prodkey, "");
858 RegCloseKey(prodkey);
859 RegCloseKey(compkey);
861 /* MSIINSTALLCONTEXT_USERUNMANAGED */
864 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
865 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
866 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
868 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
869 lstrcatA(keypath, prod_squashed);
871 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
872 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
875 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
876 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
877 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
879 RegDeleteKeyA(prodkey, "");
880 RegCloseKey(prodkey);
882 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
883 lstrcatA(keypath, usersid);
884 lstrcatA(keypath, "\\Products\\");
885 lstrcatA(keypath, prod_squashed);
886 lstrcatA(keypath, "\\InstallProperties");
888 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
889 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
891 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
892 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
894 RegCloseKey(prodkey);
897 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
898 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
899 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
901 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
902 lstrcatA(keypath, usersid);
903 lstrcatA(keypath, "\\Components\\");
904 lstrcatA(keypath, comp_squashed);
906 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
907 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
909 /* component key exists */
911 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
912 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
913 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
915 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
916 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
918 /* component\product exists */
920 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
921 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
922 ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state);
924 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
925 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
928 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
930 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
932 /* MSIINSTALLCONTEXT_USERMANAGED */
935 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
936 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
937 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
939 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
940 lstrcatA(keypath, prod_squashed);
942 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
943 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
946 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
947 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
948 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
950 RegDeleteKeyA(prodkey, "");
951 RegCloseKey(prodkey);
953 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
954 lstrcatA(keypath, usersid);
955 lstrcatA(keypath, "\\Installer\\Products\\");
956 lstrcatA(keypath, prod_squashed);
958 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
959 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
962 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
963 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
964 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
966 RegDeleteKeyA(prodkey, "");
967 RegCloseKey(prodkey);
969 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
970 lstrcatA(keypath, usersid);
971 lstrcatA(keypath, "\\Products\\");
972 lstrcatA(keypath, prod_squashed);
973 lstrcatA(keypath, "\\InstallProperties");
975 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
976 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
978 res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
979 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
982 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
983 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
984 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
986 RegDeleteValueA(prodkey, "LocalPackage");
987 RegDeleteValueA(prodkey, "ManagedLocalPackage");
988 RegDeleteKeyA(prodkey, "");
989 RegDeleteValueA(compkey, prod_squashed);
990 RegDeleteKeyA(compkey, "");
991 RegCloseKey(prodkey);
992 RegCloseKey(compkey);
995 static void test_MsiGetComponentPath(void)
997 HKEY compkey, prodkey, installprop;
998 CHAR prodcode[MAX_PATH];
999 CHAR prod_squashed[MAX_PATH];
1000 CHAR component[MAX_PATH];
1001 CHAR comp_base85[MAX_PATH];
1002 CHAR comp_squashed[MAX_PATH];
1003 CHAR keypath[MAX_PATH];
1004 CHAR path[MAX_PATH];
1010 create_test_guid(prodcode, prod_squashed);
1011 compose_base85_guid(component, comp_base85, comp_squashed);
1012 get_user_sid(&usersid);
1014 /* NULL szProduct */
1016 state = MsiGetComponentPathA(NULL, component, path, &size);
1017 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1018 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1020 /* NULL szComponent */
1022 state = MsiGetComponentPathA(prodcode, NULL, path, &size);
1023 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1024 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1026 /* NULL lpPathBuf */
1028 state = MsiGetComponentPathA(prodcode, component, NULL, &size);
1029 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1030 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1034 state = MsiGetComponentPathA(prodcode, component, path, NULL);
1035 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1036 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1038 /* all params valid */
1040 state = MsiGetComponentPathA(prodcode, component, path, &size);
1041 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1042 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1044 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1045 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1046 lstrcatA(keypath, comp_squashed);
1048 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1049 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1051 /* local system component key exists */
1053 state = MsiGetComponentPathA(prodcode, component, path, &size);
1054 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1055 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1057 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1058 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1060 /* product value exists */
1062 state = MsiGetComponentPathA(prodcode, component, path, &size);
1063 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1064 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1065 ok(size == 10, "Expected 10, got %d\n", size);
1067 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1068 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1069 lstrcatA(keypath, prod_squashed);
1070 lstrcatA(keypath, "\\InstallProperties");
1072 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1073 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1076 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1077 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1079 /* install properties key exists */
1081 state = MsiGetComponentPathA(prodcode, component, path, &size);
1082 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1083 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1084 ok(size == 10, "Expected 10, got %d\n", size);
1086 create_file("C:\\imapath", "C:\\imapath", 11);
1090 state = MsiGetComponentPathA(prodcode, component, path, &size);
1091 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1092 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1093 ok(size == 10, "Expected 10, got %d\n", size);
1095 RegDeleteValueA(compkey, prod_squashed);
1096 RegDeleteKeyA(compkey, "");
1097 RegDeleteValueA(installprop, "WindowsInstaller");
1098 RegDeleteKeyA(installprop, "");
1099 RegCloseKey(compkey);
1100 RegCloseKey(installprop);
1101 DeleteFileA("C:\\imapath");
1103 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1104 lstrcatA(keypath, "Installer\\UserData\\");
1105 lstrcatA(keypath, usersid);
1106 lstrcatA(keypath, "\\Components\\");
1107 lstrcatA(keypath, comp_squashed);
1109 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1110 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1112 /* user managed component key exists */
1114 state = MsiGetComponentPathA(prodcode, component, path, &size);
1115 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1116 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1118 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1119 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1121 /* product value exists */
1123 state = MsiGetComponentPathA(prodcode, component, path, &size);
1124 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1125 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1126 ok(size == 10, "Expected 10, got %d\n", size);
1128 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1129 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1130 lstrcatA(keypath, prod_squashed);
1131 lstrcatA(keypath, "\\InstallProperties");
1133 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1134 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1137 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1138 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1140 /* install properties key exists */
1142 state = MsiGetComponentPathA(prodcode, component, path, &size);
1143 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1144 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1145 ok(size == 10, "Expected 10, got %d\n", size);
1147 create_file("C:\\imapath", "C:\\imapath", 11);
1151 state = MsiGetComponentPathA(prodcode, component, path, &size);
1152 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1153 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1154 ok(size == 10, "Expected 10, got %d\n", size);
1156 RegDeleteValueA(compkey, prod_squashed);
1157 RegDeleteKeyA(compkey, "");
1158 RegDeleteValueA(installprop, "WindowsInstaller");
1159 RegDeleteKeyA(installprop, "");
1160 RegCloseKey(compkey);
1161 RegCloseKey(installprop);
1162 DeleteFileA("C:\\imapath");
1164 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1165 lstrcatA(keypath, "Installer\\Managed\\");
1166 lstrcatA(keypath, usersid);
1167 lstrcatA(keypath, "\\Installer\\Products\\");
1168 lstrcatA(keypath, prod_squashed);
1170 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1171 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1173 /* user managed product key exists */
1175 state = MsiGetComponentPathA(prodcode, component, path, &size);
1176 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1177 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1179 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1180 lstrcatA(keypath, "Installer\\UserData\\");
1181 lstrcatA(keypath, usersid);
1182 lstrcatA(keypath, "\\Components\\");
1183 lstrcatA(keypath, comp_squashed);
1185 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1186 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1188 /* user managed component key exists */
1190 state = MsiGetComponentPathA(prodcode, component, path, &size);
1191 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1192 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1194 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1195 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1197 /* product value exists */
1199 state = MsiGetComponentPathA(prodcode, component, path, &size);
1200 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1201 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1202 ok(size == 10, "Expected 10, got %d\n", size);
1204 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1205 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
1206 lstrcatA(keypath, prod_squashed);
1207 lstrcatA(keypath, "\\InstallProperties");
1209 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &installprop);
1210 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1213 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
1214 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1216 /* install properties key exists */
1218 state = MsiGetComponentPathA(prodcode, component, path, &size);
1219 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1220 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1221 ok(size == 10, "Expected 10, got %d\n", size);
1223 create_file("C:\\imapath", "C:\\imapath", 11);
1227 state = MsiGetComponentPathA(prodcode, component, path, &size);
1228 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1229 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1230 ok(size == 10, "Expected 10, got %d\n", size);
1232 RegDeleteValueA(compkey, prod_squashed);
1233 RegDeleteKeyA(prodkey, "");
1234 RegDeleteKeyA(compkey, "");
1235 RegDeleteValueA(installprop, "WindowsInstaller");
1236 RegDeleteKeyA(installprop, "");
1237 RegCloseKey(prodkey);
1238 RegCloseKey(compkey);
1239 RegCloseKey(installprop);
1240 DeleteFileA("C:\\imapath");
1242 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1243 lstrcatA(keypath, prod_squashed);
1245 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1246 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1248 /* user unmanaged product key exists */
1250 state = MsiGetComponentPathA(prodcode, component, path, &size);
1251 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1252 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1254 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1255 lstrcatA(keypath, "Installer\\UserData\\");
1256 lstrcatA(keypath, usersid);
1257 lstrcatA(keypath, "\\Components\\");
1258 lstrcatA(keypath, comp_squashed);
1260 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1261 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1263 /* user unmanaged component key exists */
1265 state = MsiGetComponentPathA(prodcode, component, path, &size);
1266 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1267 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1269 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1270 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1272 /* product value exists */
1274 state = MsiGetComponentPathA(prodcode, component, path, &size);
1275 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1276 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1277 ok(size == 10, "Expected 10, got %d\n", size);
1279 create_file("C:\\imapath", "C:\\imapath", 11);
1283 state = MsiGetComponentPathA(prodcode, component, path, &size);
1284 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1285 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1286 ok(size == 10, "Expected 10, got %d\n", size);
1288 RegDeleteValueA(compkey, prod_squashed);
1289 RegDeleteKeyA(prodkey, "");
1290 RegDeleteKeyA(compkey, "");
1291 RegCloseKey(prodkey);
1292 RegCloseKey(compkey);
1293 RegCloseKey(installprop);
1294 DeleteFileA("C:\\imapath");
1296 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1297 lstrcatA(keypath, prod_squashed);
1299 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1300 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1302 /* local classes product key exists */
1304 state = MsiGetComponentPathA(prodcode, component, path, &size);
1305 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1306 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1308 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1309 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1310 lstrcatA(keypath, comp_squashed);
1312 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1313 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1315 /* local user component key exists */
1317 state = MsiGetComponentPathA(prodcode, component, path, &size);
1318 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1319 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
1321 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1322 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1324 /* product value exists */
1326 state = MsiGetComponentPathA(prodcode, component, path, &size);
1327 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1328 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1329 ok(size == 10, "Expected 10, got %d\n", size);
1331 create_file("C:\\imapath", "C:\\imapath", 11);
1335 state = MsiGetComponentPathA(prodcode, component, path, &size);
1336 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1337 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
1338 ok(size == 10, "Expected 10, got %d\n", size);
1340 RegDeleteValueA(compkey, prod_squashed);
1341 RegDeleteKeyA(prodkey, "");
1342 RegDeleteKeyA(compkey, "");
1343 RegCloseKey(prodkey);
1344 RegCloseKey(compkey);
1345 DeleteFileA("C:\\imapath");
1348 static void test_MsiGetProductCode(void)
1350 HKEY compkey, prodkey;
1351 CHAR prodcode[MAX_PATH];
1352 CHAR prod_squashed[MAX_PATH];
1353 CHAR prodcode2[MAX_PATH];
1354 CHAR prod2_squashed[MAX_PATH];
1355 CHAR component[MAX_PATH];
1356 CHAR comp_base85[MAX_PATH];
1357 CHAR comp_squashed[MAX_PATH];
1358 CHAR keypath[MAX_PATH];
1359 CHAR product[MAX_PATH];
1364 create_test_guid(prodcode, prod_squashed);
1365 create_test_guid(prodcode2, prod2_squashed);
1366 compose_base85_guid(component, comp_base85, comp_squashed);
1367 get_user_sid(&usersid);
1369 /* szComponent is NULL */
1370 lstrcpyA(product, "prod");
1371 r = MsiGetProductCodeA(NULL, product);
1372 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1373 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1375 /* szComponent is empty */
1376 lstrcpyA(product, "prod");
1377 r = MsiGetProductCodeA("", product);
1378 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1379 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1381 /* garbage szComponent */
1382 lstrcpyA(product, "prod");
1383 r = MsiGetProductCodeA("garbage", product);
1384 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1385 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1387 /* guid without brackets */
1388 lstrcpyA(product, "prod");
1389 r = MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product);
1390 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1391 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1393 /* guid with brackets */
1394 lstrcpyA(product, "prod");
1395 r = MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product);
1396 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1397 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1399 /* same length as guid, but random */
1400 lstrcpyA(product, "prod");
1401 r = MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product);
1402 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1403 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1405 /* all params correct, szComponent not published */
1406 lstrcpyA(product, "prod");
1407 r = MsiGetProductCodeA(component, product);
1408 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1409 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1411 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1412 lstrcatA(keypath, "Installer\\UserData\\");
1413 lstrcatA(keypath, usersid);
1414 lstrcatA(keypath, "\\Components\\");
1415 lstrcatA(keypath, comp_squashed);
1417 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1418 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1420 /* user unmanaged component key exists */
1421 lstrcpyA(product, "prod");
1422 r = MsiGetProductCodeA(component, product);
1423 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1424 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1426 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1427 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1429 /* product value exists */
1430 lstrcpyA(product, "prod");
1431 r = MsiGetProductCodeA(component, product);
1432 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1433 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1435 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1436 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1438 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1439 lstrcatA(keypath, "Installer\\Managed\\");
1440 lstrcatA(keypath, usersid);
1441 lstrcatA(keypath, "\\Installer\\Products\\");
1442 lstrcatA(keypath, prod_squashed);
1444 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1445 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1447 /* user managed product key of first product exists */
1448 lstrcpyA(product, "prod");
1449 r = MsiGetProductCodeA(component, product);
1450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1451 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1453 RegDeleteKeyA(prodkey, "");
1454 RegCloseKey(prodkey);
1456 RegDeleteKeyA(prodkey, "");
1457 RegCloseKey(prodkey);
1459 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1460 lstrcatA(keypath, prod_squashed);
1462 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1463 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1465 /* user unmanaged product key exists */
1466 lstrcpyA(product, "prod");
1467 r = MsiGetProductCodeA(component, product);
1468 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1469 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1471 RegDeleteKeyA(prodkey, "");
1472 RegCloseKey(prodkey);
1474 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1475 lstrcatA(keypath, prod_squashed);
1477 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1478 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1480 /* local classes product key exists */
1481 lstrcpyA(product, "prod");
1482 r = MsiGetProductCodeA(component, product);
1483 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1484 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1486 RegDeleteKeyA(prodkey, "");
1487 RegCloseKey(prodkey);
1489 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1490 lstrcatA(keypath, "Installer\\Managed\\");
1491 lstrcatA(keypath, usersid);
1492 lstrcatA(keypath, "\\Installer\\Products\\");
1493 lstrcatA(keypath, prod2_squashed);
1495 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1496 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1498 /* user managed product key of second product exists */
1499 lstrcpyA(product, "prod");
1500 r = MsiGetProductCodeA(component, product);
1501 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1502 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
1504 RegDeleteKeyA(prodkey, "");
1505 RegCloseKey(prodkey);
1506 RegDeleteValueA(compkey, prod_squashed);
1507 RegDeleteValueA(compkey, prod2_squashed);
1508 RegDeleteKeyA(compkey, "");
1509 RegCloseKey(compkey);
1511 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1512 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1513 lstrcatA(keypath, comp_squashed);
1515 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1516 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1518 /* local user component key exists */
1519 lstrcpyA(product, "prod");
1520 r = MsiGetProductCodeA(component, product);
1521 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1522 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
1524 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1525 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1527 /* product value exists */
1528 lstrcpyA(product, "prod");
1529 r = MsiGetProductCodeA(component, product);
1530 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1531 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1533 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1534 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1536 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1537 lstrcatA(keypath, "Installer\\Managed\\");
1538 lstrcatA(keypath, usersid);
1539 lstrcatA(keypath, "\\Installer\\Products\\");
1540 lstrcatA(keypath, prod_squashed);
1542 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1543 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1545 /* user managed product key of first product exists */
1546 lstrcpyA(product, "prod");
1547 r = MsiGetProductCodeA(component, product);
1548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1549 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1551 RegDeleteKeyA(prodkey, "");
1552 RegCloseKey(prodkey);
1554 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1555 lstrcatA(keypath, prod_squashed);
1557 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
1558 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1560 /* user unmanaged product key exists */
1561 lstrcpyA(product, "prod");
1562 r = MsiGetProductCodeA(component, product);
1563 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1564 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1566 RegDeleteKeyA(prodkey, "");
1567 RegCloseKey(prodkey);
1569 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1570 lstrcatA(keypath, prod_squashed);
1572 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1573 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1575 /* local classes product key exists */
1576 lstrcpyA(product, "prod");
1577 r = MsiGetProductCodeA(component, product);
1578 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1579 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1581 RegDeleteKeyA(prodkey, "");
1582 RegCloseKey(prodkey);
1584 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1585 lstrcatA(keypath, "Installer\\Managed\\");
1586 lstrcatA(keypath, usersid);
1587 lstrcatA(keypath, "\\Installer\\Products\\");
1588 lstrcatA(keypath, prod2_squashed);
1590 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
1591 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1593 /* user managed product key of second product exists */
1594 lstrcpyA(product, "prod");
1595 r = MsiGetProductCodeA(component, product);
1596 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1597 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
1599 RegDeleteKeyA(prodkey, "");
1600 RegCloseKey(prodkey);
1601 RegDeleteValueA(compkey, prod_squashed);
1602 RegDeleteValueA(compkey, prod2_squashed);
1603 RegDeleteKeyA(compkey, "");
1604 RegCloseKey(compkey);
1607 static void test_MsiEnumClients(void)
1610 CHAR prodcode[MAX_PATH];
1611 CHAR prod_squashed[MAX_PATH];
1612 CHAR prodcode2[MAX_PATH];
1613 CHAR prod2_squashed[MAX_PATH];
1614 CHAR component[MAX_PATH];
1615 CHAR comp_base85[MAX_PATH];
1616 CHAR comp_squashed[MAX_PATH];
1617 CHAR product[MAX_PATH];
1618 CHAR keypath[MAX_PATH];
1623 create_test_guid(prodcode, prod_squashed);
1624 create_test_guid(prodcode2, prod2_squashed);
1625 compose_base85_guid(component, comp_base85, comp_squashed);
1626 get_user_sid(&usersid);
1628 /* NULL szComponent */
1630 r = MsiEnumClientsA(NULL, 0, product);
1631 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1632 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1634 /* empty szComponent */
1636 r = MsiEnumClientsA("", 0, product);
1637 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1638 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1640 /* NULL lpProductBuf */
1641 r = MsiEnumClientsA(component, 0, NULL);
1642 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1644 /* all params correct, component missing */
1646 r = MsiEnumClientsA(component, 0, product);
1647 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1648 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1650 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1651 lstrcatA(keypath, "Installer\\UserData\\");
1652 lstrcatA(keypath, usersid);
1653 lstrcatA(keypath, "\\Components\\");
1654 lstrcatA(keypath, comp_squashed);
1656 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1657 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1659 /* user unmanaged component key exists */
1661 r = MsiEnumClientsA(component, 0, product);
1662 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1663 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1665 /* index > 0, no products exist */
1667 r = MsiEnumClientsA(component, 1, product);
1668 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1669 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1671 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1672 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1674 /* product value exists */
1675 r = MsiEnumClientsA(component, 0, product);
1676 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1677 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1679 /* try index 0 again */
1681 r = MsiEnumClientsA(component, 0, product);
1682 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1683 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1685 /* try index 1, second product value does not exist */
1687 r = MsiEnumClientsA(component, 1, product);
1688 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1689 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1691 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1692 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1694 /* try index 1, second product value does exist */
1696 r = MsiEnumClientsA(component, 1, product);
1699 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1700 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1703 /* start the enumeration over */
1705 r = MsiEnumClientsA(component, 0, product);
1706 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1707 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
1708 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
1710 /* correctly query second product */
1712 r = MsiEnumClientsA(component, 1, product);
1713 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1714 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
1715 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
1717 RegDeleteValueA(compkey, prod_squashed);
1718 RegDeleteValueA(compkey, prod2_squashed);
1719 RegDeleteKeyA(compkey, "");
1720 RegCloseKey(compkey);
1722 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
1723 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
1724 lstrcatA(keypath, comp_squashed);
1726 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &compkey);
1727 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1729 /* user local component key exists */
1731 r = MsiEnumClientsA(component, 0, product);
1732 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1733 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1735 /* index > 0, no products exist */
1737 r = MsiEnumClientsA(component, 1, product);
1738 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1739 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1741 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
1742 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1744 /* product value exists */
1746 r = MsiEnumClientsA(component, 0, product);
1747 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1748 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
1750 /* try index 0 again */
1752 r = MsiEnumClientsA(component, 0, product);
1753 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1755 /* try index 1, second product value does not exist */
1757 r = MsiEnumClientsA(component, 1, product);
1758 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
1759 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1761 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
1762 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1764 /* try index 1, second product value does exist */
1766 r = MsiEnumClientsA(component, 1, product);
1769 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1770 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
1773 /* start the enumeration over */
1775 r = MsiEnumClientsA(component, 0, product);
1776 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1777 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
1778 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
1780 /* correctly query second product */
1782 r = MsiEnumClientsA(component, 1, product);
1783 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1784 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
1785 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
1787 RegDeleteValueA(compkey, prod_squashed);
1788 RegDeleteValueA(compkey, prod2_squashed);
1789 RegDeleteKeyA(compkey, "");
1790 RegCloseKey(compkey);
1793 static void get_version_info(LPSTR path, LPSTR *vercheck, LPDWORD verchecksz,
1794 LPSTR *langcheck, LPDWORD langchecksz)
1797 VS_FIXEDFILEINFO *ffi;
1798 DWORD size = GetFileVersionInfoSizeA(path, NULL);
1801 version = HeapAlloc(GetProcessHeap(), 0, size);
1802 GetFileVersionInfoA(path, 0, size, version);
1804 VerQueryValueA(version, "\\", (LPVOID *)&ffi, &size);
1805 *vercheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
1806 sprintf(*vercheck, "%d.%d.%d.%d", HIWORD(ffi->dwFileVersionMS),
1807 LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionLS),
1808 LOWORD(ffi->dwFileVersionLS));
1809 *verchecksz = lstrlenA(*vercheck);
1811 VerQueryValue(version, "\\VarFileInfo\\Translation", (void **)&lang, &size);
1812 *langcheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
1813 sprintf(*langcheck, "%d", *lang);
1814 *langchecksz = lstrlenA(*langcheck);
1816 HeapFree(GetProcessHeap(), 0, version);
1819 static void test_MsiGetFileVersion(void)
1822 DWORD versz, langsz;
1823 char version[MAX_PATH];
1824 char lang[MAX_PATH];
1825 char path[MAX_PATH];
1826 LPSTR vercheck, langcheck;
1827 DWORD verchecksz, langchecksz;
1829 /* NULL szFilePath */
1832 lstrcpyA(version, "version");
1833 lstrcpyA(lang, "lang");
1834 r = MsiGetFileVersionA(NULL, version, &versz, lang, &langsz);
1835 ok(r == ERROR_INVALID_PARAMETER,
1836 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1837 ok(!lstrcmpA(version, "version"),
1838 "Expected version to be unchanged, got %s\n", version);
1839 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1840 ok(!lstrcmpA(lang, "lang"),
1841 "Expected lang to be unchanged, got %s\n", lang);
1842 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1844 /* empty szFilePath */
1847 lstrcpyA(version, "version");
1848 lstrcpyA(lang, "lang");
1849 r = MsiGetFileVersionA("", version, &versz, lang, &langsz);
1850 ok(r == ERROR_FILE_NOT_FOUND,
1851 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1852 ok(!lstrcmpA(version, "version"),
1853 "Expected version to be unchanged, got %s\n", version);
1854 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1855 ok(!lstrcmpA(lang, "lang"),
1856 "Expected lang to be unchanged, got %s\n", lang);
1857 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1859 /* nonexistent szFilePath */
1862 lstrcpyA(version, "version");
1863 lstrcpyA(lang, "lang");
1864 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
1865 ok(r == ERROR_FILE_NOT_FOUND,
1866 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1867 ok(!lstrcmpA(version, "version"),
1868 "Expected version to be unchanged, got %s\n", version);
1869 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1870 ok(!lstrcmpA(lang, "lang"),
1871 "Expected lang to be unchanged, got %s\n", lang);
1872 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1874 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
1877 lstrcpyA(version, "version");
1878 lstrcpyA(lang, "lang");
1879 r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz);
1880 ok(r == ERROR_INVALID_PARAMETER,
1881 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1882 ok(!lstrcmpA(version, "version"),
1883 "Expected version to be unchanged, got %s\n", version);
1884 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1885 ok(!lstrcmpA(lang, "lang"),
1886 "Expected lang to be unchanged, got %s\n", lang);
1887 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1889 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
1892 lstrcpyA(version, "version");
1893 lstrcpyA(lang, "lang");
1894 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL);
1895 ok(r == ERROR_INVALID_PARAMETER,
1896 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1897 ok(!lstrcmpA(version, "version"),
1898 "Expected version to be unchanged, got %s\n", version);
1899 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1900 ok(!lstrcmpA(lang, "lang"),
1901 "Expected lang to be unchanged, got %s\n", lang);
1902 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1904 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
1907 lstrcpyA(version, "version");
1908 lstrcpyA(lang, "lang");
1909 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
1910 ok(r == ERROR_FILE_NOT_FOUND,
1911 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1912 ok(!lstrcmpA(version, "version"),
1913 "Expected version to be unchanged, got %s\n", version);
1914 ok(versz == 0, "Expected 0, got %d\n", versz);
1915 ok(!lstrcmpA(lang, "lang"),
1916 "Expected lang to be unchanged, got %s\n", lang);
1917 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1919 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
1922 lstrcpyA(version, "version");
1923 lstrcpyA(lang, "lang");
1924 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
1925 ok(r == ERROR_FILE_NOT_FOUND,
1926 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1927 ok(!lstrcmpA(version, "version"),
1928 "Expected version to be unchanged, got %s\n", version);
1929 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1930 ok(!lstrcmpA(lang, "lang"),
1931 "Expected lang to be unchanged, got %s\n", lang);
1932 ok(langsz == 0, "Expected 0, got %d\n", langsz);
1934 /* nonexistent szFilePath, rest NULL */
1935 r = MsiGetFileVersionA("nonexistent", NULL, NULL, NULL, NULL);
1936 ok(r == ERROR_FILE_NOT_FOUND,
1937 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1939 create_file("ver.txt", "ver.txt", 20);
1941 /* file exists, no version information */
1944 lstrcpyA(version, "version");
1945 lstrcpyA(lang, "lang");
1946 r = MsiGetFileVersionA("ver.txt", version, &versz, lang, &langsz);
1947 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1948 ok(!lstrcmpA(version, "version"),
1949 "Expected version to be unchanged, got %s\n", version);
1950 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1951 ok(!lstrcmpA(lang, "lang"),
1952 "Expected lang to be unchanged, got %s\n", lang);
1953 ok(r == ERROR_FILE_INVALID,
1954 "Expected ERROR_FILE_INVALID, got %d\n", r);
1956 DeleteFileA("ver.txt");
1958 /* relative path, has version information */
1961 lstrcpyA(version, "version");
1962 lstrcpyA(lang, "lang");
1963 r = MsiGetFileVersionA("kernel32.dll", version, &versz, lang, &langsz);
1966 ok(r == ERROR_FILE_NOT_FOUND,
1967 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1968 ok(!lstrcmpA(version, "version"),
1969 "Expected version to be unchanged, got %s\n", version);
1970 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
1971 ok(!lstrcmpA(lang, "lang"),
1972 "Expected lang to be unchanged, got %s\n", lang);
1973 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
1976 GetSystemDirectoryA(path, MAX_PATH);
1977 lstrcatA(path, "\\kernel32.dll");
1979 get_version_info(path, &vercheck, &verchecksz, &langcheck, &langchecksz);
1981 /* absolute path, has version information */
1984 lstrcpyA(version, "version");
1985 lstrcpyA(lang, "lang");
1986 r = MsiGetFileVersionA(path, version, &versz, lang, &langsz);
1987 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1988 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
1989 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
1990 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
1991 ok(!lstrcmpA(version, vercheck),
1992 "Expected %s, got %s\n", vercheck, version);
1994 /* only check version */
1996 lstrcpyA(version, "version");
1997 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
1998 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1999 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2000 ok(!lstrcmpA(version, vercheck),
2001 "Expected %s, got %s\n", vercheck, version);
2003 /* only check language */
2005 lstrcpyA(lang, "lang");
2006 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2007 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2008 ok(!lstrcmpA(lang, langcheck), "Expected %s, got %s\n", langcheck, lang);
2009 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2011 /* get pcchVersionBuf */
2013 r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL);
2014 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2015 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2017 /* get pcchLangBuf */
2019 r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
2020 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2021 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2023 /* pcchVersionBuf not big enough */
2025 lstrcpyA(version, "version");
2026 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
2027 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2028 ok(!strncmp(version, vercheck, 4),
2029 "Expected first 4 characters of %s, got %s\n", vercheck, version);
2030 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
2032 /* pcchLangBuf not big enough */
2034 lstrcpyA(lang, "lang");
2035 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
2036 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2037 ok(!strncmp(lang, langcheck, 2),
2038 "Expected first character of %s, got %s\n", langcheck, lang);
2039 ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
2041 HeapFree(GetProcessHeap(), 0, vercheck);
2042 HeapFree(GetProcessHeap(), 0, langcheck);
2045 static void test_MsiGetProductInfo(void)
2049 HKEY propkey, source;
2050 HKEY prodkey, localkey;
2051 CHAR prodcode[MAX_PATH];
2052 CHAR prod_squashed[MAX_PATH];
2053 CHAR packcode[MAX_PATH];
2054 CHAR pack_squashed[MAX_PATH];
2056 CHAR keypath[MAX_PATH];
2060 create_test_guid(prodcode, prod_squashed);
2061 create_test_guid(packcode, pack_squashed);
2062 get_user_sid(&usersid);
2064 /* NULL szProduct */
2066 lstrcpyA(buf, "apple");
2067 r = MsiGetProductInfoA(NULL, INSTALLPROPERTY_HELPLINK, buf, &sz);
2068 ok(r == ERROR_INVALID_PARAMETER,
2069 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2070 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2071 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2073 /* empty szProduct */
2075 lstrcpyA(buf, "apple");
2076 r = MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINK, buf, &sz);
2077 ok(r == ERROR_INVALID_PARAMETER,
2078 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2079 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2080 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2082 /* garbage szProduct */
2084 lstrcpyA(buf, "apple");
2085 r = MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINK, buf, &sz);
2086 ok(r == ERROR_INVALID_PARAMETER,
2087 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2088 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2089 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2091 /* guid without brackets */
2093 lstrcpyA(buf, "apple");
2094 r = MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
2095 INSTALLPROPERTY_HELPLINK, buf, &sz);
2096 ok(r == ERROR_INVALID_PARAMETER,
2097 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2098 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2099 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2101 /* guid with brackets */
2103 lstrcpyA(buf, "apple");
2104 r = MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
2105 INSTALLPROPERTY_HELPLINK, buf, &sz);
2106 ok(r == ERROR_UNKNOWN_PRODUCT,
2107 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2108 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2109 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2111 /* same length as guid, but random */
2113 lstrcpyA(buf, "apple");
2114 r = MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
2115 INSTALLPROPERTY_HELPLINK, buf, &sz);
2116 ok(r == ERROR_INVALID_PARAMETER,
2117 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2118 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2119 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2121 /* not installed, NULL szAttribute */
2123 lstrcpyA(buf, "apple");
2124 r = MsiGetProductInfoA(prodcode, NULL, buf, &sz);
2125 ok(r == ERROR_INVALID_PARAMETER,
2126 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2127 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2128 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2130 /* not installed, NULL lpValueBuf */
2132 lstrcpyA(buf, "apple");
2133 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2134 ok(r == ERROR_UNKNOWN_PRODUCT,
2135 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2136 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2137 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2139 /* not installed, NULL pcchValueBuf */
2141 lstrcpyA(buf, "apple");
2142 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, NULL);
2143 ok(r == ERROR_INVALID_PARAMETER,
2144 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2145 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2146 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2148 /* created guid cannot possibly be an installed product code */
2150 lstrcpyA(buf, "apple");
2151 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2152 ok(r == ERROR_UNKNOWN_PRODUCT,
2153 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2154 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2155 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2157 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2158 lstrcatA(keypath, usersid);
2159 lstrcatA(keypath, "\\Installer\\Products\\");
2160 lstrcatA(keypath, prod_squashed);
2162 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2163 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2165 /* managed product code exists */
2167 lstrcpyA(buf, "apple");
2168 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2169 ok(r == ERROR_UNKNOWN_PROPERTY,
2170 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2171 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2172 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2174 RegDeleteKeyA(prodkey, "");
2175 RegCloseKey(prodkey);
2177 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2178 lstrcatA(keypath, usersid);
2179 lstrcatA(keypath, "\\Products\\");
2180 lstrcatA(keypath, prod_squashed);
2182 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2183 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2185 /* local user product code exists */
2187 lstrcpyA(buf, "apple");
2188 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2189 ok(r == ERROR_UNKNOWN_PRODUCT,
2190 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2191 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2192 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2194 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2195 lstrcatA(keypath, usersid);
2196 lstrcatA(keypath, "\\Installer\\Products\\");
2197 lstrcatA(keypath, prod_squashed);
2199 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2200 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2202 /* both local and managed product code exist */
2204 lstrcpyA(buf, "apple");
2205 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2206 ok(r == ERROR_UNKNOWN_PROPERTY,
2207 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2208 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
2209 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2211 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2212 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2214 /* InstallProperties key exists */
2216 lstrcpyA(buf, "apple");
2217 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2219 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2220 ok(sz == 0, "Expected 0, got %d\n", sz);
2222 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2223 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2225 /* HelpLink value exists */
2227 lstrcpyA(buf, "apple");
2228 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2230 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2231 ok(sz == 4, "Expected 4, got %d\n", sz);
2233 /* lpValueBuf is NULL */
2235 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2237 ok(sz == 4, "Expected 4, got %d\n", sz);
2239 /* lpValueBuf is NULL, pcchValueBuf is too small */
2241 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, NULL, &sz);
2242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2243 ok(sz == 4, "Expected 4, got %d\n", sz);
2245 /* lpValueBuf is NULL, pcchValueBuf is too small */
2247 lstrcpyA(buf, "apple");
2248 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2249 ok(!lstrcmpA(buf, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf);
2250 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2251 ok(sz == 4, "Expected 4, got %d\n", sz);
2253 /* lpValueBuf is NULL, pcchValueBuf is exactly 4 */
2255 lstrcpyA(buf, "apple");
2256 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2257 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
2258 ok(!lstrcmpA(buf, "apple"),
2259 "Expected buf to remain unchanged, got \"%s\"\n", buf);
2260 ok(sz == 4, "Expected 4, got %d\n", sz);
2262 res = RegSetValueExA(propkey, "IMadeThis", 0, REG_SZ, (LPBYTE)"random", 7);
2263 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2265 /* random property not supported by MSI, value exists */
2267 lstrcpyA(buf, "apple");
2268 r = MsiGetProductInfoA(prodcode, "IMadeThis", buf, &sz);
2269 ok(r == ERROR_UNKNOWN_PROPERTY,
2270 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2271 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2272 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2274 RegDeleteValueA(propkey, "IMadeThis");
2275 RegDeleteValueA(propkey, "HelpLink");
2276 RegDeleteKeyA(propkey, "");
2277 RegDeleteKeyA(localkey, "");
2278 RegDeleteKeyA(prodkey, "");
2279 RegCloseKey(propkey);
2280 RegCloseKey(localkey);
2281 RegCloseKey(prodkey);
2283 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2284 lstrcatA(keypath, prod_squashed);
2286 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2287 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2289 /* user product key exists */
2291 lstrcpyA(buf, "apple");
2292 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2293 ok(r == ERROR_UNKNOWN_PROPERTY,
2294 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2295 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2296 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2298 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2299 lstrcatA(keypath, usersid);
2300 lstrcatA(keypath, "\\Products\\");
2301 lstrcatA(keypath, prod_squashed);
2303 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2304 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2306 /* local user product key exists */
2308 lstrcpyA(buf, "apple");
2309 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2310 ok(r == ERROR_UNKNOWN_PROPERTY,
2311 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2312 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2313 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2315 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2316 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2318 /* InstallProperties key exists */
2320 lstrcpyA(buf, "apple");
2321 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2322 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2323 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2324 ok(sz == 0, "Expected 0, got %d\n", sz);
2326 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2327 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2329 /* HelpLink value exists */
2331 lstrcpyA(buf, "apple");
2332 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2334 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2335 ok(sz == 4, "Expected 4, got %d\n", sz);
2337 RegDeleteValueA(propkey, "HelpLink");
2338 RegDeleteKeyA(propkey, "");
2339 RegDeleteKeyA(localkey, "");
2340 RegDeleteKeyA(prodkey, "");
2341 RegCloseKey(propkey);
2342 RegCloseKey(localkey);
2343 RegCloseKey(prodkey);
2345 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2346 lstrcatA(keypath, prod_squashed);
2348 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &prodkey);
2349 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2351 /* classes product key exists */
2353 lstrcpyA(buf, "apple");
2354 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2355 ok(r == ERROR_UNKNOWN_PROPERTY,
2356 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2357 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2358 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2360 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2361 lstrcatA(keypath, usersid);
2362 lstrcatA(keypath, "\\Products\\");
2363 lstrcatA(keypath, prod_squashed);
2365 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2366 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2368 /* local user product key exists */
2370 lstrcpyA(buf, "apple");
2371 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2372 ok(r == ERROR_UNKNOWN_PROPERTY,
2373 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2374 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2375 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2377 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2378 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2380 /* InstallProperties key exists */
2382 lstrcpyA(buf, "apple");
2383 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2384 ok(r == ERROR_UNKNOWN_PROPERTY,
2385 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2386 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2387 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2389 RegDeleteKeyA(propkey, "");
2390 RegDeleteKeyA(localkey, "");
2391 RegCloseKey(propkey);
2392 RegCloseKey(localkey);
2394 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2395 lstrcatA(keypath, "S-1-5-18\\\\Products\\");
2396 lstrcatA(keypath, prod_squashed);
2398 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, keypath, &localkey);
2399 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2401 /* Local System product key exists */
2403 lstrcpyA(buf, "apple");
2404 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2405 ok(r == ERROR_UNKNOWN_PROPERTY,
2406 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
2407 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
2408 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2410 res = RegCreateKeyA(localkey, "InstallProperties", &propkey);
2411 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2413 /* InstallProperties key exists */
2415 lstrcpyA(buf, "apple");
2416 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2417 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2418 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2419 ok(sz == 0, "Expected 0, got %d\n", sz);
2421 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
2422 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2424 /* HelpLink value exists */
2426 lstrcpyA(buf, "apple");
2427 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINK, buf, &sz);
2428 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2429 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
2430 ok(sz == 4, "Expected 4, got %d\n", sz);
2432 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
2433 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2435 /* DisplayName value exists */
2437 lstrcpyA(buf, "apple");
2438 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAME, buf, &sz);
2439 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2440 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
2441 ok(sz == 4, "Expected 4, got %d\n", sz);
2443 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"1.1.1", 6);
2444 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2446 /* DisplayVersion value exists */
2448 lstrcpyA(buf, "apple");
2449 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRING, buf, &sz);
2450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2451 ok(!lstrcmpA(buf, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf);
2452 ok(sz == 5, "Expected 5, got %d\n", sz);
2454 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"tele", 5);
2455 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2457 /* HelpTelephone value exists */
2459 lstrcpyA(buf, "apple");
2460 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONE, buf, &sz);
2461 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2462 ok(!lstrcmpA(buf, "tele"), "Expected \"tele\", got \"%s\"\n", buf);
2463 ok(sz == 4, "Expected 4, got %d\n", sz);
2465 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
2466 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2468 /* InstallLocation value exists */
2470 lstrcpyA(buf, "apple");
2471 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATION, buf, &sz);
2472 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2473 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
2474 ok(sz == 3, "Expected 3, got %d\n", sz);
2476 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
2477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2479 /* InstallSource value exists */
2481 lstrcpyA(buf, "apple");
2482 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCE, buf, &sz);
2483 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2484 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
2485 ok(sz == 6, "Expected 6, got %d\n", sz);
2487 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
2488 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2490 /* InstallDate value exists */
2492 lstrcpyA(buf, "apple");
2493 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATE, buf, &sz);
2494 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2495 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
2496 ok(sz == 4, "Expected 4, got %d\n", sz);
2498 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
2499 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2501 /* Publisher value exists */
2503 lstrcpyA(buf, "apple");
2504 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHER, buf, &sz);
2505 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2506 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
2507 ok(sz == 3, "Expected 3, got %d\n", sz);
2509 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"pack", 5);
2510 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2512 /* LocalPackage value exists */
2514 lstrcpyA(buf, "apple");
2515 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGE, buf, &sz);
2516 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2517 ok(!lstrcmpA(buf, "pack"), "Expected \"pack\", got \"%s\"\n", buf);
2518 ok(sz == 4, "Expected 4, got %d\n", sz);
2520 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
2521 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2523 /* UrlInfoAbout value exists */
2525 lstrcpyA(buf, "apple");
2526 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUT, buf, &sz);
2527 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2528 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
2529 ok(sz == 5, "Expected 5, got %d\n", sz);
2531 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_SZ, (LPBYTE)"info", 5);
2532 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2534 /* UrlUpdateInfo value exists */
2536 lstrcpyA(buf, "apple");
2537 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFO, buf, &sz);
2538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2539 ok(!lstrcmpA(buf, "info"), "Expected \"info\", got \"%s\"\n", buf);
2540 ok(sz == 4, "Expected 4, got %d\n", sz);
2542 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"1", 2);
2543 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2545 /* VersionMinor value exists */
2547 lstrcpyA(buf, "apple");
2548 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINOR, buf, &sz);
2549 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2550 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
2551 ok(sz == 1, "Expected 1, got %d\n", sz);
2553 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"1", 2);
2554 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2556 /* VersionMajor value exists */
2558 lstrcpyA(buf, "apple");
2559 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJOR, buf, &sz);
2560 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2561 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
2562 ok(sz == 1, "Expected 1, got %d\n", sz);
2564 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
2565 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2567 /* ProductID value exists */
2569 lstrcpyA(buf, "apple");
2570 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTID, buf, &sz);
2571 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2572 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
2573 ok(sz == 2, "Expected 2, got %d\n", sz);
2575 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
2576 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2578 /* RegCompany value exists */
2580 lstrcpyA(buf, "apple");
2581 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANY, buf, &sz);
2582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2583 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
2584 ok(sz == 4, "Expected 4, got %d\n", sz);
2586 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"own", 4);
2587 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2589 /* RegOwner value exists */
2591 lstrcpyA(buf, "apple");
2592 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNER, buf, &sz);
2593 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2594 ok(!lstrcmpA(buf, "own"), "Expected \"own\", got \"%s\"\n", buf);
2595 ok(sz == 3, "Expected 3, got %d\n", sz);
2597 res = RegSetValueExA(propkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
2598 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2600 /* InstanceType value exists */
2602 lstrcpyA(buf, "apple");
2603 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
2604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2605 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2606 ok(sz == 0, "Expected 0, got %d\n", sz);
2608 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
2609 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2611 /* InstanceType value exists */
2613 lstrcpyA(buf, "apple");
2614 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPE, buf, &sz);
2615 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2616 ok(!lstrcmpA(buf, "type"), "Expected \"type\", got \"%s\"\n", buf);
2617 ok(sz == 4, "Expected 4, got %d\n", sz);
2619 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
2620 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2622 /* Transforms value exists */
2624 lstrcpyA(buf, "apple");
2625 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
2626 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2627 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2628 ok(sz == 0, "Expected 0, got %d\n", sz);
2630 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
2631 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2633 /* Transforms value exists */
2635 lstrcpyA(buf, "apple");
2636 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMS, buf, &sz);
2637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2638 ok(!lstrcmpA(buf, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf);
2639 ok(sz == 6, "Expected 6, got %d\n", sz);
2641 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
2642 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2644 /* Language value exists */
2646 lstrcpyA(buf, "apple");
2647 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
2648 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2649 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2650 ok(sz == 0, "Expected 0, got %d\n", sz);
2652 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
2653 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2655 /* Language value exists */
2657 lstrcpyA(buf, "apple");
2658 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGE, buf, &sz);
2659 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2660 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
2661 ok(sz == 4, "Expected 4, got %d\n", sz);
2663 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
2664 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2666 /* ProductName value exists */
2668 lstrcpyA(buf, "apple");
2669 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
2670 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2671 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2672 ok(sz == 0, "Expected 0, got %d\n", sz);
2674 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
2675 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2677 /* ProductName value exists */
2679 lstrcpyA(buf, "apple");
2680 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAME, buf, &sz);
2681 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2682 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
2683 ok(sz == 4, "Expected 4, got %d\n", sz);
2685 res = RegSetValueExA(propkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
2686 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2688 /* AssignmentType value exists */
2690 lstrcpyA(buf, "apple");
2691 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
2692 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2693 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2694 ok(sz == 0, "Expected 0, got %d\n", sz);
2696 res = RegSetValueExA(prodkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
2697 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2699 /* AssignmentType value exists */
2701 lstrcpyA(buf, "apple");
2702 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPE, buf, &sz);
2703 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2704 ok(!lstrcmpA(buf, "at"), "Expected \"at\", got \"%s\"\n", buf);
2705 ok(sz == 2, "Expected 2, got %d\n", sz);
2707 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
2708 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2710 /* PackageCode value exists */
2712 lstrcpyA(buf, "apple");
2713 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
2714 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2715 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2716 ok(sz == 0, "Expected 0, got %d\n", sz);
2718 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
2719 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2721 /* PackageCode value exists */
2723 lstrcpyA(buf, "apple");
2724 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
2725 ok(r == ERROR_BAD_CONFIGURATION,
2726 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
2727 ok(!lstrcmpA(buf, "code"), "Expected \"code\", got \"%s\"\n", buf);
2728 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
2730 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)pack_squashed, 33);
2731 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2733 /* PackageCode value exists */
2735 lstrcpyA(buf, "apple");
2736 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODE, buf, &sz);
2737 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2738 ok(!lstrcmpA(buf, packcode), "Expected \"%s\", got \"%s\"\n", packcode, buf);
2739 ok(sz == 38, "Expected 38, got %d\n", sz);
2741 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
2742 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2744 /* Version value exists */
2746 lstrcpyA(buf, "apple");
2747 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
2748 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2749 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2750 ok(sz == 0, "Expected 0, got %d\n", sz);
2752 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
2753 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2755 /* Version value exists */
2757 lstrcpyA(buf, "apple");
2758 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSION, buf, &sz);
2759 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2760 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
2761 ok(sz == 3, "Expected 3, got %d\n", sz);
2763 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
2764 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2766 /* ProductIcon value exists */
2768 lstrcpyA(buf, "apple");
2769 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
2770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2771 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2772 ok(sz == 0, "Expected 0, got %d\n", sz);
2774 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
2775 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2777 /* ProductIcon value exists */
2779 lstrcpyA(buf, "apple");
2780 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICON, buf, &sz);
2781 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2782 ok(!lstrcmpA(buf, "ico"), "Expected \"ico\", got \"%s\"\n", buf);
2783 ok(sz == 3, "Expected 3, got %d\n", sz);
2785 res = RegCreateKeyA(prodkey, "SourceList", &source);
2786 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2788 res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
2789 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2792 lstrcpyA(buf, "apple");
2793 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
2794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2795 ok(!lstrcmpA(buf, "packname"), "Expected \"packname\", got \"%s\"\n", buf);
2796 ok(sz == 8, "Expected 8, got %d\n", sz);
2798 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
2799 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2801 /* Authorized value exists */
2803 lstrcpyA(buf, "apple");
2804 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
2805 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2806 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
2807 ok(sz == 0, "Expected 0, got %d\n", sz);
2809 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
2810 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2812 /* Authorized value exists */
2814 lstrcpyA(buf, "apple");
2815 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APP, buf, &sz);
2816 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2817 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
2818 ok(sz == 4, "Expected 4, got %d\n", sz);
2820 RegDeleteValueA(propkey, "HelpLink");
2821 RegDeleteValueA(propkey, "DisplayName");
2822 RegDeleteValueA(propkey, "DisplayVersion");
2823 RegDeleteValueA(propkey, "HelpTelephone");
2824 RegDeleteValueA(propkey, "InstallLocation");
2825 RegDeleteValueA(propkey, "InstallSource");
2826 RegDeleteValueA(propkey, "InstallDate");
2827 RegDeleteValueA(propkey, "Publisher");
2828 RegDeleteValueA(propkey, "LocalPackage");
2829 RegDeleteValueA(propkey, "UrlInfoAbout");
2830 RegDeleteValueA(propkey, "UrlUpdateInfo");
2831 RegDeleteValueA(propkey, "VersionMinor");
2832 RegDeleteValueA(propkey, "VersionMajor");
2833 RegDeleteValueA(propkey, "ProductID");
2834 RegDeleteValueA(propkey, "RegCompany");
2835 RegDeleteValueA(propkey, "RegOwner");
2836 RegDeleteValueA(propkey, "InstanceType");
2837 RegDeleteValueA(propkey, "Transforms");
2838 RegDeleteValueA(propkey, "Language");
2839 RegDeleteValueA(propkey, "ProductName");
2840 RegDeleteValueA(propkey, "Assignment");
2841 RegDeleteValueA(propkey, "PackageCode");
2842 RegDeleteValueA(propkey, "Version");
2843 RegDeleteValueA(propkey, "ProductIcon");
2844 RegDeleteValueA(propkey, "AuthorizedLUAApp");
2845 RegDeleteKeyA(propkey, "");
2846 RegDeleteKeyA(localkey, "");
2847 RegDeleteValueA(prodkey, "InstanceType");
2848 RegDeleteValueA(prodkey, "Transforms");
2849 RegDeleteValueA(prodkey, "Language");
2850 RegDeleteValueA(prodkey, "ProductName");
2851 RegDeleteValueA(prodkey, "Assignment");
2852 RegDeleteValueA(prodkey, "PackageCode");
2853 RegDeleteValueA(prodkey, "Version");
2854 RegDeleteValueA(prodkey, "ProductIcon");
2855 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
2856 RegDeleteValueA(source, "PackageName");
2857 RegDeleteKeyA(source, "");
2858 RegDeleteKeyA(prodkey, "");
2859 RegCloseKey(propkey);
2860 RegCloseKey(localkey);
2861 RegCloseKey(source);
2862 RegCloseKey(prodkey);
2867 init_functionpointers();
2871 test_getcomponentpath();
2872 test_MsiGetFileHash();
2874 if (!pConvertSidToStringSidA)
2875 skip("ConvertSidToStringSidA not implemented\n");
2878 /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
2879 test_MsiQueryProductState();
2880 test_MsiQueryFeatureState();
2881 test_MsiQueryComponentState();
2882 test_MsiGetComponentPath();
2883 test_MsiGetProductCode();
2884 test_MsiEnumClients();
2885 test_MsiGetProductInfo();
2888 test_MsiGetFileVersion();