2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include <srrestoreptapi.h>
32 #include "wine/test.h"
35 static const char msifile[] = "winetest-package.msi";
36 static char CURR_DIR[MAX_PATH];
38 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
39 static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
40 static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
42 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
43 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
44 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
45 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
46 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
47 static void (WINAPI *pGetSystemInfo)(LPSYSTEM_INFO);
48 static void (WINAPI *pGetNativeSystemInfo)(LPSYSTEM_INFO);
49 static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR, UINT);
51 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
52 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
54 static void init_functionpointers(void)
56 HMODULE hmsi = GetModuleHandleA("msi.dll");
57 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
58 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
59 HMODULE hshell32 = GetModuleHandleA("shell32.dll");
62 #define GET_PROC(mod, func) \
63 p ## func = (void*)GetProcAddress(mod, #func);
65 GET_PROC(hmsi, MsiApplyMultiplePatchesA);
66 GET_PROC(hmsi, MsiGetComponentPathExA);
67 GET_PROC(hshell32, SHGetFolderPathA);
69 GET_PROC(hadvapi32, ConvertSidToStringSidA);
70 GET_PROC(hadvapi32, OpenProcessToken);
71 GET_PROC(hadvapi32, RegDeleteKeyExA)
72 GET_PROC(hadvapi32, RegDeleteKeyExW)
73 GET_PROC(hkernel32, IsWow64Process)
74 GET_PROC(hkernel32, GetNativeSystemInfo)
75 GET_PROC(hkernel32, GetSystemInfo)
76 GET_PROC(hkernel32, GetSystemWow64DirectoryA)
78 hsrclient = LoadLibraryA("srclient.dll");
79 GET_PROC(hsrclient, SRRemoveRestorePoint);
80 GET_PROC(hsrclient, SRSetRestorePointA);
84 static BOOL is_process_limited(void)
88 if (!pOpenProcessToken) return FALSE;
90 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
93 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
96 ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
98 return (ret && type == TokenElevationTypeLimited);
103 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
105 if (pRegDeleteKeyExA)
106 return pRegDeleteKeyExA( key, subkey, access, 0 );
107 return RegDeleteKeyA( key, subkey );
110 static char *get_user_sid(void)
115 char *usersid = NULL;
117 if (!pConvertSidToStringSidA)
119 win_skip("ConvertSidToStringSidA is not available\n");
122 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
123 GetTokenInformation(token, TokenUser, NULL, size, &size);
125 user = HeapAlloc(GetProcessHeap(), 0, size);
126 GetTokenInformation(token, TokenUser, user, size, &size);
127 pConvertSidToStringSidA(user->User.Sid, &usersid);
128 HeapFree(GetProcessHeap(), 0, user);
134 /* RegDeleteTreeW from dlls/advapi32/registry.c */
135 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
138 DWORD dwMaxSubkeyLen, dwMaxValueLen;
139 DWORD dwMaxLen, dwSize;
140 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
145 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
149 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
150 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
151 if (ret) goto cleanup;
155 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
156 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
158 /* Name too big: alloc a buffer for it */
159 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
161 ret = ERROR_NOT_ENOUGH_MEMORY;
166 /* Recursively delete all the subkeys */
170 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
171 NULL, NULL, NULL)) break;
173 ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
174 if (ret) goto cleanup;
179 if (pRegDeleteKeyExW)
180 ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
182 ret = RegDeleteKeyW(hKey, lpszSubKey);
188 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
189 NULL, NULL, NULL, NULL)) break;
191 ret = RegDeleteValueW(hKey, lpszName);
192 if (ret) goto cleanup;
196 if (lpszName != szNameBuf)
197 HeapFree(GetProcessHeap(), 0, lpszName);
199 RegCloseKey(hSubKey);
203 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
208 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
222 out[17+i*2] = in[n++];
223 out[16+i*2] = in[n++];
228 out[17+i*2] = in[n++];
229 out[16+i*2] = in[n++];
235 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
237 WCHAR guidW[MAX_PATH];
238 WCHAR squashedW[MAX_PATH];
243 hr = CoCreateGuid(&guid);
244 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
246 size = StringFromGUID2(&guid, guidW, MAX_PATH);
247 ok(size == 39, "Expected 39, got %d\n", hr);
249 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
250 squash_guid(guidW, squashedW);
251 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
254 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
255 LPCSTR guid, LPSTR usersid, BOOL dir)
257 WCHAR guidW[MAX_PATH];
258 WCHAR squashedW[MAX_PATH];
259 CHAR squashed[MAX_PATH];
260 CHAR comppath[MAX_PATH];
261 CHAR prodpath[MAX_PATH];
265 REGSAM access = KEY_ALL_ACCESS;
268 access |= KEY_WOW64_64KEY;
270 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
271 squash_guid(guidW, squashedW);
272 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
274 if (context == MSIINSTALLCONTEXT_MACHINE)
276 prod = "3D0DAE300FACA1300AD792060BCDAA92";
278 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
279 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
281 "SOFTWARE\\Classes\\Installer\\"
282 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
284 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
286 prod = "7D2F387510109040002000060BECB6AB";
288 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
289 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
291 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
292 "Installer\\%s\\Installer\\Products\\"
293 "7D2F387510109040002000060BECB6AB", usersid);
295 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
297 prod = "7D2F387510109040002000060BECB6AB";
299 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
300 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
302 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
303 "Installer\\Managed\\%s\\Installer\\Products\\"
304 "7D2F387510109040002000060BECB6AB", usersid);
307 RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
309 lstrcpyA(path, CURR_DIR);
310 lstrcatA(path, "\\");
311 if (!dir) lstrcatA(path, filename);
313 RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
316 RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
320 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
322 WCHAR guidW[MAX_PATH];
323 WCHAR squashedW[MAX_PATH];
324 WCHAR substrW[MAX_PATH];
325 CHAR squashed[MAX_PATH];
326 CHAR comppath[MAX_PATH];
327 CHAR prodpath[MAX_PATH];
328 REGSAM access = KEY_ALL_ACCESS;
331 access |= KEY_WOW64_64KEY;
333 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
334 squash_guid(guidW, squashedW);
335 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
337 if (context == MSIINSTALLCONTEXT_MACHINE)
340 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
341 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
343 "SOFTWARE\\Classes\\Installer\\"
344 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
346 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
349 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
350 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
352 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
353 "Installer\\%s\\Installer\\Products\\"
354 "7D2F387510109040002000060BECB6AB", usersid);
356 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
359 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
360 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
362 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
363 "Installer\\Managed\\%s\\Installer\\Products\\"
364 "7D2F387510109040002000060BECB6AB", usersid);
367 MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
368 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
370 MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
371 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
374 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
379 /* open a select query */
380 r = MsiDatabaseOpenView(hdb, query, &hview);
381 if (r != ERROR_SUCCESS)
383 r = MsiViewExecute(hview, 0);
384 if (r != ERROR_SUCCESS)
386 ret = MsiViewFetch(hview, phrec);
387 r = MsiViewClose(hview);
388 if (r != ERROR_SUCCESS)
390 r = MsiCloseHandle(hview);
391 if (r != ERROR_SUCCESS)
396 static UINT run_query( MSIHANDLE hdb, const char *query )
401 r = MsiDatabaseOpenView(hdb, query, &hview);
402 if( r != ERROR_SUCCESS )
405 r = MsiViewExecute(hview, 0);
406 if( r == ERROR_SUCCESS )
407 r = MsiViewClose(hview);
408 MsiCloseHandle(hview);
412 static UINT create_component_table( MSIHANDLE hdb )
414 return run_query( hdb,
415 "CREATE TABLE `Component` ( "
416 "`Component` CHAR(72) NOT NULL, "
417 "`ComponentId` CHAR(38), "
418 "`Directory_` CHAR(72) NOT NULL, "
419 "`Attributes` SHORT NOT NULL, "
420 "`Condition` CHAR(255), "
421 "`KeyPath` CHAR(72) "
422 "PRIMARY KEY `Component`)" );
425 static UINT create_feature_table( MSIHANDLE hdb )
427 return run_query( hdb,
428 "CREATE TABLE `Feature` ( "
429 "`Feature` CHAR(38) NOT NULL, "
430 "`Feature_Parent` CHAR(38), "
432 "`Description` CHAR(255), "
433 "`Display` SHORT NOT NULL, "
434 "`Level` SHORT NOT NULL, "
435 "`Directory_` CHAR(72), "
436 "`Attributes` SHORT NOT NULL "
437 "PRIMARY KEY `Feature`)" );
440 static UINT create_feature_components_table( MSIHANDLE hdb )
442 return run_query( hdb,
443 "CREATE TABLE `FeatureComponents` ( "
444 "`Feature_` CHAR(38) NOT NULL, "
445 "`Component_` CHAR(72) NOT NULL "
446 "PRIMARY KEY `Feature_`, `Component_` )" );
449 static UINT create_file_table( MSIHANDLE hdb )
451 return run_query( hdb,
452 "CREATE TABLE `File` ("
453 "`File` CHAR(72) NOT NULL, "
454 "`Component_` CHAR(72) NOT NULL, "
455 "`FileName` CHAR(255) NOT NULL, "
456 "`FileSize` LONG NOT NULL, "
457 "`Version` CHAR(72), "
458 "`Language` CHAR(20), "
459 "`Attributes` SHORT, "
460 "`Sequence` SHORT NOT NULL "
461 "PRIMARY KEY `File`)" );
464 static UINT create_remove_file_table( MSIHANDLE hdb )
466 return run_query( hdb,
467 "CREATE TABLE `RemoveFile` ("
468 "`FileKey` CHAR(72) NOT NULL, "
469 "`Component_` CHAR(72) NOT NULL, "
470 "`FileName` CHAR(255) LOCALIZABLE, "
471 "`DirProperty` CHAR(72) NOT NULL, "
472 "`InstallMode` SHORT NOT NULL "
473 "PRIMARY KEY `FileKey`)" );
476 static UINT create_appsearch_table( MSIHANDLE hdb )
478 return run_query( hdb,
479 "CREATE TABLE `AppSearch` ("
480 "`Property` CHAR(72) NOT NULL, "
481 "`Signature_` CHAR(72) NOT NULL "
482 "PRIMARY KEY `Property`, `Signature_`)" );
485 static UINT create_reglocator_table( MSIHANDLE hdb )
487 return run_query( hdb,
488 "CREATE TABLE `RegLocator` ("
489 "`Signature_` CHAR(72) NOT NULL, "
490 "`Root` SHORT NOT NULL, "
491 "`Key` CHAR(255) NOT NULL, "
494 "PRIMARY KEY `Signature_`)" );
497 static UINT create_signature_table( MSIHANDLE hdb )
499 return run_query( hdb,
500 "CREATE TABLE `Signature` ("
501 "`Signature` CHAR(72) NOT NULL, "
502 "`FileName` CHAR(255) NOT NULL, "
503 "`MinVersion` CHAR(20), "
504 "`MaxVersion` CHAR(20), "
509 "`Languages` CHAR(255) "
510 "PRIMARY KEY `Signature`)" );
513 static UINT create_launchcondition_table( MSIHANDLE hdb )
515 return run_query( hdb,
516 "CREATE TABLE `LaunchCondition` ("
517 "`Condition` CHAR(255) NOT NULL, "
518 "`Description` CHAR(255) NOT NULL "
519 "PRIMARY KEY `Condition`)" );
522 static UINT create_property_table( MSIHANDLE hdb )
524 return run_query( hdb,
525 "CREATE TABLE `Property` ("
526 "`Property` CHAR(72) NOT NULL, "
528 "PRIMARY KEY `Property`)" );
531 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
533 return run_query( hdb,
534 "CREATE TABLE `InstallExecuteSequence` ("
535 "`Action` CHAR(72) NOT NULL, "
536 "`Condition` CHAR(255), "
538 "PRIMARY KEY `Action`)" );
541 static UINT create_media_table( MSIHANDLE hdb )
543 return run_query( hdb,
544 "CREATE TABLE `Media` ("
545 "`DiskId` SHORT NOT NULL, "
546 "`LastSequence` SHORT NOT NULL, "
547 "`DiskPrompt` CHAR(64), "
548 "`Cabinet` CHAR(255), "
549 "`VolumeLabel` CHAR(32), "
551 "PRIMARY KEY `DiskId`)" );
554 static UINT create_ccpsearch_table( MSIHANDLE hdb )
556 return run_query( hdb,
557 "CREATE TABLE `CCPSearch` ("
558 "`Signature_` CHAR(72) NOT NULL "
559 "PRIMARY KEY `Signature_`)" );
562 static UINT create_drlocator_table( MSIHANDLE hdb )
564 return run_query( hdb,
565 "CREATE TABLE `DrLocator` ("
566 "`Signature_` CHAR(72) NOT NULL, "
567 "`Parent` CHAR(72), "
570 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
573 static UINT create_complocator_table( MSIHANDLE hdb )
575 return run_query( hdb,
576 "CREATE TABLE `CompLocator` ("
577 "`Signature_` CHAR(72) NOT NULL, "
578 "`ComponentId` CHAR(38) NOT NULL, "
580 "PRIMARY KEY `Signature_`)" );
583 static UINT create_inilocator_table( MSIHANDLE hdb )
585 return run_query( hdb,
586 "CREATE TABLE `IniLocator` ("
587 "`Signature_` CHAR(72) NOT NULL, "
588 "`FileName` CHAR(255) NOT NULL, "
589 "`Section` CHAR(96)NOT NULL, "
590 "`Key` CHAR(128)NOT NULL, "
593 "PRIMARY KEY `Signature_`)" );
596 static UINT create_custom_action_table( MSIHANDLE hdb )
598 return run_query( hdb,
599 "CREATE TABLE `CustomAction` ("
600 "`Action` CHAR(72) NOT NULL, "
601 "`Type` SHORT NOT NULL, "
602 "`Source` CHAR(75), "
603 "`Target` CHAR(255) "
604 "PRIMARY KEY `Action`)" );
607 #define make_add_entry(type, qtext) \
608 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
610 char insert[] = qtext; \
613 sz = strlen(values) + sizeof insert; \
614 query = HeapAlloc(GetProcessHeap(),0,sz); \
615 sprintf(query,insert,values); \
616 r = run_query( hdb, query ); \
617 HeapFree(GetProcessHeap(), 0, query); \
621 make_add_entry(component,
622 "INSERT INTO `Component` "
623 "(`Component`, `ComponentId`, `Directory_`, "
624 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
626 make_add_entry(directory,
627 "INSERT INTO `Directory` "
628 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
630 make_add_entry(feature,
631 "INSERT INTO `Feature` "
632 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
633 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
635 make_add_entry(feature_components,
636 "INSERT INTO `FeatureComponents` "
637 "(`Feature_`, `Component_`) VALUES( %s )")
640 "INSERT INTO `File` "
641 "(`File`, `Component_`, `FileName`, `FileSize`, "
642 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
644 make_add_entry(appsearch,
645 "INSERT INTO `AppSearch` "
646 "(`Property`, `Signature_`) VALUES( %s )")
648 make_add_entry(signature,
649 "INSERT INTO `Signature` "
650 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
651 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
654 make_add_entry(launchcondition,
655 "INSERT INTO `LaunchCondition` "
656 "(`Condition`, `Description`) VALUES( %s )")
658 make_add_entry(property,
659 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
661 make_add_entry(install_execute_sequence,
662 "INSERT INTO `InstallExecuteSequence` "
663 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
665 make_add_entry(media,
666 "INSERT INTO `Media` "
667 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
668 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
670 make_add_entry(ccpsearch,
671 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
673 make_add_entry(drlocator,
674 "INSERT INTO `DrLocator` "
675 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
677 make_add_entry(complocator,
678 "INSERT INTO `CompLocator` "
679 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
681 make_add_entry(inilocator,
682 "INSERT INTO `IniLocator` "
683 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
686 make_add_entry(custom_action,
687 "INSERT INTO `CustomAction` "
688 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
690 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
691 const char *name, UINT type )
693 const char insert[] =
694 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
695 "VALUES( '%s', %u, '%s', '%s', %u )";
699 sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
700 query = HeapAlloc( GetProcessHeap(), 0, sz );
701 sprintf( query, insert, sig, root, path, name, type );
702 r = run_query( hdb, query );
703 HeapFree( GetProcessHeap(), 0, query );
707 static UINT set_summary_info(MSIHANDLE hdb)
712 /* build summary info */
713 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
714 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
716 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
717 "Installation Database");
718 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
720 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
721 "Installation Database");
722 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
724 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
726 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
728 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
730 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
732 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
733 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
734 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
736 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
737 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
739 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
740 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
742 res = MsiSummaryInfoPersist(suminfo);
743 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
745 res = MsiCloseHandle( suminfo);
746 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
752 static MSIHANDLE create_package_db(void)
759 /* create an empty database */
760 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
761 ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
762 if( res != ERROR_SUCCESS )
765 res = MsiDatabaseCommit( hdb );
766 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
768 res = set_summary_info(hdb);
769 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
771 res = run_query( hdb,
772 "CREATE TABLE `Directory` ( "
773 "`Directory` CHAR(255) NOT NULL, "
774 "`Directory_Parent` CHAR(255), "
775 "`DefaultDir` CHAR(255) NOT NULL "
776 "PRIMARY KEY `Directory`)" );
777 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
782 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
788 sprintf(szPackage, "#%u", hdb);
789 res = MsiOpenPackage(szPackage, &hPackage);
790 if (res != ERROR_SUCCESS)
796 res = MsiCloseHandle(hdb);
797 if (res != ERROR_SUCCESS)
799 MsiCloseHandle(hPackage);
804 return ERROR_SUCCESS;
807 static void create_test_file(const CHAR *name)
812 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
813 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
814 WriteFile(file, name, strlen(name), &written, NULL);
815 WriteFile(file, "\n", strlen("\n"), &written, NULL);
819 typedef struct _tagVS_VERSIONINFO
826 VS_FIXEDFILEINFO Value;
831 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
832 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
834 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
836 VS_VERSIONINFO *pVerInfo;
837 VS_FIXEDFILEINFO *pFixedInfo;
844 GetSystemDirectory(path, MAX_PATH);
845 /* Some dlls can't be updated on Vista/W2K8 */
846 lstrcatA(path, "\\version.dll");
848 CopyFileA(path, name, FALSE);
850 size = GetFileVersionInfoSize(path, &handle);
851 buffer = HeapAlloc(GetProcessHeap(), 0, size);
853 GetFileVersionInfoA(path, 0, size, buffer);
855 pVerInfo = (VS_VERSIONINFO *)buffer;
856 ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
857 pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
859 pFixedInfo->dwFileVersionMS = ms;
860 pFixedInfo->dwFileVersionLS = ls;
861 pFixedInfo->dwProductVersionMS = ms;
862 pFixedInfo->dwProductVersionLS = ls;
864 resource = BeginUpdateResource(name, FALSE);
868 if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
869 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
872 if (!EndUpdateResource(resource, FALSE))
878 HeapFree(GetProcessHeap(), 0, buffer);
882 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
884 RESTOREPOINTINFOA spec;
886 spec.dwEventType = event_type;
887 spec.dwRestorePtType = APPLICATION_INSTALL;
888 spec.llSequenceNumber = status->llSequenceNumber;
889 lstrcpyA(spec.szDescription, "msitest restore point");
891 return pSRSetRestorePointA(&spec, status);
894 static void remove_restore_point(DWORD seq_number)
898 res = pSRRemoveRestorePoint(seq_number);
899 if (res != ERROR_SUCCESS)
900 trace("Failed to remove the restore point : %08x\n", res);
903 static void test_createpackage(void)
905 MSIHANDLE hPackage = 0;
908 res = package_from_db(create_package_db(), &hPackage);
909 if (res == ERROR_INSTALL_PACKAGE_REJECTED)
911 skip("Not enough rights to perform tests\n");
915 ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
917 res = MsiCloseHandle( hPackage);
918 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
922 static void test_doaction( void )
927 r = MsiDoAction( -1, NULL );
928 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
930 r = package_from_db(create_package_db(), &hpkg);
931 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
933 skip("Not enough rights to perform tests\n");
937 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
939 r = MsiDoAction(hpkg, NULL);
940 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
942 r = MsiDoAction(0, "boo");
943 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
945 r = MsiDoAction(hpkg, "boo");
946 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
948 MsiCloseHandle( hpkg );
952 static void test_gettargetpath_bad(void)
954 static const WCHAR boo[] = {'b','o','o',0};
955 static const WCHAR empty[] = {0};
962 r = package_from_db(create_package_db(), &hpkg);
963 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
965 skip("Not enough rights to perform tests\n");
969 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
971 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
972 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
974 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
975 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
977 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
978 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
980 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
981 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
983 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
984 ok( r == ERROR_DIRECTORY, "wrong return val\n");
986 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
987 ok( r == ERROR_DIRECTORY, "wrong return val\n");
990 r = MsiGetTargetPath( hpkg, "", buffer, &sz );
991 ok( r == ERROR_DIRECTORY, "wrong return val\n");
993 r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
994 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
996 r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
997 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
999 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1000 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1002 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1003 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1005 r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
1006 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1008 r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
1009 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1012 r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
1013 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1015 MsiCloseHandle( hpkg );
1016 DeleteFile(msifile);
1019 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1025 rec = MsiCreateRecord( 1 );
1026 ok(rec, "MsiCreate record failed\n");
1028 r = MsiRecordSetString( rec, 0, file );
1029 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1032 r = MsiFormatRecord( hpkg, rec, buff, &size );
1033 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1035 MsiCloseHandle( rec );
1038 static void test_settargetpath(void)
1040 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1046 hdb = create_package_db();
1047 ok ( hdb, "failed to create package database\n" );
1049 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1050 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1052 r = create_component_table( hdb );
1053 ok( r == S_OK, "cannot create Component table: %d\n", r );
1055 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1056 ok( r == S_OK, "cannot add dummy component: %d\n", r );
1058 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1059 ok( r == S_OK, "cannot add test component: %d\n", r );
1061 r = create_feature_table( hdb );
1062 ok( r == S_OK, "cannot create Feature table: %d\n", r );
1064 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1065 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1067 r = create_feature_components_table( hdb );
1068 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1070 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1071 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1073 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1074 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1076 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1077 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1079 r = create_file_table( hdb );
1080 ok( r == S_OK, "cannot create File table: %d\n", r );
1082 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1083 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1085 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1086 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1088 r = package_from_db( hdb, &hpkg );
1089 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1091 skip("Not enough rights to perform tests\n");
1092 DeleteFile(msifile);
1095 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1097 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1099 r = MsiDoAction( hpkg, "CostInitialize");
1100 ok( r == ERROR_SUCCESS, "cost init failed\n");
1102 r = MsiDoAction( hpkg, "FileCost");
1103 ok( r == ERROR_SUCCESS, "file cost failed\n");
1105 r = MsiDoAction( hpkg, "CostFinalize");
1106 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1108 r = MsiSetTargetPath( 0, NULL, NULL );
1109 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1111 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1112 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1114 r = MsiSetTargetPath( hpkg, "boo", NULL );
1115 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1117 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1118 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1120 sz = sizeof tempdir - 1;
1121 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1122 sprintf( file, "%srootfile.txt", tempdir );
1124 query_file_path( hpkg, "[#RootFile]", buffer );
1125 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1126 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1128 GetTempFileName( tempdir, "_wt", 0, buffer );
1129 sprintf( tempdir, "%s\\subdir", buffer );
1131 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1132 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1133 "MsiSetTargetPath on file returned %d\n", r );
1135 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1136 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1137 "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1139 DeleteFile( buffer );
1141 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1142 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1144 r = GetFileAttributes( buffer );
1145 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1147 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1148 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1151 sz = sizeof buffer - 1;
1152 lstrcat( tempdir, "\\" );
1153 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1154 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1155 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1157 sprintf( file, "%srootfile.txt", tempdir );
1158 query_file_path( hpkg, "[#RootFile]", buffer );
1159 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1162 sz = sizeof(buffer);
1163 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1164 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1165 lstrcatA( tempdir, "TestParent\\" );
1166 ok( !lstrcmpi(buffer, tempdir), "Expected \"%s\", got \"%s\"\n", tempdir, buffer );
1168 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1169 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1172 sz = sizeof(buffer);
1173 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1174 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1175 ok( lstrcmpi(buffer, "C:\\one\\two\\TestDir\\"),
1176 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer );
1179 query_file_path( hpkg, "[#TestFile]", buffer );
1180 ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1181 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1184 sz = sizeof buffer - 1;
1185 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1186 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1187 ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1189 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1190 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1193 sz = sizeof buffer - 1;
1194 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1195 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1196 ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1198 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\\\one\\\\two " );
1199 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1202 sz = sizeof buffer - 1;
1203 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1204 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1205 ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer);
1207 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\\\ Program Files \\\\ " );
1208 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1211 sz = sizeof buffer - 1;
1212 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1213 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1214 ok( !lstrcmpi(buffer, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer);
1216 MsiCloseHandle( hpkg );
1219 static void test_condition(void)
1221 static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1222 static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1223 static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1224 static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1228 r = package_from_db(create_package_db(), &hpkg);
1229 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1231 skip("Not enough rights to perform tests\n");
1232 DeleteFile(msifile);
1235 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1237 r = MsiEvaluateCondition(0, NULL);
1238 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1240 r = MsiEvaluateCondition(hpkg, NULL);
1241 ok( r == MSICONDITION_NONE, "wrong return val\n");
1243 r = MsiEvaluateCondition(hpkg, "");
1244 ok( r == MSICONDITION_NONE, "wrong return val\n");
1246 r = MsiEvaluateCondition(hpkg, "1");
1247 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1249 r = MsiEvaluateCondition(hpkg, "0");
1250 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1252 r = MsiEvaluateCondition(hpkg, "-1");
1253 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1255 r = MsiEvaluateCondition(hpkg, "0 = 0");
1256 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1258 r = MsiEvaluateCondition(hpkg, "0 <> 0");
1259 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1261 r = MsiEvaluateCondition(hpkg, "0 = 1");
1262 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1264 r = MsiEvaluateCondition(hpkg, "0 > 1");
1265 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1267 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1268 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1270 r = MsiEvaluateCondition(hpkg, "1 > 1");
1271 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1273 r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1274 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1276 r = MsiEvaluateCondition(hpkg, "0 >= 1");
1277 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1279 r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1280 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1282 r = MsiEvaluateCondition(hpkg, "1 >= 1");
1283 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1285 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1286 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1288 r = MsiEvaluateCondition(hpkg, "0 < 1");
1289 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1291 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1292 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1294 r = MsiEvaluateCondition(hpkg, "1 < 1");
1295 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1297 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1298 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300 r = MsiEvaluateCondition(hpkg, "0 <= 1");
1301 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303 r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1304 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1306 r = MsiEvaluateCondition(hpkg, "1 <= 1");
1307 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1309 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1310 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1312 r = MsiEvaluateCondition(hpkg, "0 >=");
1313 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1315 r = MsiEvaluateCondition(hpkg, " ");
1316 ok( r == MSICONDITION_NONE, "wrong return val\n");
1318 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1319 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1321 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1322 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1324 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1325 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1327 r = MsiEvaluateCondition(hpkg, "not 0");
1328 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1330 r = MsiEvaluateCondition(hpkg, "not LicView");
1331 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1333 r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1334 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1336 r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1337 ok (r == MSICONDITION_FALSE, "wrong return val\n");
1339 r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1340 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1342 r = MsiEvaluateCondition(hpkg, "not \"A\"");
1343 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1345 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1346 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1348 r = MsiEvaluateCondition(hpkg, "\"0\"");
1349 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1351 r = MsiEvaluateCondition(hpkg, "1 and 2");
1352 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1354 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1355 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1357 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1358 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1360 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1361 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1363 r = MsiEvaluateCondition(hpkg, "(0)");
1364 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1366 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1367 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1369 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1370 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1372 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1373 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1375 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1376 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1378 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1379 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1381 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1382 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1384 r = MsiEvaluateCondition(hpkg, "0 < > 0");
1385 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1387 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1388 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1390 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1391 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1393 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1394 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1396 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1397 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1399 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1400 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1402 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1403 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1405 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1406 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1408 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1409 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1411 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1412 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1414 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1415 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1417 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1418 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1420 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1421 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1423 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1424 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1426 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1427 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1429 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1430 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1432 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1433 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1435 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1436 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1438 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1439 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1441 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1442 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1444 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1445 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1447 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1448 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1450 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1451 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1453 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1454 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1456 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1457 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1459 MsiSetProperty(hpkg, "mm", "5" );
1461 r = MsiEvaluateCondition(hpkg, "mm = 5");
1462 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1464 r = MsiEvaluateCondition(hpkg, "mm < 6");
1465 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1467 r = MsiEvaluateCondition(hpkg, "mm <= 5");
1468 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1470 r = MsiEvaluateCondition(hpkg, "mm > 4");
1471 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1473 r = MsiEvaluateCondition(hpkg, "mm < 12");
1474 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1476 r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1477 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1479 r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1480 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1482 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1483 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1485 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1486 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1488 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1489 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1491 r = MsiEvaluateCondition(hpkg, "3 >< 1");
1492 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1494 r = MsiEvaluateCondition(hpkg, "3 >< 4");
1495 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1497 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1498 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1500 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1501 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1503 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1504 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1506 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1507 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1509 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1510 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1512 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1513 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1515 r = MsiEvaluateCondition(hpkg, "_1 = _1");
1516 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1518 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1519 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1521 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1522 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1524 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1525 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1527 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1528 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1530 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1531 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1533 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1534 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1536 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1537 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1539 r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1540 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1542 r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1543 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1545 r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1546 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1548 r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1549 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1551 r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1552 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1554 MsiSetProperty(hpkg, "bandalmael", "0" );
1555 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1556 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1558 MsiSetProperty(hpkg, "bandalmael", "" );
1559 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1560 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1562 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1563 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1564 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1566 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1567 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1568 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1570 MsiSetProperty(hpkg, "bandalmael", "0 " );
1571 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1572 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1574 MsiSetProperty(hpkg, "bandalmael", "-0" );
1575 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1576 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1578 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1579 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1580 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1582 MsiSetProperty(hpkg, "bandalmael", "--0" );
1583 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1584 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1586 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1587 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1588 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1590 MsiSetProperty(hpkg, "bandalmael", "-" );
1591 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1592 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1594 MsiSetProperty(hpkg, "bandalmael", "+0" );
1595 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1596 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1598 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1599 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1600 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1601 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1602 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1604 MsiSetProperty(hpkg, "one", "hi");
1605 MsiSetProperty(hpkg, "two", "hithere");
1606 r = MsiEvaluateCondition(hpkg, "one >< two");
1607 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1609 MsiSetProperty(hpkg, "one", "hithere");
1610 MsiSetProperty(hpkg, "two", "hi");
1611 r = MsiEvaluateCondition(hpkg, "one >< two");
1612 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1614 MsiSetProperty(hpkg, "one", "hello");
1615 MsiSetProperty(hpkg, "two", "hi");
1616 r = MsiEvaluateCondition(hpkg, "one >< two");
1617 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1619 MsiSetProperty(hpkg, "one", "hellohithere");
1620 MsiSetProperty(hpkg, "two", "hi");
1621 r = MsiEvaluateCondition(hpkg, "one >< two");
1622 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1624 MsiSetProperty(hpkg, "one", "");
1625 MsiSetProperty(hpkg, "two", "hi");
1626 r = MsiEvaluateCondition(hpkg, "one >< two");
1627 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1629 MsiSetProperty(hpkg, "one", "hi");
1630 MsiSetProperty(hpkg, "two", "");
1631 r = MsiEvaluateCondition(hpkg, "one >< two");
1632 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1634 MsiSetProperty(hpkg, "one", "");
1635 MsiSetProperty(hpkg, "two", "");
1636 r = MsiEvaluateCondition(hpkg, "one >< two");
1637 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1639 MsiSetProperty(hpkg, "one", "1234");
1640 MsiSetProperty(hpkg, "two", "1");
1641 r = MsiEvaluateCondition(hpkg, "one >< two");
1642 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1644 MsiSetProperty(hpkg, "one", "one 1234");
1645 MsiSetProperty(hpkg, "two", "1");
1646 r = MsiEvaluateCondition(hpkg, "one >< two");
1647 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1649 MsiSetProperty(hpkg, "one", "hithere");
1650 MsiSetProperty(hpkg, "two", "hi");
1651 r = MsiEvaluateCondition(hpkg, "one << two");
1652 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1654 MsiSetProperty(hpkg, "one", "hi");
1655 MsiSetProperty(hpkg, "two", "hithere");
1656 r = MsiEvaluateCondition(hpkg, "one << two");
1657 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1659 MsiSetProperty(hpkg, "one", "hi");
1660 MsiSetProperty(hpkg, "two", "hi");
1661 r = MsiEvaluateCondition(hpkg, "one << two");
1662 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1664 MsiSetProperty(hpkg, "one", "abcdhithere");
1665 MsiSetProperty(hpkg, "two", "hi");
1666 r = MsiEvaluateCondition(hpkg, "one << two");
1667 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1669 MsiSetProperty(hpkg, "one", "");
1670 MsiSetProperty(hpkg, "two", "hi");
1671 r = MsiEvaluateCondition(hpkg, "one << two");
1672 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1674 MsiSetProperty(hpkg, "one", "hithere");
1675 MsiSetProperty(hpkg, "two", "");
1676 r = MsiEvaluateCondition(hpkg, "one << two");
1677 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1679 MsiSetProperty(hpkg, "one", "");
1680 MsiSetProperty(hpkg, "two", "");
1681 r = MsiEvaluateCondition(hpkg, "one << two");
1682 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1684 MsiSetProperty(hpkg, "one", "1234");
1685 MsiSetProperty(hpkg, "two", "1");
1686 r = MsiEvaluateCondition(hpkg, "one << two");
1687 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1689 MsiSetProperty(hpkg, "one", "1234 one");
1690 MsiSetProperty(hpkg, "two", "1");
1691 r = MsiEvaluateCondition(hpkg, "one << two");
1692 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1694 MsiSetProperty(hpkg, "one", "hithere");
1695 MsiSetProperty(hpkg, "two", "there");
1696 r = MsiEvaluateCondition(hpkg, "one >> two");
1697 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1699 MsiSetProperty(hpkg, "one", "hithere");
1700 MsiSetProperty(hpkg, "two", "hi");
1701 r = MsiEvaluateCondition(hpkg, "one >> two");
1702 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1704 MsiSetProperty(hpkg, "one", "there");
1705 MsiSetProperty(hpkg, "two", "hithere");
1706 r = MsiEvaluateCondition(hpkg, "one >> two");
1707 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1709 MsiSetProperty(hpkg, "one", "there");
1710 MsiSetProperty(hpkg, "two", "there");
1711 r = MsiEvaluateCondition(hpkg, "one >> two");
1712 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1714 MsiSetProperty(hpkg, "one", "abcdhithere");
1715 MsiSetProperty(hpkg, "two", "hi");
1716 r = MsiEvaluateCondition(hpkg, "one >> two");
1717 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1719 MsiSetProperty(hpkg, "one", "");
1720 MsiSetProperty(hpkg, "two", "there");
1721 r = MsiEvaluateCondition(hpkg, "one >> two");
1722 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1724 MsiSetProperty(hpkg, "one", "there");
1725 MsiSetProperty(hpkg, "two", "");
1726 r = MsiEvaluateCondition(hpkg, "one >> two");
1727 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1729 MsiSetProperty(hpkg, "one", "");
1730 MsiSetProperty(hpkg, "two", "");
1731 r = MsiEvaluateCondition(hpkg, "one >> two");
1732 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1734 MsiSetProperty(hpkg, "one", "1234");
1735 MsiSetProperty(hpkg, "two", "4");
1736 r = MsiEvaluateCondition(hpkg, "one >> two");
1737 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1739 MsiSetProperty(hpkg, "one", "one 1234");
1740 MsiSetProperty(hpkg, "two", "4");
1741 r = MsiEvaluateCondition(hpkg, "one >> two");
1742 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1744 MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1746 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1747 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1749 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1750 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1752 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1753 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1755 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1756 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1758 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1759 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1761 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1762 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1764 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1765 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1767 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1768 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1770 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1771 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1773 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1774 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1776 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1777 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1779 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1780 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1782 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1783 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1785 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1786 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1788 r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1789 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1791 r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1792 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1794 r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1795 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1797 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1798 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1800 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1801 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1803 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1804 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1806 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1807 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1809 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1810 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1812 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1813 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1815 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1816 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1818 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1819 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1821 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1822 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1824 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1825 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1827 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1828 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1830 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1831 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1833 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1834 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1836 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1837 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1839 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1840 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1842 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1843 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1845 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1846 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1848 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1849 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1851 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1852 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1854 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1855 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1857 MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1858 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1859 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1861 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1862 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1864 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1865 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1867 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1868 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1870 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1871 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1873 MsiSetProperty(hpkg, "one", "1");
1874 r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1875 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1877 MsiSetProperty(hpkg, "X", "5.0");
1879 r = MsiEvaluateCondition(hpkg, "X != \"\"");
1880 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1882 r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1883 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1885 r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1886 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1888 r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1889 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1891 r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1892 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1894 r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1895 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1897 r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1898 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1900 /* feature doesn't exist */
1901 r = MsiEvaluateCondition(hpkg, "&nofeature");
1902 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1904 MsiSetProperty(hpkg, "A", "2");
1905 MsiSetProperty(hpkg, "X", "50");
1907 r = MsiEvaluateCondition(hpkg, "2 <= X");
1908 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1910 r = MsiEvaluateCondition(hpkg, "A <= X");
1911 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1913 r = MsiEvaluateCondition(hpkg, "A <= 50");
1914 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1916 MsiSetProperty(hpkg, "X", "50val");
1918 r = MsiEvaluateCondition(hpkg, "2 <= X");
1919 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1921 r = MsiEvaluateCondition(hpkg, "A <= X");
1922 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1924 MsiSetProperty(hpkg, "A", "7");
1925 MsiSetProperty(hpkg, "X", "50");
1927 r = MsiEvaluateCondition(hpkg, "7 <= X");
1928 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1930 r = MsiEvaluateCondition(hpkg, "A <= X");
1931 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1933 r = MsiEvaluateCondition(hpkg, "A <= 50");
1934 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1936 MsiSetProperty(hpkg, "X", "50val");
1938 r = MsiEvaluateCondition(hpkg, "2 <= X");
1939 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1941 r = MsiEvaluateCondition(hpkg, "A <= X");
1942 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1944 r = MsiEvaluateConditionW(hpkg, cond1);
1945 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1946 "wrong return val (%d)\n", r);
1948 r = MsiEvaluateConditionW(hpkg, cond2);
1949 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1950 "wrong return val (%d)\n", r);
1952 r = MsiEvaluateConditionW(hpkg, cond3);
1953 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1954 "wrong return val (%d)\n", r);
1956 r = MsiEvaluateConditionW(hpkg, cond4);
1957 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1958 "wrong return val (%d)\n", r);
1960 MsiCloseHandle( hpkg );
1961 DeleteFile(msifile);
1964 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1972 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1973 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1976 static void test_props(void)
1978 MSIHANDLE hpkg, hdb;
1983 hdb = create_package_db();
1985 "CREATE TABLE `Property` ( "
1986 "`Property` CHAR(255) NOT NULL, "
1987 "`Value` CHAR(255) "
1988 "PRIMARY KEY `Property`)" );
1989 ok( r == ERROR_SUCCESS , "Failed\n" );
1992 "INSERT INTO `Property` "
1993 "(`Property`, `Value`) "
1994 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1995 ok( r == ERROR_SUCCESS , "Failed\n" );
1997 r = package_from_db( hdb, &hpkg );
1998 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2000 skip("Not enough rights to perform tests\n");
2001 DeleteFile(msifile);
2004 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2006 /* test invalid values */
2007 r = MsiGetProperty( 0, NULL, NULL, NULL );
2008 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2010 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
2011 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2013 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
2014 ok( r == ERROR_SUCCESS, "wrong return val\n");
2016 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
2017 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2019 /* test retrieving an empty/nonexistent property */
2021 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
2022 ok( r == ERROR_SUCCESS, "wrong return val\n");
2023 ok( sz == 0, "wrong size returned\n");
2025 check_prop_empty( hpkg, "boo");
2028 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2029 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2030 ok( !strcmp(buffer,"x"), "buffer was changed\n");
2031 ok( sz == 0, "wrong size returned\n");
2035 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2036 ok( r == ERROR_SUCCESS, "wrong return val\n");
2037 ok( buffer[0] == 0, "buffer was not changed\n");
2038 ok( sz == 0, "wrong size returned\n");
2040 /* set the property to something */
2041 r = MsiSetProperty( 0, NULL, NULL );
2042 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
2044 r = MsiSetProperty( hpkg, NULL, NULL );
2045 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2047 r = MsiSetProperty( hpkg, "", NULL );
2048 ok( r == ERROR_SUCCESS, "wrong return val\n");
2050 /* try set and get some illegal property identifiers */
2051 r = MsiSetProperty( hpkg, "", "asdf" );
2052 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2054 r = MsiSetProperty( hpkg, "=", "asdf" );
2055 ok( r == ERROR_SUCCESS, "wrong return val\n");
2057 r = MsiSetProperty( hpkg, " ", "asdf" );
2058 ok( r == ERROR_SUCCESS, "wrong return val\n");
2060 r = MsiSetProperty( hpkg, "'", "asdf" );
2061 ok( r == ERROR_SUCCESS, "wrong return val\n");
2065 r = MsiGetProperty( hpkg, "'", buffer, &sz );
2066 ok( r == ERROR_SUCCESS, "wrong return val\n");
2067 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2069 /* set empty values */
2070 r = MsiSetProperty( hpkg, "boo", NULL );
2071 ok( r == ERROR_SUCCESS, "wrong return val\n");
2072 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2074 r = MsiSetProperty( hpkg, "boo", "" );
2075 ok( r == ERROR_SUCCESS, "wrong return val\n");
2076 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2078 /* set a non-empty value */
2079 r = MsiSetProperty( hpkg, "boo", "xyz" );
2080 ok( r == ERROR_SUCCESS, "wrong return val\n");
2084 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2085 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2086 ok( buffer[0] == 0, "buffer was not changed\n");
2087 ok( sz == 3, "wrong size returned\n");
2091 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2092 ok( r == ERROR_SUCCESS, "wrong return val\n");
2093 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2094 ok( sz == 3, "wrong size returned\n");
2098 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2099 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2100 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2101 ok( sz == 3, "wrong size returned\n");
2103 r = MsiSetProperty(hpkg, "SourceDir", "foo");
2104 ok( r == ERROR_SUCCESS, "wrong return val\n");
2107 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2108 ok( r == ERROR_SUCCESS, "wrong return val\n");
2109 ok( !strcmp(buffer,""), "buffer wrong\n");
2110 ok( sz == 0, "wrong size returned\n");
2113 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2114 ok( r == ERROR_SUCCESS, "wrong return val\n");
2115 ok( !strcmp(buffer,""), "buffer wrong\n");
2116 ok( sz == 0, "wrong size returned\n");
2119 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2120 ok( r == ERROR_SUCCESS, "wrong return val\n");
2121 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2122 ok( sz == 3, "wrong size returned\n");
2124 r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2125 ok( r == ERROR_SUCCESS, "wrong return val\n");
2128 r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2129 ok( r == ERROR_SUCCESS, "return wrong\n");
2130 ok( sz == 13, "size wrong (%d)\n", sz);
2133 r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2134 ok( r == ERROR_MORE_DATA, "return wrong\n");
2135 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2137 r = MsiSetProperty(hpkg, "property", "value");
2138 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2141 r = MsiGetProperty(hpkg, "property", buffer, &sz);
2142 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2143 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2145 r = MsiSetProperty(hpkg, "property", NULL);
2146 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2149 r = MsiGetProperty(hpkg, "property", buffer, &sz);
2150 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2151 ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2153 MsiCloseHandle( hpkg );
2154 DeleteFile(msifile);
2157 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val, int len)
2159 MSIHANDLE hview, hrec;
2161 CHAR buffer[MAX_PATH];
2165 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2166 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2167 r = MsiViewExecute(hview, 0);
2168 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2170 if (len < 0) len = lstrlenA(val);
2172 while (r == ERROR_SUCCESS && !found)
2174 r = MsiViewFetch(hview, &hrec);
2175 if (r != ERROR_SUCCESS) break;
2178 r = MsiRecordGetString(hrec, 1, buffer, &sz);
2179 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2182 r = MsiRecordGetString(hrec, 2, buffer, &sz);
2183 if (r == ERROR_SUCCESS && !memcmp(buffer, val, len) && !buffer[len])
2185 ok(sz == len, "wrong size %u\n", sz);
2190 MsiCloseHandle(hrec);
2192 MsiViewClose(hview);
2193 MsiCloseHandle(hview);
2197 static void test_property_table(void)
2201 MSIHANDLE hpkg, hdb, hrec;
2202 char buffer[MAX_PATH], package[10];
2206 hdb = create_package_db();
2207 ok( hdb, "failed to create package\n");
2209 r = package_from_db(hdb, &hpkg);
2210 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2212 skip("Not enough rights to perform tests\n");
2213 DeleteFile(msifile);
2216 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2218 MsiCloseHandle(hdb);
2220 hdb = MsiGetActiveDatabase(hpkg);
2222 query = "CREATE TABLE `_Property` ( "
2223 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2224 r = run_query(hdb, query);
2225 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2227 MsiCloseHandle(hdb);
2228 MsiCloseHandle(hpkg);
2229 DeleteFile(msifile);
2231 hdb = create_package_db();
2232 ok( hdb, "failed to create package\n");
2234 query = "CREATE TABLE `_Property` ( "
2235 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2236 r = run_query(hdb, query);
2237 ok(r == ERROR_SUCCESS, "failed to create table\n");
2239 query = "ALTER `_Property` ADD `foo` INTEGER";
2240 r = run_query(hdb, query);
2241 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2243 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2244 r = run_query(hdb, query);
2245 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2247 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2248 r = run_query(hdb, query);
2249 ok(r == ERROR_SUCCESS, "failed to add column\n");
2251 sprintf(package, "#%i", hdb);
2252 r = MsiOpenPackage(package, &hpkg);
2253 todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2254 if (r == ERROR_SUCCESS)
2255 MsiCloseHandle(hpkg);
2257 r = MsiCloseHandle(hdb);
2258 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2260 hdb = create_package_db();
2261 ok (hdb, "failed to create package database\n");
2263 r = create_property_table(hdb);
2264 ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2266 r = add_property_entry(hdb, "'prop', 'val'");
2267 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2269 r = create_custom_action_table(hdb);
2270 ok(r == ERROR_SUCCESS, "cannot create CustomAction table: %d\n", r);
2272 r = add_custom_action_entry( hdb, "'EmbedNull', 51, 'prop2', '[~]np'" );
2273 ok( r == ERROR_SUCCESS, "cannot add custom action: %d\n", r);
2275 r = package_from_db(hdb, &hpkg);
2276 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2278 MsiCloseHandle(hdb);
2281 r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2282 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2283 ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2285 hdb = MsiGetActiveDatabase(hpkg);
2287 found = find_prop_in_property(hdb, "prop", "val", -1);
2288 ok(found, "prop should be in the _Property table\n");
2290 r = add_property_entry(hdb, "'dantes', 'mercedes'");
2291 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2293 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2294 r = do_query(hdb, query, &hrec);
2295 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2297 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2298 ok(found == FALSE, "dantes should not be in the _Property table\n");
2301 lstrcpy(buffer, "aaa");
2302 r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2303 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2304 ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2306 r = MsiSetProperty(hpkg, "dantes", "mercedes");
2307 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2309 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2310 ok(found == TRUE, "dantes should be in the _Property table\n");
2312 r = MsiDoAction( hpkg, "EmbedNull" );
2313 ok( r == ERROR_SUCCESS, "EmbedNull failed: %d\n", r);
2316 memset( buffer, 'a', sizeof(buffer) );
2317 r = MsiGetProperty( hpkg, "prop2", buffer, &sz );
2318 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2319 ok( !memcmp( buffer, "\0np", sizeof("\0np") ), "wrong value\n");
2320 ok( sz == sizeof("\0np") - 1, "got %u\n", sz );
2322 found = find_prop_in_property(hdb, "prop2", "\0np", 3);
2323 ok(found == TRUE, "prop2 should be in the _Property table\n");
2325 MsiCloseHandle(hdb);
2326 MsiCloseHandle(hpkg);
2327 DeleteFile(msifile);
2330 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2335 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2336 if( res == ERROR_SUCCESS )
2340 r = MsiViewExecute( htab, hrec );
2341 if( r != ERROR_SUCCESS )
2344 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2347 r = MsiViewClose( htab );
2348 if( r != ERROR_SUCCESS )
2351 r = MsiCloseHandle( htab );
2352 if( r != ERROR_SUCCESS )
2358 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2360 return try_query_param( hdb, szQuery, 0 );
2363 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2368 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2369 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2371 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2372 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2374 r = MsiSummaryInfoPersist(summary);
2375 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2377 MsiCloseHandle(summary);
2380 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2385 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2388 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2389 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2391 r = MsiSummaryInfoPersist(summary);
2392 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2394 MsiCloseHandle(summary);
2397 static void test_msipackage(void)
2399 MSIHANDLE hdb = 0, hpack = 100;
2404 /* NULL szPackagePath */
2405 r = MsiOpenPackage(NULL, &hpack);
2406 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2408 /* empty szPackagePath */
2409 r = MsiOpenPackage("", &hpack);
2410 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2412 skip("Not enough rights to perform tests\n");
2417 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2420 if (r == ERROR_SUCCESS)
2421 MsiCloseHandle(hpack);
2423 /* nonexistent szPackagePath */
2424 r = MsiOpenPackage("nonexistent", &hpack);
2425 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2428 r = MsiOpenPackage(msifile, NULL);
2429 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2433 r = MsiOpenPackage(name, &hpack);
2434 ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2436 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2437 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2439 /* database exists, but is emtpy */
2440 sprintf(name, "#%d", hdb);
2441 r = MsiOpenPackage(name, &hpack);
2442 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2443 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2445 query = "CREATE TABLE `Property` ( "
2446 "`Property` CHAR(72), `Value` CHAR(0) "
2447 "PRIMARY KEY `Property`)";
2448 r = try_query(hdb, query);
2449 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2451 query = "CREATE TABLE `InstallExecuteSequence` ("
2452 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2453 "PRIMARY KEY `Action`)";
2454 r = try_query(hdb, query);
2455 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2457 /* a few key tables exist */
2458 sprintf(name, "#%d", hdb);
2459 r = MsiOpenPackage(name, &hpack);
2460 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2461 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2463 MsiCloseHandle(hdb);
2464 DeleteFile(msifile);
2466 /* start with a clean database to show what constitutes a valid package */
2467 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2468 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2470 sprintf(name, "#%d", hdb);
2472 /* The following summary information props must exist:
2477 set_summary_dword(hdb, PID_PAGECOUNT, 100);
2478 r = MsiOpenPackage(name, &hpack);
2479 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2480 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2482 set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2483 r = MsiOpenPackage(name, &hpack);
2484 ok(r == ERROR_SUCCESS,
2485 "Expected ERROR_SUCCESS, got %d\n", r);
2487 MsiCloseHandle(hpack);
2488 MsiCloseHandle(hdb);
2489 DeleteFile(msifile);
2492 static void test_formatrecord2(void)
2494 MSIHANDLE hpkg, hrec ;
2499 r = package_from_db(create_package_db(), &hpkg);
2500 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2502 skip("Not enough rights to perform tests\n");
2503 DeleteFile(msifile);
2506 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2508 r = MsiSetProperty(hpkg, "Manufacturer", " " );
2509 ok( r == ERROR_SUCCESS, "set property failed\n");
2511 hrec = MsiCreateRecord(2);
2512 ok(hrec, "create record failed\n");
2514 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2515 ok( r == ERROR_SUCCESS, "format record failed\n");
2519 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2520 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2522 r = MsiRecordSetString(hrec, 0, "[foo][1]");
2523 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2524 r = MsiRecordSetString(hrec, 1, "hoo");
2525 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2527 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2528 ok( sz == 3, "size wrong\n");
2529 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2530 ok( r == ERROR_SUCCESS, "format failed\n");
2532 r = MsiRecordSetString(hrec, 0, "x[~]x");
2533 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2535 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2536 ok( sz == 3, "size wrong\n");
2537 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2538 ok( r == ERROR_SUCCESS, "format failed\n");
2540 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2541 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2542 r = MsiRecordSetString(hrec, 1, "hoo");
2543 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2545 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2546 ok( sz == 3, "size wrong\n");
2547 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2548 ok( r == ERROR_SUCCESS, "format failed\n");
2550 r = MsiRecordSetString(hrec, 0, "[\\[]");
2551 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2553 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2554 ok( sz == 1, "size wrong\n");
2555 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2556 ok( r == ERROR_SUCCESS, "format failed\n");
2558 SetEnvironmentVariable("FOO", "BAR");
2559 r = MsiRecordSetString(hrec, 0, "[%FOO]");
2560 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2562 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2563 ok( sz == 3, "size wrong\n");
2564 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2565 ok( r == ERROR_SUCCESS, "format failed\n");
2567 r = MsiRecordSetString(hrec, 0, "[[1]]");
2568 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2569 r = MsiRecordSetString(hrec, 1, "%FOO");
2570 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2572 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2573 ok( sz == 3, "size wrong\n");
2574 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2575 ok( r == ERROR_SUCCESS, "format failed\n");
2577 MsiCloseHandle( hrec );
2578 MsiCloseHandle( hpkg );
2579 DeleteFile(msifile);
2582 static void test_feature_states( UINT line, MSIHANDLE package, const char *feature, UINT error,
2583 INSTALLSTATE expected_state, INSTALLSTATE expected_action, int todo )
2586 INSTALLSTATE state = 0xdeadbee;
2587 INSTALLSTATE action = 0xdeadbee;
2589 r = MsiGetFeatureState( package, feature, &state, &action );
2590 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2591 if (r == ERROR_SUCCESS)
2593 ok( state == expected_state, "%u: expected state %d got %d\n",
2594 line, expected_state, state );
2596 ok( action == expected_action, "%u: expected action %d got %d\n",
2597 line, expected_action, action );
2599 ok( action == expected_action, "%u: expected action %d got %d\n",
2600 line, expected_action, action );
2604 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line, state );
2606 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2608 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2613 static void test_component_states( UINT line, MSIHANDLE package, const char *component, UINT error,
2614 INSTALLSTATE expected_state, INSTALLSTATE expected_action, int todo )
2617 INSTALLSTATE state = 0xdeadbee;
2618 INSTALLSTATE action = 0xdeadbee;
2620 r = MsiGetComponentState( package, component, &state, &action );
2621 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2622 if (r == ERROR_SUCCESS)
2624 ok( state == expected_state, "%u: expected state %d got %d\n",
2625 line, expected_state, state );
2627 ok( action == expected_action, "%u: expected action %d got %d\n",
2628 line, expected_action, action );
2630 ok( action == expected_action, "%u: expected action %d got %d\n",
2631 line, expected_action, action );
2635 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2638 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2641 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2646 static void test_states(void)
2648 static char msifile2[] = "winetest2-package.msi";
2649 static char msifile3[] = "winetest3-package.msi";
2650 static char msifile4[] = "winetest4-package.msi";
2655 if (is_process_limited())
2657 skip("process is limited\n");
2661 hdb = create_package_db();
2662 ok ( hdb, "failed to create package database\n" );
2664 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2665 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2667 r = create_property_table( hdb );
2668 ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2670 r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2671 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2673 r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2674 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2676 r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2677 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2679 r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2680 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2682 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2683 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2685 r = create_install_execute_sequence_table( hdb );
2686 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2688 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2689 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2691 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2692 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2694 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2695 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2697 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2698 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2700 r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2701 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2703 r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2704 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2706 r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2707 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2709 r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2710 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2712 r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2713 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2715 r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2716 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2718 r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2719 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2721 r = create_media_table( hdb );
2722 ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2724 r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2725 ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2727 r = create_feature_table( hdb );
2728 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2730 r = create_component_table( hdb );
2731 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2733 /* msidbFeatureAttributesFavorLocal */
2734 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2735 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2737 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2738 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2739 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2741 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2742 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2743 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2745 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2746 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2747 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2749 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2750 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2751 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2753 /* msidbFeatureAttributesFavorSource */
2754 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2755 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2757 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2758 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2759 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2761 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2762 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2763 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2765 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2766 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2767 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2769 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2770 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2771 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2773 /* msidbFeatureAttributesFavorSource */
2774 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2775 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2777 /* msidbFeatureAttributesFavorLocal */
2778 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2779 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2782 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2783 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2785 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2786 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2787 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2789 /* no feature parent:msidbComponentAttributesLocalOnly */
2790 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2791 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2793 /* msidbFeatureAttributesFavorLocal:removed */
2794 r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2795 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2797 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2798 r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2799 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2801 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2802 r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2803 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2805 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2806 r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2807 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2809 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2810 r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2811 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2813 /* msidbFeatureAttributesFavorSource:removed */
2814 r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2815 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2817 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2818 r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2819 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2821 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2822 r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2823 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2825 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2826 r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2827 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2829 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2830 r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2831 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2833 /* msidbFeatureAttributesFavorLocal */
2834 r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2835 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2837 r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2838 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2840 /* msidbFeatureAttributesFavorSource */
2841 r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2842 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2844 r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2845 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2847 /* msidbFeatureAttributesFavorAdvertise */
2848 r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2849 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2851 r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2852 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2854 /* msidbFeatureAttributesUIDisallowAbsent */
2855 r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2856 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2858 r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2859 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2861 r = create_feature_components_table( hdb );
2862 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2864 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2865 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2867 r = add_feature_components_entry( hdb, "'one', 'beta'" );
2868 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2870 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2871 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2873 r = add_feature_components_entry( hdb, "'one', 'theta'" );
2874 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2876 r = add_feature_components_entry( hdb, "'two', 'delta'" );
2877 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2879 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2880 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2882 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2883 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2885 r = add_feature_components_entry( hdb, "'two', 'iota'" );
2886 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2888 r = add_feature_components_entry( hdb, "'three', 'eta'" );
2889 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2891 r = add_feature_components_entry( hdb, "'four', 'eta'" );
2892 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2894 r = add_feature_components_entry( hdb, "'five', 'eta'" );
2895 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2897 r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2898 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2900 r = add_feature_components_entry( hdb, "'six', 'mu'" );
2901 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2903 r = add_feature_components_entry( hdb, "'six', 'nu'" );
2904 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2906 r = add_feature_components_entry( hdb, "'six', 'xi'" );
2907 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2909 r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2910 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2912 r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2913 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2915 r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2916 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2918 r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2919 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2921 r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2922 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2924 r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2925 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2927 r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2928 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2930 r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
2931 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2933 r = create_file_table( hdb );
2934 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2936 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2937 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2939 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2940 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2942 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2943 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2945 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2946 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2948 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2949 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2951 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2952 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2954 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2955 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2957 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2958 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2960 /* compressed file */
2961 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2962 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2964 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2965 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2967 r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2968 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2970 r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2971 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2973 r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2974 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2976 r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2977 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2979 r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2980 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2982 r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2983 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2985 r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2986 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2988 r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2989 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2991 r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2992 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2994 r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2995 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2997 r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2998 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3000 r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3001 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3003 MsiDatabaseCommit(hdb);
3005 /* these properties must not be in the saved msi file */
3006 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3007 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3009 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3010 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3012 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3013 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3015 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3016 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3018 r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
3019 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3021 r = package_from_db( hdb, &hpkg );
3022 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3024 skip("Not enough rights to perform tests\n");
3025 DeleteFile(msifile);
3028 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3030 MsiCloseHandle(hdb);
3032 CopyFileA(msifile, msifile2, FALSE);
3033 CopyFileA(msifile, msifile3, FALSE);
3034 CopyFileA(msifile, msifile4, FALSE);
3036 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3037 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3039 r = MsiDoAction( hpkg, "CostInitialize");
3040 ok( r == ERROR_SUCCESS, "cost init failed\n");
3042 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3043 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3045 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3047 r = MsiDoAction( hpkg, "FileCost");
3048 ok( r == ERROR_SUCCESS, "file cost failed\n");
3050 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3051 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3053 r = MsiDoAction( hpkg, "CostFinalize");
3054 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3056 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3057 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3058 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3059 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3060 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3061 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3062 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3063 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3064 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3065 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3066 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3068 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3069 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3070 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3071 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3072 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3073 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3074 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3075 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3076 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3077 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3078 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3079 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3080 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3081 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3082 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3083 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3084 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3085 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3086 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3087 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3088 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3089 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3091 MsiCloseHandle( hpkg );
3093 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3095 /* publish the features and components */
3096 r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3097 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3099 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3100 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3102 /* these properties must not be in the saved msi file */
3103 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3104 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3106 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3107 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3109 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3110 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3112 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3113 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3115 r = package_from_db( hdb, &hpkg );
3116 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3118 MsiCloseHandle(hdb);
3120 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3121 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3123 r = MsiDoAction( hpkg, "CostInitialize");
3124 ok( r == ERROR_SUCCESS, "cost init failed\n");
3126 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3127 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3129 r = MsiDoAction( hpkg, "FileCost");
3130 ok( r == ERROR_SUCCESS, "file cost failed\n");
3132 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3133 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3135 r = MsiDoAction( hpkg, "CostFinalize");
3136 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3138 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3139 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3140 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3141 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3142 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3143 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3144 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3145 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3146 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3147 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3148 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3150 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3151 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3152 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3153 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3154 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3155 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3156 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3157 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3158 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3159 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3160 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3161 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3162 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3163 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3164 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3165 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3166 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3167 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3168 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3169 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3170 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3171 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3173 MsiCloseHandle(hpkg);
3175 /* uninstall the product */
3176 r = MsiInstallProduct(msifile, "REMOVE=ALL");
3177 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3179 /* all features installed locally */
3180 r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
3181 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3183 r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
3184 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3186 /* these properties must not be in the saved msi file */
3187 r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3188 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3190 r = package_from_db( hdb, &hpkg );
3191 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3193 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3194 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3196 r = MsiDoAction( hpkg, "CostInitialize");
3197 ok( r == ERROR_SUCCESS, "cost init failed\n");
3199 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3200 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3202 r = MsiDoAction( hpkg, "CostFinalize");
3203 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3205 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3206 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3207 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3208 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3209 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3210 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3211 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3212 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3213 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3214 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3215 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3217 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3218 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3219 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3220 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3221 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3222 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3223 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3224 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3225 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3226 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3227 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3228 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3229 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3230 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3231 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3232 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3233 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3234 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3235 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3236 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3237 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3238 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3240 MsiCloseHandle(hpkg);
3242 /* uninstall the product */
3243 r = MsiInstallProduct(msifile2, "REMOVE=ALL");
3244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3246 /* all features installed from source */
3247 r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
3248 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3250 r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
3251 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3253 /* this property must not be in the saved msi file */
3254 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3255 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3257 r = package_from_db( hdb, &hpkg );
3258 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3260 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3261 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3263 r = MsiDoAction( hpkg, "CostInitialize");
3264 ok( r == ERROR_SUCCESS, "cost init failed\n");
3266 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3267 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3269 r = MsiDoAction( hpkg, "FileCost");
3270 ok( r == ERROR_SUCCESS, "file cost failed\n");
3272 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3273 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3275 r = MsiDoAction( hpkg, "CostFinalize");
3276 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3278 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3279 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3280 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3281 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3282 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3283 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3284 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3285 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3286 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3287 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3288 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3290 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3291 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3292 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3293 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3294 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3295 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3296 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3297 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3298 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3299 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3300 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3301 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3302 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3303 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3304 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3305 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3306 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3307 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3308 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3309 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3310 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3311 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3313 MsiCloseHandle(hpkg);
3315 /* reinstall the product */
3316 r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
3317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3319 r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
3320 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3322 /* this property must not be in the saved msi file */
3323 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3324 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3326 r = package_from_db( hdb, &hpkg );
3327 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3329 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3330 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3332 r = MsiDoAction( hpkg, "CostInitialize");
3333 ok( r == ERROR_SUCCESS, "cost init failed\n");
3335 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3336 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3338 r = MsiDoAction( hpkg, "FileCost");
3339 ok( r == ERROR_SUCCESS, "file cost failed\n");
3341 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3342 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3344 r = MsiDoAction( hpkg, "CostFinalize");
3345 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3347 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3348 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3349 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3350 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3351 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3352 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3353 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3354 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3355 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3356 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3357 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3359 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3360 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3361 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3362 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3363 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3364 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3365 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3366 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3367 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3368 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3369 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3370 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3371 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3372 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3373 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3374 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3375 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3376 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3377 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3378 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3379 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3380 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3382 MsiCloseHandle(hpkg);
3384 /* uninstall the product */
3385 r = MsiInstallProduct(msifile4, "REMOVE=ALL");
3386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3388 DeleteFileA(msifile);
3389 DeleteFileA(msifile2);
3390 DeleteFileA(msifile3);
3391 DeleteFileA(msifile4);
3394 static void test_getproperty(void)
3396 MSIHANDLE hPackage = 0;
3398 static CHAR empty[] = "";
3402 r = package_from_db(create_package_db(), &hPackage);
3403 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3405 skip("Not enough rights to perform tests\n");
3406 DeleteFile(msifile);
3409 ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
3411 /* set the property */
3412 r = MsiSetProperty(hPackage, "Name", "Value");
3413 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3415 /* retrieve the size, NULL pointer */
3417 r = MsiGetProperty(hPackage, "Name", NULL, &size);
3418 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3419 ok( size == 5, "Expected 5, got %d\n", size);
3421 /* retrieve the size, empty string */
3423 r = MsiGetProperty(hPackage, "Name", empty, &size);
3424 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3425 ok( size == 5, "Expected 5, got %d\n", size);
3427 /* don't change size */
3428 r = MsiGetProperty(hPackage, "Name", prop, &size);
3429 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3430 ok( size == 5, "Expected 5, got %d\n", size);
3431 ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
3433 /* increase the size by 1 */
3435 r = MsiGetProperty(hPackage, "Name", prop, &size);
3436 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3437 ok( size == 5, "Expected 5, got %d\n", size);
3438 ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
3440 r = MsiCloseHandle( hPackage);
3441 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
3442 DeleteFile(msifile);
3445 static void test_removefiles(void)
3450 INSTALLSTATE installed, action;
3452 hdb = create_package_db();
3453 ok ( hdb, "failed to create package database\n" );
3455 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3456 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3458 r = create_feature_table( hdb );
3459 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
3461 r = create_component_table( hdb );
3462 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
3464 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3465 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3467 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3468 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3470 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3471 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3473 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3474 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3476 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3477 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3479 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3480 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3482 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3483 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3485 r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3486 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3488 r = create_feature_components_table( hdb );
3489 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
3491 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
3492 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3494 r = add_feature_components_entry( hdb, "'one', 'helium'" );
3495 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3497 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
3498 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3500 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
3501 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3503 r = add_feature_components_entry( hdb, "'one', 'boron'" );
3504 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3506 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
3507 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3509 r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
3510 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3512 r = create_file_table( hdb );
3513 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3515 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3516 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3518 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3519 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3521 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3522 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3524 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3525 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3527 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3528 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3530 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3531 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3533 r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3534 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3536 r = create_remove_file_table( hdb );
3537 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
3539 r = package_from_db( hdb, &hpkg );
3540 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3542 skip("Not enough rights to perform tests\n");
3543 DeleteFile(msifile);
3546 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3548 MsiCloseHandle( hdb );
3550 create_test_file( "hydrogen.txt" );
3551 create_test_file( "helium.txt" );
3552 create_test_file( "lithium.txt" );
3553 create_test_file( "beryllium.txt" );
3554 create_test_file( "boron.txt" );
3555 create_test_file( "carbon.txt" );
3556 create_test_file( "oxygen.txt" );
3558 r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
3559 ok( r == ERROR_SUCCESS, "set property failed\n");
3561 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3563 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3564 ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
3566 r = MsiDoAction( hpkg, "CostInitialize");
3567 ok( r == ERROR_SUCCESS, "cost init failed\n");
3569 r = MsiDoAction( hpkg, "FileCost");
3570 ok( r == ERROR_SUCCESS, "file cost failed\n");
3572 installed = action = 0xdeadbeef;
3573 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3574 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3575 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3576 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3578 r = MsiDoAction( hpkg, "CostFinalize");
3579 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3581 r = MsiDoAction( hpkg, "InstallValidate");
3582 ok( r == ERROR_SUCCESS, "install validate failed\n");
3584 r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
3585 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3587 installed = action = 0xdeadbeef;
3588 r = MsiGetComponentState( hpkg, "hydrogen", &installed, &action );
3589 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3590 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3591 todo_wine ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3593 r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
3594 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3596 r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
3597 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3599 r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
3600 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3602 r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
3603 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3605 r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
3606 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3608 installed = action = 0xdeadbeef;
3609 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3610 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3611 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3612 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3614 r = MsiSetComponentState( hpkg, "oxygen", INSTALLSTATE_ABSENT );
3615 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3617 installed = action = 0xdeadbeef;
3618 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3619 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3620 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3621 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3623 r = MsiDoAction( hpkg, "RemoveFiles");
3624 ok( r == ERROR_SUCCESS, "remove files failed\n");
3626 installed = action = 0xdeadbeef;
3627 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3628 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3629 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3630 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3632 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3633 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3634 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3635 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3636 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3637 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3638 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3640 MsiCloseHandle( hpkg );
3641 DeleteFileA(msifile);
3644 static void test_appsearch(void)
3649 CHAR prop[MAX_PATH];
3652 hdb = create_package_db();
3653 ok ( hdb, "failed to create package database\n" );
3655 r = create_appsearch_table( hdb );
3656 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
3658 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
3659 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3661 r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
3662 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3664 r = create_reglocator_table( hdb );
3665 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3667 r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3668 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3670 r = create_drlocator_table( hdb );
3671 ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
3673 r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3674 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3676 r = create_signature_table( hdb );
3677 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
3679 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3680 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3682 r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3683 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3685 r = package_from_db( hdb, &hpkg );
3686 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3688 skip("Not enough rights to perform tests\n");
3689 DeleteFile(msifile);
3692 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3693 MsiCloseHandle( hdb );
3694 if (r != ERROR_SUCCESS)
3697 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3699 r = MsiDoAction( hpkg, "AppSearch" );
3700 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
3702 size = sizeof(prop);
3703 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
3704 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3705 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3707 size = sizeof(prop);
3708 r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
3709 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3712 MsiCloseHandle( hpkg );
3713 DeleteFileA(msifile);
3716 static void test_appsearch_complocator(void)
3718 MSIHANDLE hpkg, hdb;
3719 CHAR path[MAX_PATH];
3720 CHAR prop[MAX_PATH];
3725 if (!(usersid = get_user_sid()))
3728 if (is_process_limited())
3730 skip("process is limited\n");
3734 create_test_file("FileName1");
3735 create_test_file("FileName4");
3736 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
3737 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
3739 create_test_file("FileName2");
3740 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
3741 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
3743 create_test_file("FileName3");
3744 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
3745 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
3747 create_test_file("FileName5");
3748 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
3749 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
3751 create_test_file("FileName6");
3752 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
3753 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
3755 create_test_file("FileName7");
3756 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
3757 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
3759 /* dir is FALSE, but we're pretending it's a directory */
3760 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
3761 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
3763 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3764 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
3765 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
3767 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3768 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
3769 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
3771 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3772 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
3773 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
3775 hdb = create_package_db();
3776 ok(hdb, "Expected a valid database handle\n");
3778 r = create_appsearch_table(hdb);
3779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3781 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
3782 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3784 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
3785 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3787 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
3788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3790 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
3791 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3793 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
3794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3796 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
3797 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3799 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
3800 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3802 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
3803 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3805 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
3806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3808 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
3809 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3811 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
3812 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3814 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
3815 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3817 r = create_complocator_table(hdb);
3818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3820 /* published component, machine, file, signature, misdbLocatorTypeFile */
3821 r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
3822 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3824 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
3825 r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
3826 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3828 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
3829 r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
3830 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3832 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
3833 r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
3834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3836 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
3837 r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
3838 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3840 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
3841 r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
3842 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3844 /* published component, machine, file, no signature, misdbLocatorTypeFile */
3845 r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
3846 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3848 /* unpublished component, no signature, misdbLocatorTypeDir */
3849 r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
3850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3852 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
3853 r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
3854 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3856 /* published component, signature w/ ver, misdbLocatorTypeFile */
3857 r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
3858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3860 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
3861 r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
3862 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3864 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
3865 r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
3866 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3868 r = create_signature_table(hdb);
3869 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3871 r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
3872 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3874 r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
3875 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3877 r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
3878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3880 r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
3881 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3883 r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
3884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3886 r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3887 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3889 r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3890 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3892 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3893 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3895 r = package_from_db(hdb, &hpkg);
3896 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3898 skip("Not enough rights to perform tests\n");
3901 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
3903 r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
3904 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3906 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3908 r = MsiDoAction(hpkg, "AppSearch");
3909 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3912 sprintf(path, "%s\\FileName1", CURR_DIR);
3913 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
3914 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3915 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3918 sprintf(path, "%s\\FileName2", CURR_DIR);
3919 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
3920 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3921 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3924 sprintf(path, "%s\\FileName3", CURR_DIR);
3925 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
3926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3927 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3930 sprintf(path, "%s\\FileName4", CURR_DIR);
3931 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
3932 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3933 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3936 sprintf(path, "%s\\FileName5", CURR_DIR);
3937 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
3938 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3939 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3942 sprintf(path, "%s\\", CURR_DIR);
3943 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
3944 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3945 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3948 sprintf(path, "%s\\", CURR_DIR);
3949 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
3950 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3951 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3954 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
3955 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3956 ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
3959 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
3960 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3961 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3964 sprintf(path, "%s\\FileName8.dll", CURR_DIR);
3965 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
3966 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3967 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3970 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
3971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3972 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3975 sprintf(path, "%s\\FileName10.dll", CURR_DIR);
3976 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
3977 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3978 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3980 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
3981 MSIINSTALLCONTEXT_MACHINE, NULL);
3982 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
3983 MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
3984 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
3985 MSIINSTALLCONTEXT_USERMANAGED, usersid);
3986 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
3987 MSIINSTALLCONTEXT_MACHINE, NULL);
3988 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
3989 MSIINSTALLCONTEXT_MACHINE, NULL);
3990 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
3991 MSIINSTALLCONTEXT_MACHINE, NULL);
3992 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
3993 MSIINSTALLCONTEXT_MACHINE, NULL);
3994 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
3995 MSIINSTALLCONTEXT_MACHINE, NULL);
3996 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
3997 MSIINSTALLCONTEXT_MACHINE, NULL);
3998 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
3999 MSIINSTALLCONTEXT_MACHINE, NULL);
4001 MsiCloseHandle(hpkg);
4004 DeleteFileA("FileName1");
4005 DeleteFileA("FileName2");
4006 DeleteFileA("FileName3");
4007 DeleteFileA("FileName4");
4008 DeleteFileA("FileName5");
4009 DeleteFileA("FileName6");
4010 DeleteFileA("FileName7");
4011 DeleteFileA("FileName8.dll");
4012 DeleteFileA("FileName9.dll");
4013 DeleteFileA("FileName10.dll");
4014 DeleteFileA(msifile);
4018 static void test_appsearch_reglocator(void)
4020 MSIHANDLE hpkg, hdb;
4021 CHAR path[MAX_PATH], prop[MAX_PATH];
4022 DWORD binary[2], size, val;
4023 BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
4024 HKEY hklm, classes, hkcu, users;
4025 LPSTR pathdata, pathvar, ptr;
4032 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4035 DeleteFileA("test.dll");
4037 res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
4038 if (res == ERROR_ACCESS_DENIED)
4040 skip("Not enough rights to perform tests\n");
4043 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4045 res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
4046 (const BYTE *)"regszdata", 10);
4047 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4049 res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
4050 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4052 res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
4053 (const BYTE *)"regszdata", 10);
4054 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4057 res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
4058 ok(res == ERROR_SUCCESS ||
4059 broken(res == ERROR_INVALID_PARAMETER),
4060 "Expected ERROR_SUCCESS, got %d\n", res);
4062 if (res == ERROR_SUCCESS)
4064 res = RegSetValueExA(users, "Value1", 0, REG_SZ,
4065 (const BYTE *)"regszdata", 10);
4066 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4069 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
4070 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4072 res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
4073 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4075 res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
4076 (const BYTE *)"regszdata", 10);
4077 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4080 res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
4081 (const BYTE *)&val, sizeof(DWORD));
4082 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4085 res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
4086 (const BYTE *)&val, sizeof(DWORD));
4087 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4089 res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
4090 (const BYTE *)"%PATH%", 7);
4091 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4093 res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
4094 (const BYTE *)"my%NOVAR%", 10);
4095 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4097 res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
4098 (const BYTE *)"one\0two\0", 9);
4099 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4101 binary[0] = 0x1234abcd;
4102 binary[1] = 0x567890ef;
4103 res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
4104 (const BYTE *)binary, sizeof(binary));
4105 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4107 res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
4108 (const BYTE *)"#regszdata", 11);
4109 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4111 create_test_file("FileName1");
4112 sprintf(path, "%s\\FileName1", CURR_DIR);
4113 res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
4114 (const BYTE *)path, lstrlenA(path) + 1);
4115 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4117 sprintf(path, "%s\\FileName2", CURR_DIR);
4118 res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
4119 (const BYTE *)path, lstrlenA(path) + 1);
4120 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4122 lstrcpyA(path, CURR_DIR);
4123 res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
4124 (const BYTE *)path, lstrlenA(path) + 1);
4125 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4127 res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
4128 (const BYTE *)"", 1);
4129 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4131 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4132 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4133 res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
4134 (const BYTE *)path, lstrlenA(path) + 1);
4135 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4137 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4138 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4139 res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
4140 (const BYTE *)path, lstrlenA(path) + 1);
4141 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4143 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4144 sprintf(path, "%s\\FileName5.dll", CURR_DIR);
4145 res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
4146 (const BYTE *)path, lstrlenA(path) + 1);
4147 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4149 sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
4150 res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
4151 (const BYTE *)path, lstrlenA(path) + 1);
4152 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4154 space = strchr(CURR_DIR, ' ') != NULL;
4155 sprintf(path, "%s\\FileName1 -option", CURR_DIR);
4156 res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
4157 (const BYTE *)path, lstrlenA(path) + 1);
4158 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4160 hdb = create_package_db();
4161 ok(hdb, "Expected a valid database handle\n");
4163 r = create_appsearch_table(hdb);
4164 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4166 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4169 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4170 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4172 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4173 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4175 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4176 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4178 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4179 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4181 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4182 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4184 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4187 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4188 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4190 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4191 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4193 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4194 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4196 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4197 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4199 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4202 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
4203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4205 r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
4206 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4208 r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
4209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4211 r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
4212 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4214 r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
4215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4217 r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
4218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4220 r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
4221 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4223 r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
4224 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4226 r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
4227 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4229 r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
4230 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4232 r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
4233 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4235 r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
4236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4238 r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
4239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4241 r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
4242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4244 r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
4245 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4247 r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
4248 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4250 r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
4251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4253 r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
4254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4256 r = create_reglocator_table(hdb);
4257 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4259 type = msidbLocatorTypeRawValue;
4261 type |= msidbLocatorType64bit;
4263 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4264 r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
4265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4267 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4268 r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
4269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4271 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4272 r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
4273 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4275 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4276 r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
4277 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4279 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4280 r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
4281 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4283 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4284 r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
4285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4287 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4288 r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
4289 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4291 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4292 r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
4293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4295 type = msidbLocatorTypeFileName;
4297 type |= msidbLocatorType64bit;
4299 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4300 r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
4301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4303 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4304 r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
4305 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4307 /* HKLM, msidbLocatorTypeFileName, no signature */
4308 r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
4309 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4311 type = msidbLocatorTypeDirectory;
4313 type |= msidbLocatorType64bit;
4315 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4316 r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
4317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4319 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4320 r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
4321 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4323 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4324 r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
4325 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4327 type = msidbLocatorTypeRawValue;
4329 type |= msidbLocatorType64bit;
4331 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4332 r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
4333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4335 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4336 r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
4337 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4339 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4340 r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
4341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4343 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4344 r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
4345 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4347 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4348 r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
4349 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4351 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4352 r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
4353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4355 type = msidbLocatorTypeFileName;
4357 type |= msidbLocatorType64bit;
4359 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4360 r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
4361 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4363 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4364 r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
4365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4367 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4368 r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
4369 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4371 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4372 r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
4373 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4375 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4376 r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
4377 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4379 type = msidbLocatorTypeDirectory;
4381 type |= msidbLocatorType64bit;
4383 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4384 r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
4385 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4387 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4388 r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
4389 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4391 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4392 r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
4393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4395 type = msidbLocatorTypeFileName;
4397 type |= msidbLocatorType64bit;
4399 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4400 r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
4401 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4403 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4404 r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
4405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4407 r = create_signature_table(hdb);
4408 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4410 str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4411 r = add_signature_entry(hdb, str);
4412 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4414 str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4415 r = add_signature_entry(hdb, str);
4416 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4418 str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4419 r = add_signature_entry(hdb, str);
4420 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4422 str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4423 r = add_signature_entry(hdb, str);
4424 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4426 str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4427 r = add_signature_entry(hdb, str);
4428 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4430 str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4431 r = add_signature_entry(hdb, str);
4432 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4434 ptr = strrchr(CURR_DIR, '\\') + 1;
4435 sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
4436 r = add_signature_entry(hdb, path);
4437 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4439 str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4440 r = add_signature_entry(hdb, str);
4441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4443 str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4444 r = add_signature_entry(hdb, str);
4445 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4447 str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4448 r = add_signature_entry(hdb, str);
4449 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4451 r = package_from_db(hdb, &hpkg);
4452 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4454 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4456 r = MsiDoAction(hpkg, "AppSearch");
4457 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4460 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4461 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4462 ok(!lstrcmpA(prop, "regszdata"),
4463 "Expected \"regszdata\", got \"%s\"\n", prop);
4466 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4467 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4468 ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
4471 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4472 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4473 ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
4475 memset(&si, 0, sizeof(si));
4476 if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
4478 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
4480 size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
4481 pathvar = HeapAlloc(GetProcessHeap(), 0, size);
4482 ExpandEnvironmentStringsA("%PATH%", pathvar, size);
4485 r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
4486 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4488 pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
4489 r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
4490 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4491 ok(!lstrcmpA(pathdata, pathvar),
4492 "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
4494 HeapFree(GetProcessHeap(), 0, pathvar);
4495 HeapFree(GetProcessHeap(), 0, pathdata);
4499 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4500 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4502 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
4505 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4506 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4509 ok(!memcmp(prop, "\0one\0two\0\0", 10),
4510 "Expected \"\\0one\\0two\\0\\0\"\n");
4514 lstrcpyA(path, "#xCDAB3412EF907856");
4515 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4516 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4517 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4520 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4521 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4522 ok(!lstrcmpA(prop, "##regszdata"),
4523 "Expected \"##regszdata\", got \"%s\"\n", prop);
4526 sprintf(path, "%s\\FileName1", CURR_DIR);
4527 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4528 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4529 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4532 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4533 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4534 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4537 sprintf(path, "%s\\", CURR_DIR);
4538 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4539 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4540 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4543 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4544 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4545 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4548 sprintf(path, "%s\\", CURR_DIR);
4549 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
4550 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4551 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4554 r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
4555 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4556 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4559 r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
4560 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4561 ok(!lstrcmpA(prop, "regszdata"),
4562 "Expected \"regszdata\", got \"%s\"\n", prop);
4565 r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
4566 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4567 ok(!lstrcmpA(prop, "regszdata"),
4568 "Expected \"regszdata\", got \"%s\"\n", prop);
4573 r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
4574 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4575 ok(!lstrcmpA(prop, "regszdata"),
4576 "Expected \"regszdata\", got \"%s\"\n", prop);
4580 r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
4581 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4582 ok(!lstrcmpA(prop, "defvalue"),
4583 "Expected \"defvalue\", got \"%s\"\n", prop);
4586 r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
4587 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4588 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4591 r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
4592 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4593 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4598 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4599 r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
4600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4601 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4604 r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
4605 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4606 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4609 sprintf(path, "%s\\FileName5.dll", CURR_DIR);
4610 r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
4611 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4612 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4616 lstrcpyA(path, CURR_DIR);
4617 ptr = strrchr(path, '\\') + 1;
4619 r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
4620 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4621 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4624 sprintf(path, "%s\\", CURR_DIR);
4625 r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
4626 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4627 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4630 r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
4631 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4632 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4635 r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
4636 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4637 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4640 r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
4641 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4642 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4645 sprintf(path, "%s\\FileName1", CURR_DIR);
4646 r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
4647 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4648 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4651 sprintf(path, "%s\\FileName1", CURR_DIR);
4652 r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
4653 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4655 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4657 todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4659 RegSetValueA(hklm, NULL, REG_SZ, "", 0);
4660 RegDeleteValueA(hklm, "Value1");
4661 RegDeleteValueA(hklm, "Value2");
4662 RegDeleteValueA(hklm, "Value3");
4663 RegDeleteValueA(hklm, "Value4");
4664 RegDeleteValueA(hklm, "Value5");
4665 RegDeleteValueA(hklm, "Value6");
4666 RegDeleteValueA(hklm, "Value7");
4667 RegDeleteValueA(hklm, "Value8");
4668 RegDeleteValueA(hklm, "Value9");
4669 RegDeleteValueA(hklm, "Value10");
4670 RegDeleteValueA(hklm, "Value11");
4671 RegDeleteValueA(hklm, "Value12");
4672 RegDeleteValueA(hklm, "Value13");
4673 RegDeleteValueA(hklm, "Value14");
4674 RegDeleteValueA(hklm, "Value15");
4675 RegDeleteValueA(hklm, "Value16");
4676 RegDeleteValueA(hklm, "Value17");
4677 RegDeleteKey(hklm, "");
4680 RegDeleteValueA(classes, "Value1");
4681 RegDeleteKeyA(classes, "");
4682 RegCloseKey(classes);
4684 RegDeleteValueA(hkcu, "Value1");
4685 RegDeleteKeyA(hkcu, "");
4688 RegDeleteValueA(users, "Value1");
4689 RegDeleteKeyA(users, "");
4692 DeleteFileA("FileName1");
4693 DeleteFileA("FileName3.dll");
4694 DeleteFileA("FileName4.dll");
4695 DeleteFileA("FileName5.dll");
4696 MsiCloseHandle(hpkg);
4697 DeleteFileA(msifile);
4700 static void delete_win_ini(LPCSTR file)
4702 CHAR path[MAX_PATH];
4704 GetWindowsDirectoryA(path, MAX_PATH);
4705 lstrcatA(path, "\\");
4706 lstrcatA(path, file);
4711 static void test_appsearch_inilocator(void)
4713 MSIHANDLE hpkg, hdb;
4714 CHAR path[MAX_PATH];
4715 CHAR prop[MAX_PATH];
4723 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4726 DeleteFileA("test.dll");
4728 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4730 create_test_file("FileName1");
4731 sprintf(path, "%s\\FileName1", CURR_DIR);
4732 WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
4734 WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
4736 sprintf(path, "%s\\IDontExist", CURR_DIR);
4737 WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
4739 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4740 sprintf(path, "%s\\FileName2.dll", CURR_DIR);
4741 WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
4743 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4744 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4745 WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
4747 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4748 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4749 WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
4751 hdb = create_package_db();
4752 ok(hdb, "Expected a valid database handle\n");
4754 r = create_appsearch_table(hdb);
4755 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4757 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4758 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4760 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4761 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4763 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4764 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4766 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4769 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4772 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4773 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4775 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4776 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4778 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4781 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4782 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4784 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4785 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4787 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4790 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4791 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4793 r = create_inilocator_table(hdb);
4794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4796 /* msidbLocatorTypeRawValue, field 1 */
4797 str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
4798 r = add_inilocator_entry(hdb, str);
4799 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4801 /* msidbLocatorTypeRawValue, field 2 */
4802 str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
4803 r = add_inilocator_entry(hdb, str);
4804 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4806 /* msidbLocatorTypeRawValue, entire field */
4807 str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
4808 r = add_inilocator_entry(hdb, str);
4809 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4811 /* msidbLocatorTypeFile */
4812 str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4813 r = add_inilocator_entry(hdb, str);
4814 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4816 /* msidbLocatorTypeDirectory, file */
4817 str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
4818 r = add_inilocator_entry(hdb, str);
4819 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4821 /* msidbLocatorTypeDirectory, directory */
4822 str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
4823 r = add_inilocator_entry(hdb, str);
4824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4826 /* msidbLocatorTypeFile, file, no signature */
4827 str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4828 r = add_inilocator_entry(hdb, str);
4829 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4831 /* msidbLocatorTypeFile, dir, no signature */
4832 str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
4833 r = add_inilocator_entry(hdb, str);
4834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4836 /* msidbLocatorTypeFile, file does not exist */
4837 str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
4838 r = add_inilocator_entry(hdb, str);
4839 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4841 /* msidbLocatorTypeFile, signature with version */
4842 str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
4843 r = add_inilocator_entry(hdb, str);
4844 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4846 /* msidbLocatorTypeFile, signature with version, ver > max */
4847 str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
4848 r = add_inilocator_entry(hdb, str);
4849 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4851 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4852 str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
4853 r = add_inilocator_entry(hdb, str);
4854 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4856 r = create_signature_table(hdb);
4857 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4859 r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4862 r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4863 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4865 r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4866 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4868 r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4869 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4871 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4872 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4874 r = package_from_db(hdb, &hpkg);
4875 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4877 skip("Not enough rights to perform tests\n");
4880 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4882 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4884 r = MsiDoAction(hpkg, "AppSearch");
4885 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4888 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4889 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4890 ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
4893 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4894 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4895 ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
4898 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4899 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4900 ok(!lstrcmpA(prop, "keydata,field2"),
4901 "Expected \"keydata,field2\", got \"%s\"\n", prop);
4904 sprintf(path, "%s\\FileName1", CURR_DIR);
4905 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
4906 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4907 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4910 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4911 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4912 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4915 sprintf(path, "%s\\", CURR_DIR);
4916 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4917 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4918 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4921 sprintf(path, "%s\\", CURR_DIR);
4922 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4923 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4924 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4927 lstrcpyA(path, CURR_DIR);
4928 ptr = strrchr(path, '\\');
4930 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4932 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4935 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4936 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4937 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4942 sprintf(path, "%s\\FileName2.dll", CURR_DIR);
4943 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4944 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4945 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4948 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4949 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4950 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4953 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4954 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4955 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4956 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4959 MsiCloseHandle(hpkg);
4962 delete_win_ini("IniFile.ini");
4963 DeleteFileA("FileName1");
4964 DeleteFileA("FileName2.dll");
4965 DeleteFileA("FileName3.dll");
4966 DeleteFileA("FileName4.dll");
4967 DeleteFileA(msifile);
4971 * MSI AppSearch action on DrLocator table always returns absolute paths.
4972 * If a relative path was set, it returns the first absolute path that
4973 * matches or an empty string if it didn't find anything.
4974 * This helper function replicates this behaviour.
4976 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
4981 size = lstrlenA(relative);
4982 drives = GetLogicalDrives();
4983 lstrcpyA(absolute, "A:\\");
4984 for (i = 0; i < 26; absolute[0] = '\0', i++)
4986 if (!(drives & (1 << i)))
4989 absolute[0] = 'A' + i;
4990 if (GetDriveType(absolute) != DRIVE_FIXED)
4993 lstrcpynA(absolute + 3, relative, size + 1);
4994 attr = GetFileAttributesA(absolute);
4995 if (attr != INVALID_FILE_ATTRIBUTES &&
4996 (attr & FILE_ATTRIBUTE_DIRECTORY))
4998 if (absolute[3 + size - 1] != '\\')
4999 lstrcatA(absolute, "\\");
5006 static void test_appsearch_drlocator(void)
5008 MSIHANDLE hpkg, hdb;
5009 CHAR path[MAX_PATH];
5010 CHAR prop[MAX_PATH];
5017 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5020 DeleteFileA("test.dll");
5022 create_test_file("FileName1");
5023 CreateDirectoryA("one", NULL);
5024 CreateDirectoryA("one\\two", NULL);
5025 CreateDirectoryA("one\\two\\three", NULL);
5026 create_test_file("one\\two\\three\\FileName2");
5027 CreateDirectoryA("another", NULL);
5028 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5029 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5030 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5032 hdb = create_package_db();
5033 ok(hdb, "Expected a valid database handle\n");
5035 r = create_appsearch_table(hdb);
5036 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5038 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5039 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5041 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5044 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5047 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5048 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5050 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5053 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5056 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5057 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5059 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5060 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5062 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5063 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5065 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
5066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5068 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
5069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5071 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
5072 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5074 r = create_drlocator_table(hdb);
5075 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5077 /* no parent, full path, depth 0, signature */
5078 sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
5079 r = add_drlocator_entry(hdb, path);
5080 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5082 /* no parent, full path, depth 0, no signature */
5083 sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
5084 r = add_drlocator_entry(hdb, path);
5085 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5087 /* no parent, relative path, depth 0, no signature */
5088 sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
5089 r = add_drlocator_entry(hdb, path);
5090 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5092 /* no parent, full path, depth 2, signature */
5093 sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
5094 r = add_drlocator_entry(hdb, path);
5095 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5097 /* no parent, full path, depth 3, signature */
5098 sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
5099 r = add_drlocator_entry(hdb, path);
5100 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5102 /* no parent, full path, depth 1, signature is dir */
5103 sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
5104 r = add_drlocator_entry(hdb, path);
5105 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5107 /* parent is in DrLocator, relative path, depth 0, signature */
5108 sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5109 r = add_drlocator_entry(hdb, path);
5110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5112 /* no parent, full path, depth 0, signature w/ version */
5113 sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
5114 r = add_drlocator_entry(hdb, path);
5115 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5117 /* no parent, full path, depth 0, signature w/ version, ver > max */
5118 sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
5119 r = add_drlocator_entry(hdb, path);
5120 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5122 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5123 sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
5124 r = add_drlocator_entry(hdb, path);
5125 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5127 /* no parent, relative empty path, depth 0, no signature */
5128 sprintf(path, "'NewSignature11', '', '', 0");
5129 r = add_drlocator_entry(hdb, path);
5130 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5132 r = create_reglocator_table(hdb);
5133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5136 r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5137 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5139 /* parent is in RegLocator, no path, depth 0, no signature */
5140 sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
5141 r = add_drlocator_entry(hdb, path);
5142 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5144 r = create_signature_table(hdb);
5145 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5147 str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5148 r = add_signature_entry(hdb, str);
5149 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5151 str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5152 r = add_signature_entry(hdb, str);
5153 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5155 str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5156 r = add_signature_entry(hdb, str);
5157 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5159 str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5160 r = add_signature_entry(hdb, str);
5161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5163 str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5164 r = add_signature_entry(hdb, str);
5165 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5167 str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5168 r = add_signature_entry(hdb, str);
5169 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5171 str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5172 r = add_signature_entry(hdb, str);
5173 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5175 str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5176 r = add_signature_entry(hdb, str);
5177 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5179 r = package_from_db(hdb, &hpkg);
5180 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5182 skip("Not enough rights to perform tests\n");
5185 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5187 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5189 r = MsiDoAction(hpkg, "AppSearch");
5190 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5193 sprintf(path, "%s\\FileName1", CURR_DIR);
5194 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5196 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5199 sprintf(path, "%s\\", CURR_DIR);
5200 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5201 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5202 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5205 search_absolute_directory(path, CURR_DIR + 3);
5206 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5208 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5211 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5212 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5213 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5216 sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
5217 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5219 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5222 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5223 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5224 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5227 sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
5228 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5230 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5235 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
5236 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5237 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5238 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5241 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5243 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5246 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5248 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5252 search_absolute_directory(path, "");
5253 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5255 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5258 strcpy(path, "c:\\");
5259 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
5260 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5261 ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
5263 MsiCloseHandle(hpkg);
5266 DeleteFileA("FileName1");
5267 DeleteFileA("FileName3.dll");
5268 DeleteFileA("FileName4.dll");
5269 DeleteFileA("FileName5.dll");
5270 DeleteFileA("one\\two\\three\\FileName2");
5271 RemoveDirectoryA("one\\two\\three");
5272 RemoveDirectoryA("one\\two");
5273 RemoveDirectoryA("one");
5274 RemoveDirectoryA("another");
5275 DeleteFileA(msifile);
5278 static void test_featureparents(void)
5284 hdb = create_package_db();
5285 ok ( hdb, "failed to create package database\n" );
5287 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
5288 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
5290 r = create_feature_table( hdb );
5291 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
5293 r = create_component_table( hdb );
5294 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
5296 r = create_feature_components_table( hdb );
5297 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
5299 r = create_file_table( hdb );
5300 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
5302 /* msidbFeatureAttributesFavorLocal */
5303 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
5304 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5306 /* msidbFeatureAttributesFavorSource */
5307 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
5308 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5310 /* msidbFeatureAttributesFavorLocal */
5311 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
5312 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5314 /* msidbFeatureAttributesUIDisallowAbsent */
5315 r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
5316 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5318 /* disabled because of install level */
5319 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
5320 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5322 /* child feature of disabled feature */
5323 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5324 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5326 /* component of disabled feature (install level) */
5327 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5328 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5330 /* component of disabled child feature (install level) */
5331 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5332 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5334 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5335 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5336 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5338 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5339 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5340 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5342 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5343 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5344 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5346 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5347 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5348 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5350 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5351 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5352 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5354 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5355 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5356 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5358 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5359 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5360 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5362 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5363 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5364 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5366 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5367 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5368 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5370 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
5371 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5373 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
5374 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5376 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
5377 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5379 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
5380 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5382 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
5383 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5385 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
5386 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5388 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
5389 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5391 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
5392 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5394 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
5395 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5397 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
5398 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5400 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
5401 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5403 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
5404 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5406 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
5407 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5409 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
5410 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5412 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
5413 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5415 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
5416 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5418 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
5419 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5421 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5422 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5424 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5425 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5427 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5428 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5430 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5431 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5433 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5434 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5436 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5437 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5439 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5440 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5442 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5443 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5445 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5446 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5448 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5449 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5451 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5452 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5454 r = package_from_db( hdb, &hpkg );
5455 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5457 skip("Not enough rights to perform tests\n");
5458 DeleteFile(msifile);
5461 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5463 MsiCloseHandle( hdb );
5465 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5467 r = MsiDoAction( hpkg, "CostInitialize");
5468 ok( r == ERROR_SUCCESS, "cost init failed\n");
5470 r = MsiDoAction( hpkg, "FileCost");
5471 ok( r == ERROR_SUCCESS, "file cost failed\n");
5473 r = MsiDoAction( hpkg, "CostFinalize");
5474 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5476 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5477 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
5478 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5479 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5480 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5481 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5483 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5484 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5485 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5486 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5487 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5488 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5489 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5490 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5491 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5492 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5493 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5495 r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
5496 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5498 r = MsiSetFeatureState(hpkg, "lyra", INSTALLSTATE_ABSENT);
5499 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5501 r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
5502 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
5504 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5505 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
5506 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, 0 );
5507 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, 0 );
5508 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5509 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5511 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5512 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5513 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5514 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5515 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5516 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5517 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5518 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5519 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5520 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5521 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5523 MsiCloseHandle(hpkg);
5524 DeleteFileA(msifile);
5527 static void test_installprops(void)
5529 MSIHANDLE hpkg, hdb;
5530 CHAR path[MAX_PATH], buf[MAX_PATH];
5536 REGSAM access = KEY_ALL_ACCESS;
5538 INSTALLUILEVEL uilevel;
5541 access |= KEY_WOW64_64KEY;
5543 GetCurrentDirectory(MAX_PATH, path);
5544 lstrcat(path, "\\");
5545 lstrcat(path, msifile);
5547 uilevel = MsiSetInternalUI(INSTALLUILEVEL_BASIC|INSTALLUILEVEL_SOURCERESONLY, NULL);
5549 hdb = create_package_db();
5550 ok( hdb, "failed to create database\n");
5552 r = package_from_db(hdb, &hpkg);
5553 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5555 skip("Not enough rights to perform tests\n");
5556 MsiSetInternalUI(uilevel, NULL);
5557 DeleteFile(msifile);
5560 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5562 MsiCloseHandle(hdb);
5566 r = MsiGetProperty(hpkg, "UILevel", buf, &size);
5567 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5568 ok( !lstrcmp(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5570 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5574 r = MsiGetProperty(hpkg, "UILevel", buf, &size);
5575 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5576 ok( !lstrcmp(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5580 r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
5581 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5582 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5584 RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
5585 RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
5590 if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5594 RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
5599 r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
5600 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5601 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5606 if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5610 RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
5617 r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
5618 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5619 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5624 r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
5625 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5626 trace("VersionDatabase = %s\n", buf);
5630 r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
5631 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5632 trace("VersionMsi = %s\n", buf);
5636 r = MsiGetProperty(hpkg, "Date", buf, &size);
5637 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5638 trace("Date = %s\n", buf);
5642 r = MsiGetProperty(hpkg, "Time", buf, &size);
5643 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5644 trace("Time = %s\n", buf);
5648 r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
5649 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5650 trace("PackageCode = %s\n", buf);
5654 r = MsiGetProperty(hpkg, "ComputerName", buf, &size);
5655 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5656 trace("ComputerName = %s\n", buf);
5658 langid = GetUserDefaultLangID();
5659 sprintf(path, "%d", langid);
5663 r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
5664 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5665 ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
5667 res = GetSystemMetrics(SM_CXSCREEN);
5670 r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
5671 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5672 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5674 res = GetSystemMetrics(SM_CYSCREEN);
5677 r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
5678 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5679 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5681 if (pGetSystemInfo && pSHGetFolderPathA)
5683 pGetSystemInfo(&si);
5684 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
5688 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5689 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5690 ok(buf[0], "property not set\n");
5694 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5695 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5696 ok(buf[0], "property not set\n");
5700 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5701 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5702 ok(buf[0], "property not set\n");
5706 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5707 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5708 GetSystemDirectoryA(path, MAX_PATH);
5709 if (size) buf[size - 1] = 0;
5710 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5714 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5715 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5716 pGetSystemWow64DirectoryA(path, MAX_PATH);
5717 if (size) buf[size - 1] = 0;
5718 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5722 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
5723 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5724 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5725 if (size) buf[size - 1] = 0;
5726 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5730 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5731 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5732 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5733 if (size) buf[size - 1] = 0;
5734 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5738 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
5739 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5740 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5741 if (size) buf[size - 1] = 0;
5742 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5746 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5747 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5748 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5749 if (size) buf[size - 1] = 0;
5750 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5754 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5755 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5756 ok(buf[0], "property not set\n");
5758 else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
5764 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5765 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5766 ok(buf[0], "property not set\n");
5770 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5771 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5772 ok(!buf[0], "property set\n");
5776 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5777 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5778 ok(!buf[0], "property set\n");
5782 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5783 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5784 ok(!buf[0], "property set\n");
5788 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5789 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5790 GetSystemDirectoryA(path, MAX_PATH);
5791 if (size) buf[size - 1] = 0;
5792 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5796 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
5797 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5798 ok(!buf[0], "property set\n");
5802 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5803 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5804 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5805 if (size) buf[size - 1] = 0;
5806 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5810 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
5811 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5812 ok(!buf[0], "property set\n");
5816 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5817 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5818 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5819 if (size) buf[size - 1] = 0;
5820 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5824 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5825 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5826 ok(!buf[0], "property set\n");
5832 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5833 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5834 ok(buf[0], "property not set\n");
5838 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5839 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5840 ok(buf[0], "property not set\n");
5844 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5845 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5846 ok(buf[0], "property not set\n");
5850 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5851 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5852 GetSystemDirectoryA(path, MAX_PATH);
5853 if (size) buf[size - 1] = 0;
5854 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5858 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5859 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5860 pGetSystemWow64DirectoryA(path, MAX_PATH);
5861 if (size) buf[size - 1] = 0;
5862 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5866 r = MsiGetProperty(hpkg, "ProgramFilesFolder64", buf, &size);
5867 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5868 ok(!buf[0], "property set\n");
5872 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5873 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5874 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5875 if (size) buf[size - 1] = 0;
5876 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5880 r = MsiGetProperty(hpkg, "CommonFilesFolder64", buf, &size);
5881 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5882 ok(!buf[0], "property set\n");
5886 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5887 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5888 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5889 if (size) buf[size - 1] = 0;
5890 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5894 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5895 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5896 ok(buf[0], "property not set\n");
5903 MsiCloseHandle(hpkg);
5904 DeleteFile(msifile);
5905 MsiSetInternalUI(uilevel, NULL);
5908 static void test_launchconditions(void)
5914 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5916 hdb = create_package_db();
5917 ok( hdb, "failed to create package database\n" );
5919 r = create_launchcondition_table( hdb );
5920 ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
5922 r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
5923 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
5925 /* invalid condition */
5926 r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
5927 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
5929 r = package_from_db( hdb, &hpkg );
5930 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5932 skip("Not enough rights to perform tests\n");
5933 DeleteFile(msifile);
5936 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5938 MsiCloseHandle( hdb );
5940 r = MsiSetProperty( hpkg, "X", "1" );
5941 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5943 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5945 /* invalid conditions are ignored */
5946 r = MsiDoAction( hpkg, "LaunchConditions" );
5947 ok( r == ERROR_SUCCESS, "cost init failed\n" );
5949 /* verify LaunchConditions still does some verification */
5950 r = MsiSetProperty( hpkg, "X", "2" );
5951 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5953 r = MsiDoAction( hpkg, "LaunchConditions" );
5954 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
5956 MsiCloseHandle( hpkg );
5957 DeleteFile( msifile );
5960 static void test_ccpsearch(void)
5962 MSIHANDLE hdb, hpkg;
5963 CHAR prop[MAX_PATH];
5964 DWORD size = MAX_PATH;
5967 hdb = create_package_db();
5968 ok(hdb, "failed to create package database\n");
5970 r = create_ccpsearch_table(hdb);
5971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5973 r = add_ccpsearch_entry(hdb, "'CCP_random'");
5974 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5976 r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
5977 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5979 r = create_reglocator_table(hdb);
5980 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5982 r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
5983 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5985 r = create_drlocator_table(hdb);
5986 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5988 r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
5989 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5991 r = create_signature_table(hdb);
5992 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5994 r = package_from_db(hdb, &hpkg);
5995 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5997 skip("Not enough rights to perform tests\n");
5998 DeleteFile(msifile);
6001 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6003 MsiCloseHandle(hdb);
6005 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6007 r = MsiDoAction(hpkg, "CCPSearch");
6008 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6010 r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
6011 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6012 ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
6014 MsiCloseHandle(hpkg);
6015 DeleteFileA(msifile);
6018 static void test_complocator(void)
6020 MSIHANDLE hdb, hpkg;
6022 CHAR prop[MAX_PATH];
6023 CHAR expected[MAX_PATH];
6024 DWORD size = MAX_PATH;
6026 hdb = create_package_db();
6027 ok(hdb, "failed to create package database\n");
6029 r = create_appsearch_table(hdb);
6030 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6032 r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
6033 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6035 r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
6036 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6038 r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
6039 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6041 r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
6042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6044 r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
6045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6047 r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
6048 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6050 r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
6051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6053 r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
6054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6056 r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
6057 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6059 r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
6060 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6062 r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
6063 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6065 r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
6066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6068 r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
6069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6071 r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
6072 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6074 r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
6075 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6077 r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
6078 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6080 r = create_complocator_table(hdb);
6081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6083 r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6084 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6086 r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6087 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6089 r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6090 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6092 r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6093 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6095 r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6096 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6098 r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6099 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6101 r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6102 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6104 r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6105 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6107 r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6108 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6110 r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6111 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6113 r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6114 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6116 r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6117 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6119 r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6120 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6122 r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6123 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6125 r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6128 r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6129 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6131 r = create_signature_table(hdb);
6132 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6134 r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6135 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6137 r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6138 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6140 r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6141 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6143 r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6144 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6146 r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6147 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6149 r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6150 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6152 r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6153 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6155 r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6156 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6158 r = package_from_db(hdb, &hpkg);
6159 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6161 skip("Not enough rights to perform tests\n");
6162 DeleteFile(msifile);
6165 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6167 MsiCloseHandle(hdb);
6169 create_test_file("abelisaurus");
6170 create_test_file("bactrosaurus");
6171 create_test_file("camelotia");
6172 create_test_file("diclonius");
6173 create_test_file("echinodon");
6174 create_test_file("falcarius");
6175 create_test_file("gallimimus");
6176 create_test_file("hagryphus");
6177 CreateDirectoryA("iguanodon", NULL);
6178 CreateDirectoryA("jobaria", NULL);
6179 CreateDirectoryA("kakuru", NULL);
6180 CreateDirectoryA("labocania", NULL);
6181 CreateDirectoryA("megaraptor", NULL);
6182 CreateDirectoryA("neosodon", NULL);
6183 CreateDirectoryA("olorotitan", NULL);
6184 CreateDirectoryA("pantydraco", NULL);
6186 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
6187 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
6188 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
6189 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
6190 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
6191 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
6192 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
6193 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
6194 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
6195 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
6196 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
6197 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
6198 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
6199 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
6200 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
6201 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
6203 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6205 r = MsiDoAction(hpkg, "AppSearch");
6206 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6209 r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
6210 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6212 lstrcpyA(expected, CURR_DIR);
6213 lstrcatA(expected, "\\abelisaurus");
6214 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6215 "Expected %s or empty string, got %s\n", expected, prop);
6218 r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
6219 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6220 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6223 r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
6224 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6225 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6228 r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
6229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6230 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6233 r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
6234 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6236 lstrcpyA(expected, CURR_DIR);
6237 lstrcatA(expected, "\\");
6238 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6239 "Expected %s or empty string, got %s\n", expected, prop);
6242 r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
6243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6244 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6247 r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
6248 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6249 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6252 r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
6253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6254 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6257 r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
6258 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6259 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6262 r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
6263 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6264 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6267 r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
6268 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6269 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6272 r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
6273 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6274 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6277 r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
6278 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6280 lstrcpyA(expected, CURR_DIR);
6281 lstrcatA(expected, "\\");
6282 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6283 "Expected %s or empty string, got %s\n", expected, prop);
6286 r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
6287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6289 lstrcpyA(expected, CURR_DIR);
6290 lstrcatA(expected, "\\neosodon\\");
6291 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6292 "Expected %s or empty string, got %s\n", expected, prop);
6295 r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
6296 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6297 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6300 r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
6301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6302 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6304 MsiCloseHandle(hpkg);
6305 DeleteFileA("abelisaurus");
6306 DeleteFileA("bactrosaurus");
6307 DeleteFileA("camelotia");
6308 DeleteFileA("diclonius");
6309 DeleteFileA("echinodon");
6310 DeleteFileA("falcarius");
6311 DeleteFileA("gallimimus");
6312 DeleteFileA("hagryphus");
6313 RemoveDirectoryA("iguanodon");
6314 RemoveDirectoryA("jobaria");
6315 RemoveDirectoryA("kakuru");
6316 RemoveDirectoryA("labocania");
6317 RemoveDirectoryA("megaraptor");
6318 RemoveDirectoryA("neosodon");
6319 RemoveDirectoryA("olorotitan");
6320 RemoveDirectoryA("pantydraco");
6321 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6322 MSIINSTALLCONTEXT_MACHINE, NULL);
6323 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6324 MSIINSTALLCONTEXT_MACHINE, NULL);
6325 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6326 MSIINSTALLCONTEXT_MACHINE, NULL);
6327 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6328 MSIINSTALLCONTEXT_MACHINE, NULL);
6329 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6330 MSIINSTALLCONTEXT_MACHINE, NULL);
6331 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6332 MSIINSTALLCONTEXT_MACHINE, NULL);
6333 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6334 MSIINSTALLCONTEXT_MACHINE, NULL);
6335 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6336 MSIINSTALLCONTEXT_MACHINE, NULL);
6337 DeleteFileA(msifile);
6340 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
6345 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6346 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6348 r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
6349 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6351 r = MsiSummaryInfoPersist(summary);
6352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6354 MsiCloseHandle(summary);
6357 static void test_MsiGetSourcePath(void)
6359 MSIHANDLE hdb, hpkg;
6360 CHAR path[MAX_PATH];
6362 CHAR subsrc[MAX_PATH];
6363 CHAR sub2[MAX_PATH];
6367 lstrcpyA(cwd, CURR_DIR);
6368 lstrcatA(cwd, "\\");
6370 lstrcpyA(subsrc, cwd);
6371 lstrcatA(subsrc, "subsource");
6372 lstrcatA(subsrc, "\\");
6374 lstrcpyA(sub2, subsrc);
6375 lstrcatA(sub2, "sub2");
6376 lstrcatA(sub2, "\\");
6378 /* uncompressed source */
6380 hdb = create_package_db();
6381 ok( hdb, "failed to create database\n");
6383 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
6385 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
6386 ok(r == S_OK, "failed\n");
6388 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6389 ok(r == S_OK, "failed\n");
6391 r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
6392 ok(r == S_OK, "failed\n");
6394 r = MsiDatabaseCommit(hdb);
6395 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6397 r = package_from_db(hdb, &hpkg);
6398 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6400 skip("Not enough rights to perform tests\n");
6401 DeleteFile(msifile);
6404 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6406 MsiCloseHandle(hdb);
6408 /* invalid database handle */
6410 lstrcpyA(path, "kiwi");
6411 r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
6412 ok(r == ERROR_INVALID_HANDLE,
6413 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
6414 ok(!lstrcmpA(path, "kiwi"),
6415 "Expected path to be unchanged, got \"%s\"\n", path);
6416 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6420 lstrcpyA(path, "kiwi");
6421 r = MsiGetSourcePath(hpkg, NULL, path, &size);
6422 ok(r == ERROR_INVALID_PARAMETER,
6423 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6424 ok(!lstrcmpA(path, "kiwi"),
6425 "Expected path to be unchanged, got \"%s\"\n", path);
6426 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6428 /* empty szFolder */
6430 lstrcpyA(path, "kiwi");
6431 r = MsiGetSourcePath(hpkg, "", path, &size);
6432 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6433 ok(!lstrcmpA(path, "kiwi"),
6434 "Expected path to be unchanged, got \"%s\"\n", path);
6435 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6439 lstrcpyA(path, "kiwi");
6440 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6441 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6442 ok(!lstrcmpA(path, "kiwi"),
6443 "Expected path to be unchanged, got \"%s\"\n", path);
6444 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6447 lstrcpyA(path, "kiwi");
6448 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6449 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6450 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6451 ok(size == 0, "Expected 0, got %d\n", size);
6454 lstrcpyA(path, "kiwi");
6455 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6456 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6457 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6458 ok(size == 0, "Expected 0, got %d\n", size);
6462 lstrcpyA(path, "kiwi");
6463 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6464 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6465 ok(!lstrcmpA(path, "kiwi"),
6466 "Expected path to be unchanged, got \"%s\"\n", path);
6467 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6471 lstrcpyA(path, "kiwi");
6472 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6473 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6474 ok(!lstrcmpA(path, "kiwi"),
6475 "Expected path to be unchanged, got \"%s\"\n", path);
6476 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6478 /* source path does not exist, but the property exists */
6480 lstrcpyA(path, "kiwi");
6481 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6482 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6483 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6484 ok(size == 0, "Expected 0, got %d\n", size);
6487 lstrcpyA(path, "kiwi");
6488 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6489 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6490 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6491 ok(size == 0, "Expected 0, got %d\n", size);
6495 lstrcpyA(path, "kiwi");
6496 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6497 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6498 ok(!lstrcmpA(path, "kiwi"),
6499 "Expected path to be unchanged, got \"%s\"\n", path);
6500 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6504 lstrcpyA(path, "kiwi");
6505 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6506 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6507 ok(!lstrcmpA(path, "kiwi"),
6508 "Expected path to be unchanged, got \"%s\"\n", path);
6509 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6511 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6513 r = MsiDoAction(hpkg, "CostInitialize");
6514 ok(r == ERROR_SUCCESS, "cost init failed\n");
6516 /* try TARGETDIR after CostInitialize */
6518 lstrcpyA(path, "kiwi");
6519 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6520 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6521 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6522 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6524 /* try SourceDir after CostInitialize */
6526 lstrcpyA(path, "kiwi");
6527 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6528 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6529 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6530 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6532 /* try SOURCEDIR after CostInitialize */
6534 lstrcpyA(path, "kiwi");
6535 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6536 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6537 ok(!lstrcmpA(path, "kiwi"),
6538 "Expected path to be unchanged, got \"%s\"\n", path);
6539 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6541 /* source path does not exist, but the property exists */
6543 lstrcpyA(path, "kiwi");
6544 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6545 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6546 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6547 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6550 lstrcpyA(path, "kiwi");
6551 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6553 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6554 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6556 /* try SubDir after CostInitialize */
6558 lstrcpyA(path, "kiwi");
6559 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6560 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6561 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6562 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6564 /* try SubDir2 after CostInitialize */
6566 lstrcpyA(path, "kiwi");
6567 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6568 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6569 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6570 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6572 r = MsiDoAction(hpkg, "ResolveSource");
6573 ok(r == ERROR_SUCCESS, "file cost failed\n");
6575 /* try TARGETDIR after ResolveSource */
6577 lstrcpyA(path, "kiwi");
6578 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6579 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6580 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6581 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6583 /* try SourceDir after ResolveSource */
6585 lstrcpyA(path, "kiwi");
6586 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6587 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6588 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6589 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6591 /* try SOURCEDIR after ResolveSource */
6593 lstrcpyA(path, "kiwi");
6594 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6595 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6596 ok(!lstrcmpA(path, "kiwi"),
6597 "Expected path to be unchanged, got \"%s\"\n", path);
6598 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6600 /* source path does not exist, but the property exists */
6602 lstrcpyA(path, "kiwi");
6603 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6605 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6606 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6609 lstrcpyA(path, "kiwi");
6610 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6611 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6612 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6613 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6615 /* try SubDir after ResolveSource */
6617 lstrcpyA(path, "kiwi");
6618 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6619 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6620 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6621 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6623 /* try SubDir2 after ResolveSource */
6625 lstrcpyA(path, "kiwi");
6626 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6628 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6629 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6631 r = MsiDoAction(hpkg, "FileCost");
6632 ok(r == ERROR_SUCCESS, "file cost failed\n");
6634 /* try TARGETDIR after FileCost */
6636 lstrcpyA(path, "kiwi");
6637 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6638 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6639 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6640 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6642 /* try SourceDir after FileCost */
6644 lstrcpyA(path, "kiwi");
6645 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6646 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6647 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6648 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6650 /* try SOURCEDIR after FileCost */
6652 lstrcpyA(path, "kiwi");
6653 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6654 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6655 ok(!lstrcmpA(path, "kiwi"),
6656 "Expected path to be unchanged, got \"%s\"\n", path);
6657 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6659 /* source path does not exist, but the property exists */
6661 lstrcpyA(path, "kiwi");
6662 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6663 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6664 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6665 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6668 lstrcpyA(path, "kiwi");
6669 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6670 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6671 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6672 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6674 /* try SubDir after FileCost */
6676 lstrcpyA(path, "kiwi");
6677 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6679 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6680 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6682 /* try SubDir2 after FileCost */
6684 lstrcpyA(path, "kiwi");
6685 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6686 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6687 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6688 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6690 r = MsiDoAction(hpkg, "CostFinalize");
6691 ok(r == ERROR_SUCCESS, "file cost failed\n");
6693 /* try TARGETDIR after CostFinalize */
6695 lstrcpyA(path, "kiwi");
6696 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6697 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6698 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6699 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6701 /* try SourceDir after CostFinalize */
6703 lstrcpyA(path, "kiwi");
6704 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6705 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6706 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6707 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6709 /* try SOURCEDIR after CostFinalize */
6711 lstrcpyA(path, "kiwi");
6712 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6713 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6714 ok(!lstrcmpA(path, "kiwi"),
6715 "Expected path to be unchanged, got \"%s\"\n", path);
6716 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6718 /* source path does not exist, but the property exists */
6720 lstrcpyA(path, "kiwi");
6721 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6722 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6723 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6724 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6727 lstrcpyA(path, "kiwi");
6728 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6729 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6730 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6731 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6733 /* try SubDir after CostFinalize */
6735 lstrcpyA(path, "kiwi");
6736 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6737 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6738 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6739 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6741 /* try SubDir2 after CostFinalize */
6743 lstrcpyA(path, "kiwi");
6744 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6745 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6746 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6747 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6749 /* nonexistent directory */
6751 lstrcpyA(path, "kiwi");
6752 r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
6753 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6754 ok(!lstrcmpA(path, "kiwi"),
6755 "Expected path to be unchanged, got \"%s\"\n", path);
6756 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6758 /* NULL szPathBuf */
6760 r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
6761 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6762 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6764 /* NULL pcchPathBuf */
6765 lstrcpyA(path, "kiwi");
6766 r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
6767 ok(r == ERROR_INVALID_PARAMETER,
6768 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6769 ok(!lstrcmpA(path, "kiwi"),
6770 "Expected path to be unchanged, got \"%s\"\n", path);
6772 /* pcchPathBuf is 0 */
6774 lstrcpyA(path, "kiwi");
6775 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6776 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6777 ok(!lstrcmpA(path, "kiwi"),
6778 "Expected path to be unchanged, got \"%s\"\n", path);
6779 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6781 /* pcchPathBuf does not have room for NULL terminator */
6782 size = lstrlenA(cwd);
6783 lstrcpyA(path, "kiwi");
6784 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6785 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6786 ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
6787 "Expected path with no backslash, got \"%s\"\n", path);
6788 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6790 /* pcchPathBuf has room for NULL terminator */
6791 size = lstrlenA(cwd) + 1;
6792 lstrcpyA(path, "kiwi");
6793 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6795 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6796 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6798 /* remove property */
6799 r = MsiSetProperty(hpkg, "SourceDir", NULL);
6800 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6802 /* try SourceDir again */
6804 lstrcpyA(path, "kiwi");
6805 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6807 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6808 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6810 /* set property to a valid directory */
6811 r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
6812 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6814 /* try SOURCEDIR again */
6816 lstrcpyA(path, "kiwi");
6817 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6818 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6819 ok(!lstrcmpA(path, "kiwi"),
6820 "Expected path to be unchanged, got \"%s\"\n", path);
6821 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6823 MsiCloseHandle(hpkg);
6825 /* compressed source */
6827 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
6828 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6830 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
6832 r = package_from_db(hdb, &hpkg);
6833 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6837 lstrcpyA(path, "kiwi");
6838 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6839 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6840 ok(!lstrcmpA(path, "kiwi"),
6841 "Expected path to be unchanged, got \"%s\"\n", path);
6842 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6846 lstrcpyA(path, "kiwi");
6847 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6848 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6849 ok(!lstrcmpA(path, "kiwi"),
6850 "Expected path to be unchanged, got \"%s\"\n", path);
6851 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6855 lstrcpyA(path, "kiwi");
6856 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6857 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6858 ok(!lstrcmpA(path, "kiwi"),
6859 "Expected path to be unchanged, got \"%s\"\n", path);
6860 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6862 /* source path nor the property exist */
6864 lstrcpyA(path, "kiwi");
6865 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6866 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6867 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6868 ok(size == 0, "Expected 0, got %d\n", size);
6871 lstrcpyA(path, "kiwi");
6872 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6874 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6875 ok(size == 0, "Expected 0, got %d\n", size);
6879 lstrcpyA(path, "kiwi");
6880 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6881 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6882 ok(!lstrcmpA(path, "kiwi"),
6883 "Expected path to be unchanged, got \"%s\"\n", path);
6884 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6888 lstrcpyA(path, "kiwi");
6889 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6890 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6891 ok(!lstrcmpA(path, "kiwi"),
6892 "Expected path to be unchanged, got \"%s\"\n", path);
6893 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6895 r = MsiDoAction(hpkg, "CostInitialize");
6896 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6898 /* try TARGETDIR after CostInitialize */
6900 lstrcpyA(path, "kiwi");
6901 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6903 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6904 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6906 /* try SourceDir after CostInitialize */
6908 lstrcpyA(path, "kiwi");
6909 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6911 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6912 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6914 /* try SOURCEDIR after CostInitialize */
6916 lstrcpyA(path, "kiwi");
6917 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6920 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6921 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6922 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6925 /* source path does not exist, but the property exists */
6927 lstrcpyA(path, "kiwi");
6928 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6930 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6931 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6934 lstrcpyA(path, "kiwi");
6935 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6936 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6937 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6938 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6940 /* try SubDir after CostInitialize */
6942 lstrcpyA(path, "kiwi");
6943 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6944 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6945 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6946 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6948 /* try SubDir2 after CostInitialize */
6950 lstrcpyA(path, "kiwi");
6951 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6952 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6953 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6954 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6956 r = MsiDoAction(hpkg, "ResolveSource");
6957 ok(r == ERROR_SUCCESS, "file cost failed\n");
6959 /* try TARGETDIR after ResolveSource */
6961 lstrcpyA(path, "kiwi");
6962 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6963 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6964 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6965 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6967 /* try SourceDir after ResolveSource */
6969 lstrcpyA(path, "kiwi");
6970 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6972 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6973 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6975 /* try SOURCEDIR after ResolveSource */
6977 lstrcpyA(path, "kiwi");
6978 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6981 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6982 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6983 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6986 /* source path and the property exist */
6988 lstrcpyA(path, "kiwi");
6989 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6990 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6991 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6992 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6995 lstrcpyA(path, "kiwi");
6996 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6997 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6998 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6999 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7001 /* try SubDir after ResolveSource */
7003 lstrcpyA(path, "kiwi");
7004 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7005 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7006 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7007 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7009 /* try SubDir2 after ResolveSource */
7011 lstrcpyA(path, "kiwi");
7012 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7013 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7014 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7015 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7017 r = MsiDoAction(hpkg, "FileCost");
7018 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7020 /* try TARGETDIR after CostFinalize */
7022 lstrcpyA(path, "kiwi");
7023 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
7024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7025 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7026 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7028 /* try SourceDir after CostFinalize */
7030 lstrcpyA(path, "kiwi");
7031 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7033 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7034 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7036 /* try SOURCEDIR after CostFinalize */
7038 lstrcpyA(path, "kiwi");
7039 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7043 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7044 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7047 /* source path and the property exist */
7049 lstrcpyA(path, "kiwi");
7050 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7052 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7053 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7056 lstrcpyA(path, "kiwi");
7057 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7058 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7059 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7060 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7062 /* try SubDir after CostFinalize */
7064 lstrcpyA(path, "kiwi");
7065 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7067 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7068 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7070 /* try SubDir2 after CostFinalize */
7072 lstrcpyA(path, "kiwi");
7073 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7075 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7076 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7078 r = MsiDoAction(hpkg, "CostFinalize");
7079 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7081 /* try TARGETDIR after CostFinalize */
7083 lstrcpyA(path, "kiwi");
7084 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
7085 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7086 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7087 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7089 /* try SourceDir after CostFinalize */
7091 lstrcpyA(path, "kiwi");
7092 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7093 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7094 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7095 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7097 /* try SOURCEDIR after CostFinalize */
7099 lstrcpyA(path, "kiwi");
7100 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7103 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7104 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7105 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7108 /* source path and the property exist */
7110 lstrcpyA(path, "kiwi");
7111 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7112 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7113 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7114 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7117 lstrcpyA(path, "kiwi");
7118 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7120 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7121 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7123 /* try SubDir after CostFinalize */
7125 lstrcpyA(path, "kiwi");
7126 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7127 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7128 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7129 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7131 /* try SubDir2 after CostFinalize */
7133 lstrcpyA(path, "kiwi");
7134 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7135 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7136 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7137 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7139 MsiCloseHandle(hpkg);
7140 DeleteFile(msifile);
7143 static void test_shortlongsource(void)
7145 MSIHANDLE hdb, hpkg;
7146 CHAR path[MAX_PATH];
7148 CHAR subsrc[MAX_PATH];
7152 lstrcpyA(cwd, CURR_DIR);
7153 lstrcatA(cwd, "\\");
7155 lstrcpyA(subsrc, cwd);
7156 lstrcatA(subsrc, "long");
7157 lstrcatA(subsrc, "\\");
7159 /* long file names */
7161 hdb = create_package_db();
7162 ok( hdb, "failed to create database\n");
7164 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
7166 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7167 ok(r == S_OK, "failed\n");
7169 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
7170 ok(r == S_OK, "failed\n");
7172 /* CostInitialize:short */
7173 r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
7174 ok(r == S_OK, "failed\n");
7176 /* CostInitialize:long */
7177 r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
7178 ok(r == S_OK, "failed\n");
7180 /* FileCost:short */
7181 r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
7182 ok(r == S_OK, "failed\n");
7185 r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7186 ok(r == S_OK, "failed\n");
7188 /* CostFinalize:short */
7189 r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7190 ok(r == S_OK, "failed\n");
7192 /* CostFinalize:long */
7193 r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7194 ok(r == S_OK, "failed\n");
7196 MsiDatabaseCommit(hdb);
7198 r = package_from_db(hdb, &hpkg);
7199 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7201 skip("Not enough rights to perform tests\n");
7202 DeleteFile(msifile);
7205 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7207 MsiCloseHandle(hdb);
7209 CreateDirectoryA("one", NULL);
7210 CreateDirectoryA("four", NULL);
7212 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7214 r = MsiDoAction(hpkg, "CostInitialize");
7215 ok(r == ERROR_SUCCESS, "file cost failed\n");
7217 CreateDirectory("five", NULL);
7218 CreateDirectory("eight", NULL);
7220 r = MsiDoAction(hpkg, "FileCost");
7221 ok(r == ERROR_SUCCESS, "file cost failed\n");
7223 CreateDirectory("nine", NULL);
7224 CreateDirectory("twelve", NULL);
7226 r = MsiDoAction(hpkg, "CostFinalize");
7227 ok(r == ERROR_SUCCESS, "file cost failed\n");
7229 /* neither short nor long source directories exist */
7231 lstrcpyA(path, "kiwi");
7232 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7233 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7234 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7235 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7237 CreateDirectoryA("short", NULL);
7239 /* short source directory exists */
7241 lstrcpyA(path, "kiwi");
7242 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7244 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7245 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7247 CreateDirectoryA("long", NULL);
7249 /* both short and long source directories exist */
7251 lstrcpyA(path, "kiwi");
7252 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7254 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7255 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7257 lstrcpyA(subsrc, cwd);
7258 lstrcatA(subsrc, "two");
7259 lstrcatA(subsrc, "\\");
7261 /* short dir exists before CostInitialize */
7263 lstrcpyA(path, "kiwi");
7264 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7266 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7267 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7269 lstrcpyA(subsrc, cwd);
7270 lstrcatA(subsrc, "four");
7271 lstrcatA(subsrc, "\\");
7273 /* long dir exists before CostInitialize */
7275 lstrcpyA(path, "kiwi");
7276 r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
7277 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7278 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7279 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7281 lstrcpyA(subsrc, cwd);
7282 lstrcatA(subsrc, "six");
7283 lstrcatA(subsrc, "\\");
7285 /* short dir exists before FileCost */
7287 lstrcpyA(path, "kiwi");
7288 r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
7289 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7290 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7291 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7293 lstrcpyA(subsrc, cwd);
7294 lstrcatA(subsrc, "eight");
7295 lstrcatA(subsrc, "\\");
7297 /* long dir exists before FileCost */
7299 lstrcpyA(path, "kiwi");
7300 r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
7301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7302 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7303 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7305 lstrcpyA(subsrc, cwd);
7306 lstrcatA(subsrc, "ten");
7307 lstrcatA(subsrc, "\\");
7309 /* short dir exists before CostFinalize */
7311 lstrcpyA(path, "kiwi");
7312 r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
7313 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7314 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7315 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7317 lstrcpyA(subsrc, cwd);
7318 lstrcatA(subsrc, "twelve");
7319 lstrcatA(subsrc, "\\");
7321 /* long dir exists before CostFinalize */
7323 lstrcpyA(path, "kiwi");
7324 r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
7325 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7326 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7327 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7329 MsiCloseHandle(hpkg);
7330 RemoveDirectoryA("short");
7331 RemoveDirectoryA("long");
7332 RemoveDirectoryA("one");
7333 RemoveDirectoryA("four");
7334 RemoveDirectoryA("five");
7335 RemoveDirectoryA("eight");
7336 RemoveDirectoryA("nine");
7337 RemoveDirectoryA("twelve");
7339 /* short file names */
7341 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
7342 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7344 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
7346 r = package_from_db(hdb, &hpkg);
7347 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7349 MsiCloseHandle(hdb);
7351 CreateDirectoryA("one", NULL);
7352 CreateDirectoryA("four", NULL);
7354 r = MsiDoAction(hpkg, "CostInitialize");
7355 ok(r == ERROR_SUCCESS, "file cost failed\n");
7357 CreateDirectory("five", NULL);
7358 CreateDirectory("eight", NULL);
7360 r = MsiDoAction(hpkg, "FileCost");
7361 ok(r == ERROR_SUCCESS, "file cost failed\n");
7363 CreateDirectory("nine", NULL);
7364 CreateDirectory("twelve", NULL);
7366 r = MsiDoAction(hpkg, "CostFinalize");
7367 ok(r == ERROR_SUCCESS, "file cost failed\n");
7369 lstrcpyA(subsrc, cwd);
7370 lstrcatA(subsrc, "short");
7371 lstrcatA(subsrc, "\\");
7373 /* neither short nor long source directories exist */
7375 lstrcpyA(path, "kiwi");
7376 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7377 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7378 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7379 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7381 CreateDirectoryA("short", NULL);
7383 /* short source directory exists */
7385 lstrcpyA(path, "kiwi");
7386 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7387 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7388 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7389 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7391 CreateDirectoryA("long", NULL);
7393 /* both short and long source directories exist */
7395 lstrcpyA(path, "kiwi");
7396 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7397 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7398 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7399 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7401 lstrcpyA(subsrc, cwd);
7402 lstrcatA(subsrc, "one");
7403 lstrcatA(subsrc, "\\");
7405 /* short dir exists before CostInitialize */
7407 lstrcpyA(path, "kiwi");
7408 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7409 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7410 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7411 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7413 lstrcpyA(subsrc, cwd);
7414 lstrcatA(subsrc, "three");
7415 lstrcatA(subsrc, "\\");
7417 /* long dir exists before CostInitialize */
7419 lstrcpyA(path, "kiwi");
7420 r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
7421 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7422 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7423 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7425 lstrcpyA(subsrc, cwd);
7426 lstrcatA(subsrc, "five");
7427 lstrcatA(subsrc, "\\");
7429 /* short dir exists before FileCost */
7431 lstrcpyA(path, "kiwi");
7432 r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
7433 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7434 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7435 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7437 lstrcpyA(subsrc, cwd);
7438 lstrcatA(subsrc, "seven");
7439 lstrcatA(subsrc, "\\");
7441 /* long dir exists before FileCost */
7443 lstrcpyA(path, "kiwi");
7444 r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
7445 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7446 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7447 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7449 lstrcpyA(subsrc, cwd);
7450 lstrcatA(subsrc, "nine");
7451 lstrcatA(subsrc, "\\");
7453 /* short dir exists before CostFinalize */
7455 lstrcpyA(path, "kiwi");
7456 r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
7457 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7458 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7459 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7461 lstrcpyA(subsrc, cwd);
7462 lstrcatA(subsrc, "eleven");
7463 lstrcatA(subsrc, "\\");
7465 /* long dir exists before CostFinalize */
7467 lstrcpyA(path, "kiwi");
7468 r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
7469 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7470 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7471 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7473 MsiCloseHandle(hpkg);
7474 RemoveDirectoryA("short");
7475 RemoveDirectoryA("long");
7476 RemoveDirectoryA("one");
7477 RemoveDirectoryA("four");
7478 RemoveDirectoryA("five");
7479 RemoveDirectoryA("eight");
7480 RemoveDirectoryA("nine");
7481 RemoveDirectoryA("twelve");
7482 DeleteFileA(msifile);
7485 static void test_sourcedir(void)
7487 MSIHANDLE hdb, hpkg;
7489 CHAR path[MAX_PATH];
7491 CHAR subsrc[MAX_PATH];
7495 lstrcpyA(cwd, CURR_DIR);
7496 lstrcatA(cwd, "\\");
7498 lstrcpyA(subsrc, cwd);
7499 lstrcatA(subsrc, "long");
7500 lstrcatA(subsrc, "\\");
7502 hdb = create_package_db();
7503 ok( hdb, "failed to create database\n");
7505 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7506 ok(r == S_OK, "failed\n");
7508 sprintf(package, "#%u", hdb);
7509 r = MsiOpenPackage(package, &hpkg);
7510 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7512 skip("Not enough rights to perform tests\n");
7515 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7517 /* properties only */
7519 /* SourceDir prop */
7521 lstrcpyA(path, "kiwi");
7522 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7523 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7524 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7525 ok(size == 0, "Expected 0, got %d\n", size);
7527 /* SOURCEDIR prop */
7529 lstrcpyA(path, "kiwi");
7530 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7531 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7532 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7533 ok(size == 0, "Expected 0, got %d\n", size);
7535 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7537 r = MsiDoAction(hpkg, "CostInitialize");
7538 ok(r == ERROR_SUCCESS, "file cost failed\n");
7540 /* SourceDir after CostInitialize */
7542 lstrcpyA(path, "kiwi");
7543 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7544 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7545 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7546 ok(size == 0, "Expected 0, got %d\n", size);
7548 /* SOURCEDIR after CostInitialize */
7550 lstrcpyA(path, "kiwi");
7551 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7553 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7554 ok(size == 0, "Expected 0, got %d\n", size);
7556 r = MsiDoAction(hpkg, "FileCost");
7557 ok(r == ERROR_SUCCESS, "file cost failed\n");
7559 /* SourceDir after FileCost */
7561 lstrcpyA(path, "kiwi");
7562 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7563 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7564 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7565 ok(size == 0, "Expected 0, got %d\n", size);
7567 /* SOURCEDIR after FileCost */
7569 lstrcpyA(path, "kiwi");
7570 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7571 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7572 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7573 ok(size == 0, "Expected 0, got %d\n", size);
7575 r = MsiDoAction(hpkg, "CostFinalize");
7576 ok(r == ERROR_SUCCESS, "file cost failed\n");
7578 /* SourceDir after CostFinalize */
7580 lstrcpyA(path, "kiwi");
7581 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7583 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7584 ok(size == 0, "Expected 0, got %d\n", size);
7586 /* SOURCEDIR after CostFinalize */
7588 lstrcpyA(path, "kiwi");
7589 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7590 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7591 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7592 ok(size == 0, "Expected 0, got %d\n", size);
7595 lstrcpyA(path, "kiwi");
7596 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7597 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7598 ok(!lstrcmpA(path, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path);
7599 ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
7601 /* SOURCEDIR after calling MsiGetSourcePath */
7603 lstrcpyA(path, "kiwi");
7604 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7605 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7607 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7608 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7611 r = MsiDoAction(hpkg, "ResolveSource");
7612 ok(r == ERROR_SUCCESS, "file cost failed\n");
7614 /* SourceDir after ResolveSource */
7616 lstrcpyA(path, "kiwi");
7617 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7618 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7619 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7620 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7622 /* SOURCEDIR after ResolveSource */
7624 lstrcpyA(path, "kiwi");
7625 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7626 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7627 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7628 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7632 lstrcpyA(path, "kiwi");
7633 r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
7634 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7635 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7636 ok(size == 0, "Expected 0, got %d\n", size);
7638 MsiCloseHandle(hpkg);
7640 /* reset the package state */
7641 sprintf(package, "#%i", hdb);
7642 r = MsiOpenPackage(package, &hpkg);
7643 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7645 /* test how MsiGetSourcePath affects the properties */
7647 /* SourceDir prop */
7649 lstrcpyA(path, "kiwi");
7650 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7651 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7654 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7655 ok(size == 0, "Expected 0, got %d\n", size);
7659 lstrcpyA(path, "kiwi");
7660 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7661 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7662 ok(!lstrcmpA(path, "kiwi"),
7663 "Expected path to be unchanged, got \"%s\"\n", path);
7664 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7666 /* SourceDir after MsiGetSourcePath */
7668 lstrcpyA(path, "kiwi");
7669 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7670 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7673 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7674 ok(size == 0, "Expected 0, got %d\n", size);
7677 /* SOURCEDIR prop */
7679 lstrcpyA(path, "kiwi");
7680 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7681 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7684 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7685 ok(size == 0, "Expected 0, got %d\n", size);
7689 lstrcpyA(path, "kiwi");
7690 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7691 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7692 ok(!lstrcmpA(path, "kiwi"),
7693 "Expected path to be unchanged, got \"%s\"\n", path);
7694 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7696 /* SOURCEDIR prop after MsiGetSourcePath */
7698 lstrcpyA(path, "kiwi");
7699 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7700 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7703 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7704 ok(size == 0, "Expected 0, got %d\n", size);
7707 r = MsiDoAction(hpkg, "CostInitialize");
7708 ok(r == ERROR_SUCCESS, "file cost failed\n");
7710 /* SourceDir after CostInitialize */
7712 lstrcpyA(path, "kiwi");
7713 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7714 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7717 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7718 ok(size == 0, "Expected 0, got %d\n", size);
7722 lstrcpyA(path, "kiwi");
7723 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7724 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7725 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7726 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7728 /* SourceDir after MsiGetSourcePath */
7730 lstrcpyA(path, "kiwi");
7731 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7733 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7734 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7736 /* SOURCEDIR after CostInitialize */
7738 lstrcpyA(path, "kiwi");
7739 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7740 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7741 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7742 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7744 /* SOURCEDIR source path still does not exist */
7746 lstrcpyA(path, "kiwi");
7747 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7748 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7749 ok(!lstrcmpA(path, "kiwi"),
7750 "Expected path to be unchanged, got \"%s\"\n", path);
7751 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7753 r = MsiDoAction(hpkg, "FileCost");
7754 ok(r == ERROR_SUCCESS, "file cost failed\n");
7756 /* SourceDir after FileCost */
7758 lstrcpyA(path, "kiwi");
7759 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7761 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7762 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7764 /* SOURCEDIR after FileCost */
7766 lstrcpyA(path, "kiwi");
7767 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7768 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7769 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7770 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7772 /* SOURCEDIR source path still does not exist */
7774 lstrcpyA(path, "kiwi");
7775 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7776 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7777 ok(!lstrcmpA(path, "kiwi"),
7778 "Expected path to be unchanged, got \"%s\"\n", path);
7779 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7781 r = MsiDoAction(hpkg, "CostFinalize");
7782 ok(r == ERROR_SUCCESS, "file cost failed\n");
7784 /* SourceDir after CostFinalize */
7786 lstrcpyA(path, "kiwi");
7787 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7789 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7790 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7792 /* SOURCEDIR after CostFinalize */
7794 lstrcpyA(path, "kiwi");
7795 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7796 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7797 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7798 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7800 /* SOURCEDIR source path still does not exist */
7802 lstrcpyA(path, "kiwi");
7803 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7804 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7805 ok(!lstrcmpA(path, "kiwi"),
7806 "Expected path to be unchanged, got \"%s\"\n", path);
7807 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7809 r = MsiDoAction(hpkg, "ResolveSource");
7810 ok(r == ERROR_SUCCESS, "file cost failed\n");
7812 /* SourceDir after ResolveSource */
7814 lstrcpyA(path, "kiwi");
7815 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7816 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7817 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7818 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7820 /* SOURCEDIR after ResolveSource */
7822 lstrcpyA(path, "kiwi");
7823 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7825 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7826 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7828 /* SOURCEDIR source path still does not exist */
7830 lstrcpyA(path, "kiwi");
7831 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7832 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7833 ok(!lstrcmpA(path, "kiwi"),
7834 "Expected path to be unchanged, got \"%s\"\n", path);
7835 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7837 MsiCloseHandle(hpkg);
7840 MsiCloseHandle(hdb);
7841 DeleteFileA(msifile);
7851 static const struct access_res create[16] =
7853 { TRUE, ERROR_SUCCESS, TRUE },
7854 { TRUE, ERROR_SUCCESS, TRUE },
7855 { TRUE, ERROR_SUCCESS, FALSE },
7856 { TRUE, ERROR_SUCCESS, FALSE },
7857 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7858 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7859 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7860 { TRUE, ERROR_SUCCESS, FALSE },
7861 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7862 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7863 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7864 { TRUE, ERROR_SUCCESS, TRUE },
7865 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7866 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7867 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7868 { TRUE, ERROR_SUCCESS, TRUE }
7871 static const struct access_res create_commit[16] =
7873 { TRUE, ERROR_SUCCESS, TRUE },
7874 { TRUE, ERROR_SUCCESS, TRUE },
7875 { TRUE, ERROR_SUCCESS, FALSE },
7876 { TRUE, ERROR_SUCCESS, FALSE },
7877 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7878 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7879 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7880 { TRUE, ERROR_SUCCESS, FALSE },
7881 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7882 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7883 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7884 { TRUE, ERROR_SUCCESS, TRUE },
7885 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7886 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7887 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7888 { TRUE, ERROR_SUCCESS, TRUE }
7891 static const struct access_res create_close[16] =
7893 { TRUE, ERROR_SUCCESS, FALSE },
7894 { TRUE, ERROR_SUCCESS, FALSE },
7895 { TRUE, ERROR_SUCCESS, FALSE },
7896 { TRUE, ERROR_SUCCESS, FALSE },
7897 { TRUE, ERROR_SUCCESS, FALSE },
7898 { TRUE, ERROR_SUCCESS, FALSE },
7899 { TRUE, ERROR_SUCCESS, FALSE },
7900 { TRUE, ERROR_SUCCESS, FALSE },
7901 { TRUE, ERROR_SUCCESS, FALSE },
7902 { TRUE, ERROR_SUCCESS, FALSE },
7903 { TRUE, ERROR_SUCCESS, FALSE },
7904 { TRUE, ERROR_SUCCESS, FALSE },
7905 { TRUE, ERROR_SUCCESS, FALSE },
7906 { TRUE, ERROR_SUCCESS, FALSE },
7907 { TRUE, ERROR_SUCCESS, FALSE },
7908 { TRUE, ERROR_SUCCESS }
7911 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
7913 DWORD access = 0, share = 0;
7918 for (i = 0; i < 4; i++)
7920 if (i == 0) access = 0;
7921 if (i == 1) access = GENERIC_READ;
7922 if (i == 2) access = GENERIC_WRITE;
7923 if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
7925 for (j = 0; j < 4; j++)
7927 if (ares[idx].ignore)
7930 if (j == 0) share = 0;
7931 if (j == 1) share = FILE_SHARE_READ;
7932 if (j == 2) share = FILE_SHARE_WRITE;
7933 if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
7935 SetLastError(0xdeadbeef);
7936 hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
7937 FILE_ATTRIBUTE_NORMAL, 0);
7938 lasterr = GetLastError();
7940 ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
7941 "(%d, handle, %d): Expected %d, got %d\n",
7942 line, idx, ares[idx].gothandle,
7943 (hfile != INVALID_HANDLE_VALUE));
7945 ok(lasterr == ares[idx].lasterr, "(%d, lasterr, %d): Expected %d, got %d\n",
7946 line, idx, ares[idx].lasterr, lasterr);
7954 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
7956 static void test_access(void)
7961 r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
7962 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7964 test_file_access(msifile, create);
7966 r = MsiDatabaseCommit(hdb);
7967 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7969 test_file_access(msifile, create_commit);
7970 MsiCloseHandle(hdb);
7972 test_file_access(msifile, create_close);
7973 DeleteFileA(msifile);
7975 r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
7976 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7978 test_file_access(msifile, create);
7980 r = MsiDatabaseCommit(hdb);
7981 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7983 test_file_access(msifile, create_commit);
7984 MsiCloseHandle(hdb);
7986 test_file_access(msifile, create_close);
7987 DeleteFileA(msifile);
7990 static void test_emptypackage(void)
7992 MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
7993 MSIHANDLE hview = 0, hrec = 0;
7994 MSICONDITION condition;
7995 CHAR buffer[MAX_PATH];
7999 r = MsiOpenPackageA("", &hpkg);
8000 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8002 skip("Not enough rights to perform tests\n");
8007 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8010 hdb = MsiGetActiveDatabase(hpkg);
8013 ok(hdb != 0, "Expected a valid database handle\n");
8016 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
8019 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8021 r = MsiViewExecute(hview, 0);
8024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8027 r = MsiViewFetch(hview, &hrec);
8030 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8035 r = MsiRecordGetString(hrec, 1, buffer, &size);
8038 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8039 ok(!lstrcmpA(buffer, "_Property"),
8040 "Expected \"_Property\", got \"%s\"\n", buffer);
8043 MsiCloseHandle(hrec);
8045 r = MsiViewFetch(hview, &hrec);
8048 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8052 r = MsiRecordGetString(hrec, 1, buffer, &size);
8055 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8056 ok(!lstrcmpA(buffer, "#_FolderCache"),
8057 "Expected \"_Property\", got \"%s\"\n", buffer);
8060 MsiCloseHandle(hrec);
8061 MsiViewClose(hview);
8062 MsiCloseHandle(hview);
8064 condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
8067 ok(condition == MSICONDITION_FALSE,
8068 "Expected MSICONDITION_FALSE, got %d\n", condition);
8071 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
8074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8076 r = MsiViewExecute(hview, 0);
8079 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8082 /* _Property table is not empty */
8083 r = MsiViewFetch(hview, &hrec);
8086 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8089 MsiCloseHandle(hrec);
8090 MsiViewClose(hview);
8091 MsiCloseHandle(hview);
8093 condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
8096 ok(condition == MSICONDITION_FALSE,
8097 "Expected MSICONDITION_FALSE, got %d\n", condition);
8100 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
8103 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8105 r = MsiViewExecute(hview, 0);
8108 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8111 /* #_FolderCache is not empty */
8112 r = MsiViewFetch(hview, &hrec);
8115 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8118 MsiCloseHandle(hrec);
8119 MsiViewClose(hview);
8120 MsiCloseHandle(hview);
8122 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
8125 ok(r == ERROR_BAD_QUERY_SYNTAX,
8126 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8129 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
8132 ok(r == ERROR_BAD_QUERY_SYNTAX,
8133 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8136 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
8139 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
8140 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
8143 MsiCloseHandle(hsuminfo);
8145 r = MsiDatabaseCommit(hdb);
8148 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8151 MsiCloseHandle(hdb);
8152 MsiCloseHandle(hpkg);
8155 static void test_MsiGetProductProperty(void)
8157 MSIHANDLE hprod, hdb;
8159 CHAR path[MAX_PATH];
8160 CHAR query[MAX_PATH];
8161 CHAR keypath[MAX_PATH*2];
8162 CHAR prodcode[MAX_PATH];
8163 CHAR prod_squashed[MAX_PATH];
8164 HKEY prodkey, userkey, props;
8168 REGSAM access = KEY_ALL_ACCESS;
8170 GetCurrentDirectoryA(MAX_PATH, path);
8171 lstrcatA(path, "\\");
8173 create_test_guid(prodcode, prod_squashed);
8176 access |= KEY_WOW64_64KEY;
8178 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
8179 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8181 r = MsiDatabaseCommit(hdb);
8182 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8184 r = set_summary_info(hdb);
8185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8188 "CREATE TABLE `Directory` ( "
8189 "`Directory` CHAR(255) NOT NULL, "
8190 "`Directory_Parent` CHAR(255), "
8191 "`DefaultDir` CHAR(255) NOT NULL "
8192 "PRIMARY KEY `Directory`)");
8193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8196 "CREATE TABLE `Property` ( "
8197 "`Property` CHAR(72) NOT NULL, "
8198 "`Value` CHAR(255) "
8199 "PRIMARY KEY `Property`)");
8200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8202 sprintf(query, "INSERT INTO `Property` "
8203 "(`Property`, `Value`) "
8204 "VALUES( 'ProductCode', '%s' )", prodcode);
8205 r = run_query(hdb, query);
8206 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8208 r = MsiDatabaseCommit(hdb);
8209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8211 MsiCloseHandle(hdb);
8213 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8214 lstrcatA(keypath, prod_squashed);
8216 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8217 if (res == ERROR_ACCESS_DENIED)
8219 skip("Not enough rights to perform tests\n");
8220 DeleteFile(msifile);
8223 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8225 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8226 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8227 lstrcatA(keypath, prod_squashed);
8229 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
8230 if (res == ERROR_ACCESS_DENIED)
8232 skip("Not enough rights to perform tests\n");
8233 RegDeleteKeyA(prodkey, "");
8234 RegCloseKey(prodkey);
8237 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8239 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8240 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8242 lstrcpyA(val, path);
8243 lstrcatA(val, "\\");
8244 lstrcatA(val, msifile);
8245 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8246 (const BYTE *)val, lstrlenA(val) + 1);
8247 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8250 r = MsiOpenProductA(prodcode, &hprod);
8251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8252 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
8254 /* hProduct is invalid */
8256 lstrcpyA(val, "apple");
8257 r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
8258 ok(r == ERROR_INVALID_HANDLE,
8259 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8260 ok(!lstrcmpA(val, "apple"),
8261 "Expected val to be unchanged, got \"%s\"\n", val);
8262 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8264 /* szProperty is NULL */
8266 lstrcpyA(val, "apple");
8267 r = MsiGetProductPropertyA(hprod, NULL, val, &size);
8268 ok(r == ERROR_INVALID_PARAMETER,
8269 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8270 ok(!lstrcmpA(val, "apple"),
8271 "Expected val to be unchanged, got \"%s\"\n", val);
8272 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8274 /* szProperty is empty */
8276 lstrcpyA(val, "apple");
8277 r = MsiGetProductPropertyA(hprod, "", val, &size);
8278 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8279 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8280 ok(size == 0, "Expected 0, got %d\n", size);
8282 /* get the property */
8284 lstrcpyA(val, "apple");
8285 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8287 ok(!lstrcmpA(val, prodcode),
8288 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8289 ok(size == lstrlenA(prodcode),
8290 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8292 /* lpValueBuf is NULL */
8294 r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
8295 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8296 ok(size == lstrlenA(prodcode),
8297 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8299 /* pcchValueBuf is NULL */
8300 lstrcpyA(val, "apple");
8301 r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
8302 ok(r == ERROR_INVALID_PARAMETER,
8303 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8304 ok(!lstrcmpA(val, "apple"),
8305 "Expected val to be unchanged, got \"%s\"\n", val);
8306 ok(size == lstrlenA(prodcode),
8307 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8309 /* pcchValueBuf is too small */
8311 lstrcpyA(val, "apple");
8312 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8313 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8314 ok(!strncmp(val, prodcode, 3),
8315 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
8316 ok(size == lstrlenA(prodcode),
8317 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8319 /* pcchValueBuf does not leave room for NULL terminator */
8320 size = lstrlenA(prodcode);
8321 lstrcpyA(val, "apple");
8322 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8323 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8324 ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
8325 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
8326 ok(size == lstrlenA(prodcode),
8327 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8329 /* pcchValueBuf has enough room for NULL terminator */
8330 size = lstrlenA(prodcode) + 1;
8331 lstrcpyA(val, "apple");
8332 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8334 ok(!lstrcmpA(val, prodcode),
8335 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8336 ok(size == lstrlenA(prodcode),
8337 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8339 /* nonexistent property */
8341 lstrcpyA(val, "apple");
8342 r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
8343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8344 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8345 ok(size == 0, "Expected 0, got %d\n", size);
8347 r = MsiSetPropertyA(hprod, "NewProperty", "value");
8348 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8350 /* non-product property set */
8352 lstrcpyA(val, "apple");
8353 r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
8354 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8355 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8356 ok(size == 0, "Expected 0, got %d\n", size);
8358 r = MsiSetPropertyA(hprod, "ProductCode", "value");
8359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8361 /* non-product property that is also a product property set */
8363 lstrcpyA(val, "apple");
8364 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8366 ok(!lstrcmpA(val, prodcode),
8367 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8368 ok(size == lstrlenA(prodcode),
8369 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8371 MsiCloseHandle(hprod);
8373 RegDeleteValueA(props, "LocalPackage");
8374 delete_key(props, "", access);
8376 delete_key(userkey, "", access);
8377 RegCloseKey(userkey);
8378 delete_key(prodkey, "", access);
8379 RegCloseKey(prodkey);
8380 DeleteFileA(msifile);
8383 static void test_MsiSetProperty(void)
8385 MSIHANDLE hpkg, hdb, hrec;
8391 r = package_from_db(create_package_db(), &hpkg);
8392 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8394 skip("Not enough rights to perform tests\n");
8395 DeleteFile(msifile);
8398 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
8400 /* invalid hInstall */
8401 r = MsiSetPropertyA(0, "Prop", "Val");
8402 ok(r == ERROR_INVALID_HANDLE,
8403 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8405 /* invalid hInstall */
8406 r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8407 ok(r == ERROR_INVALID_HANDLE,
8408 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8410 /* szName is NULL */
8411 r = MsiSetPropertyA(hpkg, NULL, "Val");
8412 ok(r == ERROR_INVALID_PARAMETER,
8413 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8415 /* both szName and szValue are NULL */
8416 r = MsiSetPropertyA(hpkg, NULL, NULL);
8417 ok(r == ERROR_INVALID_PARAMETER,
8418 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8420 /* szName is empty */
8421 r = MsiSetPropertyA(hpkg, "", "Val");
8422 ok(r == ERROR_FUNCTION_FAILED,
8423 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8425 /* szName is empty and szValue is NULL */
8426 r = MsiSetPropertyA(hpkg, "", NULL);
8427 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8429 /* set a property */
8430 r = MsiSetPropertyA(hpkg, "Prop", "Val");
8431 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8433 /* get the property */
8435 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8436 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8437 ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
8438 ok(size == 3, "Expected 3, got %d\n", size);
8440 /* update the property */
8441 r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
8442 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8444 /* get the property */
8446 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8447 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8448 ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
8449 ok(size == 4, "Expected 4, got %d\n", size);
8451 hdb = MsiGetActiveDatabase(hpkg);
8452 ok(hdb != 0, "Expected a valid database handle\n");
8454 /* set prop is not in the _Property table */
8455 query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8456 r = do_query(hdb, query, &hrec);
8457 ok(r == ERROR_BAD_QUERY_SYNTAX,
8458 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8460 /* set prop is not in the Property table */
8461 query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8462 r = do_query(hdb, query, &hrec);
8463 ok(r == ERROR_BAD_QUERY_SYNTAX,
8464 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8466 MsiCloseHandle(hdb);
8468 /* szValue is an empty string */
8469 r = MsiSetPropertyA(hpkg, "Prop", "");
8470 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8472 /* try to get the property */
8474 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8475 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8476 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8477 ok(size == 0, "Expected 0, got %d\n", size);
8479 /* reset the property */
8480 r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
8481 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8483 /* delete the property */
8484 r = MsiSetPropertyA(hpkg, "Prop", NULL);
8485 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8487 /* try to get the property */
8489 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8490 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8491 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8492 ok(size == 0, "Expected 0, got %d\n", size);
8494 MsiCloseHandle(hpkg);
8495 DeleteFileA(msifile);
8498 static void test_MsiApplyMultiplePatches(void)
8500 UINT r, type = GetDriveType(NULL);
8502 if (!pMsiApplyMultiplePatchesA) {
8503 win_skip("MsiApplyMultiplePatchesA not found\n");
8507 r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
8508 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8510 r = pMsiApplyMultiplePatchesA("", NULL, NULL);
8511 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8513 r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
8514 if (type == DRIVE_FIXED)
8515 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8517 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8519 r = pMsiApplyMultiplePatchesA(" ;", NULL, NULL);
8520 if (type == DRIVE_FIXED)
8521 todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
8523 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8525 r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
8526 if (type == DRIVE_FIXED)
8527 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8529 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8531 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
8532 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8534 r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
8535 if (type == DRIVE_FIXED)
8536 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8538 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8540 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
8541 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8543 r = pMsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL, NULL);
8544 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8547 static void test_MsiApplyPatch(void)
8551 r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
8552 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8554 r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
8555 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8558 static void test_MsiEnumComponentCosts(void)
8560 MSIHANDLE hdb, hpkg;
8561 char package[12], drive[3];
8566 hdb = create_package_db();
8567 ok( hdb, "failed to create database\n" );
8569 r = create_property_table( hdb );
8570 ok( r == ERROR_SUCCESS, "cannot create Property table %u\n", r );
8572 r = add_property_entry( hdb, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8573 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8575 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
8576 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8578 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
8579 ok( r == ERROR_SUCCESS, "failed to add directory entry %u\n" , r );
8581 r = create_media_table( hdb );
8582 ok( r == ERROR_SUCCESS, "cannot create Media table %u\n", r );
8584 r = add_media_entry( hdb, "'1', '2', 'cabinet', '', '', ''");
8585 ok( r == ERROR_SUCCESS, "cannot add media entry %u\n", r );
8587 r = create_file_table( hdb );
8588 ok( r == ERROR_SUCCESS, "cannot create File table %u\n", r );
8590 r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8591 ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
8593 r = create_component_table( hdb );
8594 ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
8596 r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8597 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8599 r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8600 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8602 r = create_feature_table( hdb );
8603 ok( r == ERROR_SUCCESS, "cannot create Feature table %u\n", r );
8605 r = add_feature_entry( hdb, "'one', '', '', '', 0, 1, '', 0" );
8606 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8608 r = add_feature_entry( hdb, "'two', '', '', '', 0, 1, '', 0" );
8609 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8611 r = create_feature_components_table( hdb );
8612 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table %u\n", r );
8614 r = add_feature_components_entry( hdb, "'one', 'one'" );
8615 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8617 r = add_feature_components_entry( hdb, "'two', 'two'" );
8618 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8620 r = create_install_execute_sequence_table( hdb );
8621 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table %u\n", r );
8623 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
8624 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8626 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
8627 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8629 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
8630 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8632 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1100'" );
8633 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8635 MsiDatabaseCommit( hdb );
8637 sprintf( package, "#%u", hdb );
8638 r = MsiOpenPackageA( package, &hpkg );
8639 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8641 skip("Not enough rights to perform tests\n");
8644 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8646 r = MsiEnumComponentCostsA( 0, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8647 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8649 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8650 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8652 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8653 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8655 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8656 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8658 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8659 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8661 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, NULL, NULL, NULL );
8662 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8664 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, NULL, NULL, NULL );
8665 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8667 len = sizeof(drive);
8668 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, NULL, NULL );
8669 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8671 len = sizeof(drive);
8672 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, NULL );
8673 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8675 len = sizeof(drive);
8676 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8677 todo_wine ok( r == ERROR_INVALID_HANDLE_STATE, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r );
8679 len = sizeof(drive);
8680 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, &len, &cost, &temp );
8681 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8683 MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );
8685 r = MsiDoAction( hpkg, "CostInitialize" );
8686 ok( r == ERROR_SUCCESS, "CostInitialize failed %u\n", r );
8688 r = MsiDoAction( hpkg, "FileCost" );
8689 ok( r == ERROR_SUCCESS, "FileCost failed %u\n", r );
8691 len = sizeof(drive);
8692 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8693 ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8695 r = MsiDoAction( hpkg, "CostFinalize" );
8696 ok( r == ERROR_SUCCESS, "CostFinalize failed %u\n", r );
8698 /* contrary to what msdn says InstallValidate must be called too */
8699 len = sizeof(drive);
8700 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8701 todo_wine ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8703 r = MsiDoAction( hpkg, "InstallValidate" );
8704 ok( r == ERROR_SUCCESS, "InstallValidate failed %u\n", r );
8707 r = MsiEnumComponentCostsA( hpkg, "three", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8708 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
8711 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8712 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8713 ok( len == 2, "expected len == 2, got %u\n", len );
8716 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8717 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8718 ok( len == 2, "expected len == 2, got %u\n", len );
8721 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8722 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8723 ok( len == 2, "expected len == 2, got %u\n", len );
8725 /* install state doesn't seem to matter */
8726 len = sizeof(drive);
8727 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8728 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8730 len = sizeof(drive);
8731 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_ABSENT, drive, &len, &cost, &temp );
8732 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8734 len = sizeof(drive);
8735 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_SOURCE, drive, &len, &cost, &temp );
8736 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8738 len = sizeof(drive);
8740 cost = temp = 0xdead;
8741 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8742 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8743 ok( len == 2, "expected len == 2, got %u\n", len );
8744 ok( drive[0], "expected a drive\n" );
8745 ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
8746 ok( !temp, "expected temp == 0, got %d\n", temp );
8748 len = sizeof(drive);
8750 cost = temp = 0xdead;
8751 r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8752 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8753 ok( len == 2, "expected len == 2, got %u\n", len );
8754 ok( drive[0], "expected a drive\n" );
8755 ok( !cost, "expected cost == 0, got %d\n", cost );
8756 ok( !temp, "expected temp == 0, got %d\n", temp );
8758 len = sizeof(drive);
8760 cost = temp = 0xdead;
8761 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8762 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8763 ok( len == 2, "expected len == 2, got %u\n", len );
8764 ok( drive[0], "expected a drive\n" );
8765 ok( !cost, "expected cost == 0, got %d\n", cost );
8766 ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
8768 /* increased index */
8769 len = sizeof(drive);
8770 r = MsiEnumComponentCostsA( hpkg, "one", 1, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8771 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8773 len = sizeof(drive);
8774 r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8775 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8777 MsiCloseHandle( hpkg );
8779 MsiCloseHandle( hdb );
8780 DeleteFileA( msifile );
8783 static void test_MsiDatabaseCommit(void)
8786 MSIHANDLE hdb, hpkg = 0;
8787 char buf[32], package[12];
8790 hdb = create_package_db();
8791 ok( hdb, "failed to create database\n" );
8793 r = create_property_table( hdb );
8794 ok( r == ERROR_SUCCESS, "can't create Property table %u\n", r );
8796 sprintf( package, "#%u", hdb );
8797 r = MsiOpenPackage( package, &hpkg );
8798 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8800 skip("Not enough rights to perform tests\n");
8803 ok( r == ERROR_SUCCESS, "got %u\n", r );
8805 r = MsiSetPropertyA( hpkg, "PROP", "value" );
8806 ok( r == ERROR_SUCCESS, "got %u\n", r );
8810 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8811 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8812 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8814 r = MsiDatabaseCommit( hdb );
8815 ok( r == ERROR_SUCCESS, "MsiDatabaseCommit returned %u\n", r );
8819 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8820 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8821 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8823 MsiCloseHandle( hpkg );
8825 MsiCloseHandle( hdb );
8826 DeleteFileA( msifile );
8831 STATEMGRSTATUS status;
8834 init_functionpointers();
8836 if (pIsWow64Process)
8837 pIsWow64Process(GetCurrentProcess(), &is_wow64);
8839 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
8841 /* Create a restore point ourselves so we circumvent the multitude of restore points
8842 * that would have been created by all the installation and removal tests.
8844 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
8845 * creation of restore points.
8847 if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
8849 memset(&status, 0, sizeof(status));
8850 ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
8853 test_createpackage();
8855 test_gettargetpath_bad();
8856 test_settargetpath();
8858 test_property_table();
8861 test_formatrecord2();
8866 test_appsearch_complocator();
8867 test_appsearch_reglocator();
8868 test_appsearch_inilocator();
8869 test_appsearch_drlocator();
8870 test_featureparents();
8871 test_installprops();
8872 test_launchconditions();
8875 test_MsiGetSourcePath();
8876 test_shortlongsource();
8879 test_emptypackage();
8880 test_MsiGetProductProperty();
8881 test_MsiSetProperty();
8882 test_MsiApplyMultiplePatches();
8883 test_MsiApplyPatch();
8884 test_MsiEnumComponentCosts();
8885 test_MsiDatabaseCommit();
8887 if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
8889 ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
8891 remove_restore_point(status.llSequenceNumber);