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 #define make_add_entry(type, qtext) \
597 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
599 char insert[] = qtext; \
602 sz = strlen(values) + sizeof insert; \
603 query = HeapAlloc(GetProcessHeap(),0,sz); \
604 sprintf(query,insert,values); \
605 r = run_query( hdb, query ); \
606 HeapFree(GetProcessHeap(), 0, query); \
610 make_add_entry(component,
611 "INSERT INTO `Component` "
612 "(`Component`, `ComponentId`, `Directory_`, "
613 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
615 make_add_entry(directory,
616 "INSERT INTO `Directory` "
617 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
619 make_add_entry(feature,
620 "INSERT INTO `Feature` "
621 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
622 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
624 make_add_entry(feature_components,
625 "INSERT INTO `FeatureComponents` "
626 "(`Feature_`, `Component_`) VALUES( %s )")
629 "INSERT INTO `File` "
630 "(`File`, `Component_`, `FileName`, `FileSize`, "
631 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
633 make_add_entry(appsearch,
634 "INSERT INTO `AppSearch` "
635 "(`Property`, `Signature_`) VALUES( %s )")
637 make_add_entry(signature,
638 "INSERT INTO `Signature` "
639 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
640 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
643 make_add_entry(launchcondition,
644 "INSERT INTO `LaunchCondition` "
645 "(`Condition`, `Description`) VALUES( %s )")
647 make_add_entry(property,
648 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
650 make_add_entry(install_execute_sequence,
651 "INSERT INTO `InstallExecuteSequence` "
652 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
654 make_add_entry(media,
655 "INSERT INTO `Media` "
656 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
657 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
659 make_add_entry(ccpsearch,
660 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
662 make_add_entry(drlocator,
663 "INSERT INTO `DrLocator` "
664 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
666 make_add_entry(complocator,
667 "INSERT INTO `CompLocator` "
668 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
670 make_add_entry(inilocator,
671 "INSERT INTO `IniLocator` "
672 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
675 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
676 const char *name, UINT type )
678 const char insert[] =
679 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
680 "VALUES( '%s', %u, '%s', '%s', %u )";
684 sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
685 query = HeapAlloc( GetProcessHeap(), 0, sz );
686 sprintf( query, insert, sig, root, path, name, type );
687 r = run_query( hdb, query );
688 HeapFree( GetProcessHeap(), 0, query );
692 static UINT set_summary_info(MSIHANDLE hdb)
697 /* build summary info */
698 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
699 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
701 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
702 "Installation Database");
703 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
705 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
706 "Installation Database");
707 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
709 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
711 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
713 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
715 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
717 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
718 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
719 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
721 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
722 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
724 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
725 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
727 res = MsiSummaryInfoPersist(suminfo);
728 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
730 res = MsiCloseHandle( suminfo);
731 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
737 static MSIHANDLE create_package_db(void)
744 /* create an empty database */
745 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
746 ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
747 if( res != ERROR_SUCCESS )
750 res = MsiDatabaseCommit( hdb );
751 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
753 res = set_summary_info(hdb);
754 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
756 res = run_query( hdb,
757 "CREATE TABLE `Directory` ( "
758 "`Directory` CHAR(255) NOT NULL, "
759 "`Directory_Parent` CHAR(255), "
760 "`DefaultDir` CHAR(255) NOT NULL "
761 "PRIMARY KEY `Directory`)" );
762 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
767 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
773 sprintf(szPackage, "#%u", hdb);
774 res = MsiOpenPackage(szPackage, &hPackage);
775 if (res != ERROR_SUCCESS)
781 res = MsiCloseHandle(hdb);
782 if (res != ERROR_SUCCESS)
784 MsiCloseHandle(hPackage);
789 return ERROR_SUCCESS;
792 static void create_test_file(const CHAR *name)
797 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
798 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
799 WriteFile(file, name, strlen(name), &written, NULL);
800 WriteFile(file, "\n", strlen("\n"), &written, NULL);
804 typedef struct _tagVS_VERSIONINFO
811 VS_FIXEDFILEINFO Value;
816 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
817 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
819 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
821 VS_VERSIONINFO *pVerInfo;
822 VS_FIXEDFILEINFO *pFixedInfo;
829 GetSystemDirectory(path, MAX_PATH);
830 /* Some dlls can't be updated on Vista/W2K8 */
831 lstrcatA(path, "\\version.dll");
833 CopyFileA(path, name, FALSE);
835 size = GetFileVersionInfoSize(path, &handle);
836 buffer = HeapAlloc(GetProcessHeap(), 0, size);
838 GetFileVersionInfoA(path, 0, size, buffer);
840 pVerInfo = (VS_VERSIONINFO *)buffer;
841 ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
842 pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
844 pFixedInfo->dwFileVersionMS = ms;
845 pFixedInfo->dwFileVersionLS = ls;
846 pFixedInfo->dwProductVersionMS = ms;
847 pFixedInfo->dwProductVersionLS = ls;
849 resource = BeginUpdateResource(name, FALSE);
853 if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
854 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
857 if (!EndUpdateResource(resource, FALSE))
863 HeapFree(GetProcessHeap(), 0, buffer);
867 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
869 RESTOREPOINTINFOA spec;
871 spec.dwEventType = event_type;
872 spec.dwRestorePtType = APPLICATION_INSTALL;
873 spec.llSequenceNumber = status->llSequenceNumber;
874 lstrcpyA(spec.szDescription, "msitest restore point");
876 return pSRSetRestorePointA(&spec, status);
879 static void remove_restore_point(DWORD seq_number)
883 res = pSRRemoveRestorePoint(seq_number);
884 if (res != ERROR_SUCCESS)
885 trace("Failed to remove the restore point : %08x\n", res);
888 static void test_createpackage(void)
890 MSIHANDLE hPackage = 0;
893 res = package_from_db(create_package_db(), &hPackage);
894 if (res == ERROR_INSTALL_PACKAGE_REJECTED)
896 skip("Not enough rights to perform tests\n");
900 ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
902 res = MsiCloseHandle( hPackage);
903 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
907 static void test_doaction( void )
912 r = MsiDoAction( -1, NULL );
913 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
915 r = package_from_db(create_package_db(), &hpkg);
916 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
918 skip("Not enough rights to perform tests\n");
922 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
924 r = MsiDoAction(hpkg, NULL);
925 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
927 r = MsiDoAction(0, "boo");
928 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
930 r = MsiDoAction(hpkg, "boo");
931 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
933 MsiCloseHandle( hpkg );
937 static void test_gettargetpath_bad(void)
939 static const WCHAR boo[] = {'b','o','o',0};
940 static const WCHAR empty[] = {0};
947 r = package_from_db(create_package_db(), &hpkg);
948 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
950 skip("Not enough rights to perform tests\n");
954 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
956 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
957 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
959 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
960 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
962 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
963 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
965 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
966 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
968 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
969 ok( r == ERROR_DIRECTORY, "wrong return val\n");
971 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
972 ok( r == ERROR_DIRECTORY, "wrong return val\n");
975 r = MsiGetTargetPath( hpkg, "", buffer, &sz );
976 ok( r == ERROR_DIRECTORY, "wrong return val\n");
978 r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
979 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
981 r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
982 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
984 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
985 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
987 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
988 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
990 r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
991 ok( r == ERROR_DIRECTORY, "wrong return val\n");
993 r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
994 ok( r == ERROR_DIRECTORY, "wrong return val\n");
997 r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
998 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1000 MsiCloseHandle( hpkg );
1001 DeleteFile(msifile);
1004 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1010 rec = MsiCreateRecord( 1 );
1011 ok(rec, "MsiCreate record failed\n");
1013 r = MsiRecordSetString( rec, 0, file );
1014 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1017 r = MsiFormatRecord( hpkg, rec, buff, &size );
1018 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1020 MsiCloseHandle( rec );
1023 static void test_settargetpath(void)
1025 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1031 hdb = create_package_db();
1032 ok ( hdb, "failed to create package database\n" );
1034 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1035 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1037 r = create_component_table( hdb );
1038 ok( r == S_OK, "cannot create Component table: %d\n", r );
1040 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1041 ok( r == S_OK, "cannot add dummy component: %d\n", r );
1043 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1044 ok( r == S_OK, "cannot add test component: %d\n", r );
1046 r = create_feature_table( hdb );
1047 ok( r == S_OK, "cannot create Feature table: %d\n", r );
1049 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1050 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1052 r = create_feature_components_table( hdb );
1053 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1055 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1056 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1058 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1059 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1061 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1062 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1064 r = create_file_table( hdb );
1065 ok( r == S_OK, "cannot create File table: %d\n", r );
1067 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1068 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1070 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1071 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1073 r = package_from_db( hdb, &hpkg );
1074 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1076 skip("Not enough rights to perform tests\n");
1077 DeleteFile(msifile);
1080 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1082 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1084 r = MsiDoAction( hpkg, "CostInitialize");
1085 ok( r == ERROR_SUCCESS, "cost init failed\n");
1087 r = MsiDoAction( hpkg, "FileCost");
1088 ok( r == ERROR_SUCCESS, "file cost failed\n");
1090 r = MsiDoAction( hpkg, "CostFinalize");
1091 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1093 r = MsiSetTargetPath( 0, NULL, NULL );
1094 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1096 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1097 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1099 r = MsiSetTargetPath( hpkg, "boo", NULL );
1100 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1102 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1103 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1105 sz = sizeof tempdir - 1;
1106 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1107 sprintf( file, "%srootfile.txt", tempdir );
1109 query_file_path( hpkg, "[#RootFile]", buffer );
1110 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1111 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1113 GetTempFileName( tempdir, "_wt", 0, buffer );
1114 sprintf( tempdir, "%s\\subdir", buffer );
1116 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1117 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1118 "MsiSetTargetPath on file returned %d\n", r );
1120 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1121 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1122 "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1124 DeleteFile( buffer );
1126 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1127 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1129 r = GetFileAttributes( buffer );
1130 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1132 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1133 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1136 sz = sizeof buffer - 1;
1137 lstrcat( tempdir, "\\" );
1138 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1139 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1140 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1142 sprintf( file, "%srootfile.txt", tempdir );
1143 query_file_path( hpkg, "[#RootFile]", buffer );
1144 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1147 sz = sizeof(buffer);
1148 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1149 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1150 lstrcatA( tempdir, "TestParent\\" );
1151 ok( !lstrcmpi(buffer, tempdir), "Expected \"%s\", got \"%s\"\n", tempdir, buffer );
1153 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1154 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1157 sz = sizeof(buffer);
1158 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1159 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1160 ok( lstrcmpi(buffer, "C:\\one\\two\\TestDir\\"),
1161 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer );
1164 query_file_path( hpkg, "[#TestFile]", buffer );
1165 ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1166 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1169 sz = sizeof buffer - 1;
1170 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1171 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1172 ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1174 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1175 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1178 sz = sizeof buffer - 1;
1179 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1180 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1181 ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1183 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\\\one\\\\two " );
1184 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1187 sz = sizeof buffer - 1;
1188 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1189 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1190 ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer);
1192 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\\\ Program Files \\\\ " );
1193 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1196 sz = sizeof buffer - 1;
1197 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1198 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1199 ok( !lstrcmpi(buffer, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer);
1201 MsiCloseHandle( hpkg );
1204 static void test_condition(void)
1206 static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1207 static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1208 static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1209 static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1213 r = package_from_db(create_package_db(), &hpkg);
1214 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1216 skip("Not enough rights to perform tests\n");
1217 DeleteFile(msifile);
1220 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1222 r = MsiEvaluateCondition(0, NULL);
1223 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1225 r = MsiEvaluateCondition(hpkg, NULL);
1226 ok( r == MSICONDITION_NONE, "wrong return val\n");
1228 r = MsiEvaluateCondition(hpkg, "");
1229 ok( r == MSICONDITION_NONE, "wrong return val\n");
1231 r = MsiEvaluateCondition(hpkg, "1");
1232 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1234 r = MsiEvaluateCondition(hpkg, "0");
1235 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1237 r = MsiEvaluateCondition(hpkg, "-1");
1238 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1240 r = MsiEvaluateCondition(hpkg, "0 = 0");
1241 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1243 r = MsiEvaluateCondition(hpkg, "0 <> 0");
1244 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1246 r = MsiEvaluateCondition(hpkg, "0 = 1");
1247 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1249 r = MsiEvaluateCondition(hpkg, "0 > 1");
1250 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1252 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1253 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1255 r = MsiEvaluateCondition(hpkg, "1 > 1");
1256 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1258 r = MsiEvaluateCondition(hpkg, "1 ~> 1");
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, "1 >= 1");
1268 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1270 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1271 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1273 r = MsiEvaluateCondition(hpkg, "0 < 1");
1274 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1276 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1277 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1279 r = MsiEvaluateCondition(hpkg, "1 < 1");
1280 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1282 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1283 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1285 r = MsiEvaluateCondition(hpkg, "0 <= 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, "1 <= 1");
1292 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1294 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1295 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1297 r = MsiEvaluateCondition(hpkg, "0 >=");
1298 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1300 r = MsiEvaluateCondition(hpkg, " ");
1301 ok( r == MSICONDITION_NONE, "wrong return val\n");
1303 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1304 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1306 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1307 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1309 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1310 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1312 r = MsiEvaluateCondition(hpkg, "not 0");
1313 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1315 r = MsiEvaluateCondition(hpkg, "not LicView");
1316 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1318 r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1319 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1321 r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1322 ok (r == MSICONDITION_FALSE, "wrong return val\n");
1324 r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1325 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1327 r = MsiEvaluateCondition(hpkg, "not \"A\"");
1328 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1331 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1333 r = MsiEvaluateCondition(hpkg, "\"0\"");
1334 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1336 r = MsiEvaluateCondition(hpkg, "1 and 2");
1337 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1339 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1340 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1342 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1343 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1345 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1346 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1348 r = MsiEvaluateCondition(hpkg, "(0)");
1349 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1351 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1352 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1354 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1355 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1357 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1358 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1360 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1361 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1363 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1364 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1366 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1367 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1369 r = MsiEvaluateCondition(hpkg, "0 < > 0");
1370 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1372 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1373 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1375 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1376 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1378 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1379 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1381 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1382 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1384 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1385 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1387 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1388 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1390 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1391 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1393 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1394 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1396 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1397 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1399 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1400 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1402 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1403 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1405 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1406 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1408 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1409 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1411 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1412 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1414 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1415 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1417 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1418 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1420 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1421 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1423 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1424 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1426 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1427 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1429 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1430 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1432 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1433 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1435 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1436 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1438 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1439 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1441 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1442 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1444 MsiSetProperty(hpkg, "mm", "5" );
1446 r = MsiEvaluateCondition(hpkg, "mm = 5");
1447 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1449 r = MsiEvaluateCondition(hpkg, "mm < 6");
1450 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1452 r = MsiEvaluateCondition(hpkg, "mm <= 5");
1453 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1455 r = MsiEvaluateCondition(hpkg, "mm > 4");
1456 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1458 r = MsiEvaluateCondition(hpkg, "mm < 12");
1459 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1461 r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1462 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1464 r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1465 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1467 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1468 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1470 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1471 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1473 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1474 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1476 r = MsiEvaluateCondition(hpkg, "3 >< 1");
1477 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1479 r = MsiEvaluateCondition(hpkg, "3 >< 4");
1480 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1482 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1483 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1485 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1486 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1488 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1489 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1491 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1492 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1494 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1495 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1497 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1498 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1500 r = MsiEvaluateCondition(hpkg, "_1 = _1");
1501 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1503 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1504 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1506 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1507 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1509 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1510 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1512 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1513 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1515 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1516 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1518 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1519 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1521 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1522 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1524 r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1525 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1527 r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1528 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1530 r = MsiEvaluateCondition(hpkg, "bandalmael>=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 MsiSetProperty(hpkg, "bandalmael", "0" );
1540 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1541 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1543 MsiSetProperty(hpkg, "bandalmael", "" );
1544 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1545 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1547 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1548 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1549 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1551 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1552 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1553 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1555 MsiSetProperty(hpkg, "bandalmael", "0 " );
1556 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1557 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1559 MsiSetProperty(hpkg, "bandalmael", "-0" );
1560 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1561 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1563 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1564 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1565 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1567 MsiSetProperty(hpkg, "bandalmael", "--0" );
1568 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1569 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1571 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1572 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1573 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1575 MsiSetProperty(hpkg, "bandalmael", "-" );
1576 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1577 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1579 MsiSetProperty(hpkg, "bandalmael", "+0" );
1580 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1581 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1583 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1584 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1585 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1586 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1587 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1589 MsiSetProperty(hpkg, "one", "hi");
1590 MsiSetProperty(hpkg, "two", "hithere");
1591 r = MsiEvaluateCondition(hpkg, "one >< two");
1592 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1594 MsiSetProperty(hpkg, "one", "hithere");
1595 MsiSetProperty(hpkg, "two", "hi");
1596 r = MsiEvaluateCondition(hpkg, "one >< two");
1597 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1599 MsiSetProperty(hpkg, "one", "hello");
1600 MsiSetProperty(hpkg, "two", "hi");
1601 r = MsiEvaluateCondition(hpkg, "one >< two");
1602 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1604 MsiSetProperty(hpkg, "one", "hellohithere");
1605 MsiSetProperty(hpkg, "two", "hi");
1606 r = MsiEvaluateCondition(hpkg, "one >< two");
1607 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1609 MsiSetProperty(hpkg, "one", "");
1610 MsiSetProperty(hpkg, "two", "hi");
1611 r = MsiEvaluateCondition(hpkg, "one >< two");
1612 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1614 MsiSetProperty(hpkg, "one", "hi");
1615 MsiSetProperty(hpkg, "two", "");
1616 r = MsiEvaluateCondition(hpkg, "one >< two");
1617 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1619 MsiSetProperty(hpkg, "one", "");
1620 MsiSetProperty(hpkg, "two", "");
1621 r = MsiEvaluateCondition(hpkg, "one >< two");
1622 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1624 MsiSetProperty(hpkg, "one", "1234");
1625 MsiSetProperty(hpkg, "two", "1");
1626 r = MsiEvaluateCondition(hpkg, "one >< two");
1627 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1629 MsiSetProperty(hpkg, "one", "one 1234");
1630 MsiSetProperty(hpkg, "two", "1");
1631 r = MsiEvaluateCondition(hpkg, "one >< two");
1632 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1634 MsiSetProperty(hpkg, "one", "hithere");
1635 MsiSetProperty(hpkg, "two", "hi");
1636 r = MsiEvaluateCondition(hpkg, "one << two");
1637 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1639 MsiSetProperty(hpkg, "one", "hi");
1640 MsiSetProperty(hpkg, "two", "hithere");
1641 r = MsiEvaluateCondition(hpkg, "one << two");
1642 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1644 MsiSetProperty(hpkg, "one", "hi");
1645 MsiSetProperty(hpkg, "two", "hi");
1646 r = MsiEvaluateCondition(hpkg, "one << two");
1647 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1649 MsiSetProperty(hpkg, "one", "abcdhithere");
1650 MsiSetProperty(hpkg, "two", "hi");
1651 r = MsiEvaluateCondition(hpkg, "one << two");
1652 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1654 MsiSetProperty(hpkg, "one", "");
1655 MsiSetProperty(hpkg, "two", "hi");
1656 r = MsiEvaluateCondition(hpkg, "one << two");
1657 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1659 MsiSetProperty(hpkg, "one", "hithere");
1660 MsiSetProperty(hpkg, "two", "");
1661 r = MsiEvaluateCondition(hpkg, "one << two");
1662 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1664 MsiSetProperty(hpkg, "one", "");
1665 MsiSetProperty(hpkg, "two", "");
1666 r = MsiEvaluateCondition(hpkg, "one << two");
1667 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1669 MsiSetProperty(hpkg, "one", "1234");
1670 MsiSetProperty(hpkg, "two", "1");
1671 r = MsiEvaluateCondition(hpkg, "one << two");
1672 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1674 MsiSetProperty(hpkg, "one", "1234 one");
1675 MsiSetProperty(hpkg, "two", "1");
1676 r = MsiEvaluateCondition(hpkg, "one << two");
1677 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1679 MsiSetProperty(hpkg, "one", "hithere");
1680 MsiSetProperty(hpkg, "two", "there");
1681 r = MsiEvaluateCondition(hpkg, "one >> two");
1682 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1684 MsiSetProperty(hpkg, "one", "hithere");
1685 MsiSetProperty(hpkg, "two", "hi");
1686 r = MsiEvaluateCondition(hpkg, "one >> two");
1687 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1689 MsiSetProperty(hpkg, "one", "there");
1690 MsiSetProperty(hpkg, "two", "hithere");
1691 r = MsiEvaluateCondition(hpkg, "one >> two");
1692 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1694 MsiSetProperty(hpkg, "one", "there");
1695 MsiSetProperty(hpkg, "two", "there");
1696 r = MsiEvaluateCondition(hpkg, "one >> two");
1697 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1699 MsiSetProperty(hpkg, "one", "abcdhithere");
1700 MsiSetProperty(hpkg, "two", "hi");
1701 r = MsiEvaluateCondition(hpkg, "one >> two");
1702 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1704 MsiSetProperty(hpkg, "one", "");
1705 MsiSetProperty(hpkg, "two", "there");
1706 r = MsiEvaluateCondition(hpkg, "one >> two");
1707 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1709 MsiSetProperty(hpkg, "one", "there");
1710 MsiSetProperty(hpkg, "two", "");
1711 r = MsiEvaluateCondition(hpkg, "one >> two");
1712 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1714 MsiSetProperty(hpkg, "one", "");
1715 MsiSetProperty(hpkg, "two", "");
1716 r = MsiEvaluateCondition(hpkg, "one >> two");
1717 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1719 MsiSetProperty(hpkg, "one", "1234");
1720 MsiSetProperty(hpkg, "two", "4");
1721 r = MsiEvaluateCondition(hpkg, "one >> two");
1722 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1724 MsiSetProperty(hpkg, "one", "one 1234");
1725 MsiSetProperty(hpkg, "two", "4");
1726 r = MsiEvaluateCondition(hpkg, "one >> two");
1727 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1729 MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1731 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1732 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1734 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1735 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1737 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1738 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1740 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1741 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1743 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1744 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1746 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1747 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1749 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1750 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1752 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1753 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1755 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1756 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1758 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1759 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1761 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1762 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1764 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1765 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1767 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1768 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1770 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1771 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1773 r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1774 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1776 r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1777 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1779 r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1780 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1782 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1783 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1785 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1786 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1788 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1789 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1791 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1792 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1794 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1795 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1797 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1798 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1800 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1801 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1803 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1804 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1806 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1807 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1809 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1810 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1812 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1813 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1815 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1816 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1818 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1819 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1821 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1822 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1824 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1825 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1827 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1828 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1830 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[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]\"");
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 MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1843 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1844 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1846 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1847 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1849 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1850 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1852 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1853 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1855 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1856 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1858 MsiSetProperty(hpkg, "one", "1");
1859 r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1860 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1862 MsiSetProperty(hpkg, "X", "5.0");
1864 r = MsiEvaluateCondition(hpkg, "X != \"\"");
1865 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1867 r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1868 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1870 r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1871 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1873 r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1874 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1876 r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1877 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1879 r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1880 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1882 r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1883 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1885 /* feature doesn't exist */
1886 r = MsiEvaluateCondition(hpkg, "&nofeature");
1887 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1889 MsiSetProperty(hpkg, "A", "2");
1890 MsiSetProperty(hpkg, "X", "50");
1892 r = MsiEvaluateCondition(hpkg, "2 <= X");
1893 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1895 r = MsiEvaluateCondition(hpkg, "A <= X");
1896 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1898 r = MsiEvaluateCondition(hpkg, "A <= 50");
1899 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1901 MsiSetProperty(hpkg, "X", "50val");
1903 r = MsiEvaluateCondition(hpkg, "2 <= X");
1904 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1906 r = MsiEvaluateCondition(hpkg, "A <= X");
1907 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1909 MsiSetProperty(hpkg, "A", "7");
1910 MsiSetProperty(hpkg, "X", "50");
1912 r = MsiEvaluateCondition(hpkg, "7 <= X");
1913 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1915 r = MsiEvaluateCondition(hpkg, "A <= X");
1916 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1918 r = MsiEvaluateCondition(hpkg, "A <= 50");
1919 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1921 MsiSetProperty(hpkg, "X", "50val");
1923 r = MsiEvaluateCondition(hpkg, "2 <= X");
1924 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1926 r = MsiEvaluateCondition(hpkg, "A <= X");
1927 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1929 r = MsiEvaluateConditionW(hpkg, cond1);
1930 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1931 "wrong return val (%d)\n", r);
1933 r = MsiEvaluateConditionW(hpkg, cond2);
1934 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1935 "wrong return val (%d)\n", r);
1937 r = MsiEvaluateConditionW(hpkg, cond3);
1938 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1939 "wrong return val (%d)\n", r);
1941 r = MsiEvaluateConditionW(hpkg, cond4);
1942 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1943 "wrong return val (%d)\n", r);
1945 MsiCloseHandle( hpkg );
1946 DeleteFile(msifile);
1949 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1957 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1958 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1961 static void test_props(void)
1963 MSIHANDLE hpkg, hdb;
1968 hdb = create_package_db();
1970 "CREATE TABLE `Property` ( "
1971 "`Property` CHAR(255) NOT NULL, "
1972 "`Value` CHAR(255) "
1973 "PRIMARY KEY `Property`)" );
1974 ok( r == ERROR_SUCCESS , "Failed\n" );
1977 "INSERT INTO `Property` "
1978 "(`Property`, `Value`) "
1979 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1980 ok( r == ERROR_SUCCESS , "Failed\n" );
1982 r = package_from_db( hdb, &hpkg );
1983 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1985 skip("Not enough rights to perform tests\n");
1986 DeleteFile(msifile);
1989 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1991 /* test invalid values */
1992 r = MsiGetProperty( 0, NULL, NULL, NULL );
1993 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1995 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1996 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1998 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
1999 ok( r == ERROR_SUCCESS, "wrong return val\n");
2001 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
2002 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2004 /* test retrieving an empty/nonexistent property */
2006 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
2007 ok( r == ERROR_SUCCESS, "wrong return val\n");
2008 ok( sz == 0, "wrong size returned\n");
2010 check_prop_empty( hpkg, "boo");
2013 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2014 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2015 ok( !strcmp(buffer,"x"), "buffer was changed\n");
2016 ok( sz == 0, "wrong size returned\n");
2020 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2021 ok( r == ERROR_SUCCESS, "wrong return val\n");
2022 ok( buffer[0] == 0, "buffer was not changed\n");
2023 ok( sz == 0, "wrong size returned\n");
2025 /* set the property to something */
2026 r = MsiSetProperty( 0, NULL, NULL );
2027 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
2029 r = MsiSetProperty( hpkg, NULL, NULL );
2030 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2032 r = MsiSetProperty( hpkg, "", NULL );
2033 ok( r == ERROR_SUCCESS, "wrong return val\n");
2035 /* try set and get some illegal property identifiers */
2036 r = MsiSetProperty( hpkg, "", "asdf" );
2037 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2039 r = MsiSetProperty( hpkg, "=", "asdf" );
2040 ok( r == ERROR_SUCCESS, "wrong return val\n");
2042 r = MsiSetProperty( hpkg, " ", "asdf" );
2043 ok( r == ERROR_SUCCESS, "wrong return val\n");
2045 r = MsiSetProperty( hpkg, "'", "asdf" );
2046 ok( r == ERROR_SUCCESS, "wrong return val\n");
2050 r = MsiGetProperty( hpkg, "'", buffer, &sz );
2051 ok( r == ERROR_SUCCESS, "wrong return val\n");
2052 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2054 /* set empty values */
2055 r = MsiSetProperty( hpkg, "boo", NULL );
2056 ok( r == ERROR_SUCCESS, "wrong return val\n");
2057 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2059 r = MsiSetProperty( hpkg, "boo", "" );
2060 ok( r == ERROR_SUCCESS, "wrong return val\n");
2061 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2063 /* set a non-empty value */
2064 r = MsiSetProperty( hpkg, "boo", "xyz" );
2065 ok( r == ERROR_SUCCESS, "wrong return val\n");
2069 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2070 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2071 ok( buffer[0] == 0, "buffer was not changed\n");
2072 ok( sz == 3, "wrong size returned\n");
2076 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2077 ok( r == ERROR_SUCCESS, "wrong return val\n");
2078 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2079 ok( sz == 3, "wrong size returned\n");
2083 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2084 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2085 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2086 ok( sz == 3, "wrong size returned\n");
2088 r = MsiSetProperty(hpkg, "SourceDir", "foo");
2089 ok( r == ERROR_SUCCESS, "wrong return val\n");
2092 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2093 ok( r == ERROR_SUCCESS, "wrong return val\n");
2094 ok( !strcmp(buffer,""), "buffer wrong\n");
2095 ok( sz == 0, "wrong size returned\n");
2098 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2099 ok( r == ERROR_SUCCESS, "wrong return val\n");
2100 ok( !strcmp(buffer,""), "buffer wrong\n");
2101 ok( sz == 0, "wrong size returned\n");
2104 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2105 ok( r == ERROR_SUCCESS, "wrong return val\n");
2106 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2107 ok( sz == 3, "wrong size returned\n");
2109 r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2110 ok( r == ERROR_SUCCESS, "wrong return val\n");
2113 r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2114 ok( r == ERROR_SUCCESS, "return wrong\n");
2115 ok( sz == 13, "size wrong (%d)\n", sz);
2118 r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2119 ok( r == ERROR_MORE_DATA, "return wrong\n");
2120 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2122 r = MsiSetProperty(hpkg, "property", "value");
2123 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2126 r = MsiGetProperty(hpkg, "property", buffer, &sz);
2127 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2128 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2130 r = MsiSetProperty(hpkg, "property", NULL);
2131 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2134 r = MsiGetProperty(hpkg, "property", buffer, &sz);
2135 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2136 ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2138 MsiCloseHandle( hpkg );
2139 DeleteFile(msifile);
2142 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2144 MSIHANDLE hview, hrec;
2146 CHAR buffer[MAX_PATH];
2150 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2151 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2152 r = MsiViewExecute(hview, 0);
2153 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2156 while (r == ERROR_SUCCESS && !found)
2158 r = MsiViewFetch(hview, &hrec);
2159 if (r != ERROR_SUCCESS) break;
2162 r = MsiRecordGetString(hrec, 1, buffer, &sz);
2163 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2166 r = MsiRecordGetString(hrec, 2, buffer, &sz);
2167 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2171 MsiCloseHandle(hrec);
2174 MsiViewClose(hview);
2175 MsiCloseHandle(hview);
2180 static void test_property_table(void)
2184 MSIHANDLE hpkg, hdb, hrec;
2185 char buffer[MAX_PATH], package[10];
2189 hdb = create_package_db();
2190 ok( hdb, "failed to create package\n");
2192 r = package_from_db(hdb, &hpkg);
2193 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2195 skip("Not enough rights to perform tests\n");
2196 DeleteFile(msifile);
2199 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2201 MsiCloseHandle(hdb);
2203 hdb = MsiGetActiveDatabase(hpkg);
2205 query = "CREATE TABLE `_Property` ( "
2206 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2207 r = run_query(hdb, query);
2208 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2210 MsiCloseHandle(hdb);
2211 MsiCloseHandle(hpkg);
2212 DeleteFile(msifile);
2214 hdb = create_package_db();
2215 ok( hdb, "failed to create package\n");
2217 query = "CREATE TABLE `_Property` ( "
2218 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2219 r = run_query(hdb, query);
2220 ok(r == ERROR_SUCCESS, "failed to create table\n");
2222 query = "ALTER `_Property` ADD `foo` INTEGER";
2223 r = run_query(hdb, query);
2224 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2226 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2227 r = run_query(hdb, query);
2228 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2230 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2231 r = run_query(hdb, query);
2232 ok(r == ERROR_SUCCESS, "failed to add column\n");
2234 sprintf(package, "#%i", hdb);
2235 r = MsiOpenPackage(package, &hpkg);
2236 todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2237 if (r == ERROR_SUCCESS)
2238 MsiCloseHandle(hpkg);
2240 r = MsiCloseHandle(hdb);
2241 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2243 hdb = create_package_db();
2244 ok (hdb, "failed to create package database\n");
2246 r = create_property_table(hdb);
2247 ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2249 r = add_property_entry(hdb, "'prop', 'val'");
2250 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2252 r = package_from_db(hdb, &hpkg);
2253 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2255 MsiCloseHandle(hdb);
2258 r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2260 ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2262 hdb = MsiGetActiveDatabase(hpkg);
2264 found = find_prop_in_property(hdb, "prop", "val");
2265 ok(found, "prop should be in the _Property table\n");
2267 r = add_property_entry(hdb, "'dantes', 'mercedes'");
2268 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2270 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2271 r = do_query(hdb, query, &hrec);
2272 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2274 found = find_prop_in_property(hdb, "dantes", "mercedes");
2275 ok(found == FALSE, "dantes should not be in the _Property table\n");
2278 lstrcpy(buffer, "aaa");
2279 r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2280 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2281 ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2283 r = MsiSetProperty(hpkg, "dantes", "mercedes");
2284 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2286 found = find_prop_in_property(hdb, "dantes", "mercedes");
2287 ok(found == TRUE, "dantes should be in the _Property table\n");
2289 MsiCloseHandle(hdb);
2290 MsiCloseHandle(hpkg);
2291 DeleteFile(msifile);
2294 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2299 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2300 if( res == ERROR_SUCCESS )
2304 r = MsiViewExecute( htab, hrec );
2305 if( r != ERROR_SUCCESS )
2308 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2311 r = MsiViewClose( htab );
2312 if( r != ERROR_SUCCESS )
2315 r = MsiCloseHandle( htab );
2316 if( r != ERROR_SUCCESS )
2322 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2324 return try_query_param( hdb, szQuery, 0 );
2327 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2332 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2335 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2336 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2338 r = MsiSummaryInfoPersist(summary);
2339 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2341 MsiCloseHandle(summary);
2344 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2349 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2350 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2352 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2355 r = MsiSummaryInfoPersist(summary);
2356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2358 MsiCloseHandle(summary);
2361 static void test_msipackage(void)
2363 MSIHANDLE hdb = 0, hpack = 100;
2368 /* NULL szPackagePath */
2369 r = MsiOpenPackage(NULL, &hpack);
2370 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2372 /* empty szPackagePath */
2373 r = MsiOpenPackage("", &hpack);
2374 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2376 skip("Not enough rights to perform tests\n");
2381 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2384 if (r == ERROR_SUCCESS)
2385 MsiCloseHandle(hpack);
2387 /* nonexistent szPackagePath */
2388 r = MsiOpenPackage("nonexistent", &hpack);
2389 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2392 r = MsiOpenPackage(msifile, NULL);
2393 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2397 r = MsiOpenPackage(name, &hpack);
2398 ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2400 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2401 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2403 /* database exists, but is emtpy */
2404 sprintf(name, "#%d", hdb);
2405 r = MsiOpenPackage(name, &hpack);
2406 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2407 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2409 query = "CREATE TABLE `Property` ( "
2410 "`Property` CHAR(72), `Value` CHAR(0) "
2411 "PRIMARY KEY `Property`)";
2412 r = try_query(hdb, query);
2413 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2415 query = "CREATE TABLE `InstallExecuteSequence` ("
2416 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2417 "PRIMARY KEY `Action`)";
2418 r = try_query(hdb, query);
2419 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2421 /* a few key tables exist */
2422 sprintf(name, "#%d", hdb);
2423 r = MsiOpenPackage(name, &hpack);
2424 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2425 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2427 MsiCloseHandle(hdb);
2428 DeleteFile(msifile);
2430 /* start with a clean database to show what constitutes a valid package */
2431 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2432 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2434 sprintf(name, "#%d", hdb);
2436 /* The following summary information props must exist:
2441 set_summary_dword(hdb, PID_PAGECOUNT, 100);
2442 r = MsiOpenPackage(name, &hpack);
2443 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2444 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2446 set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2447 r = MsiOpenPackage(name, &hpack);
2448 ok(r == ERROR_SUCCESS,
2449 "Expected ERROR_SUCCESS, got %d\n", r);
2451 MsiCloseHandle(hpack);
2452 MsiCloseHandle(hdb);
2453 DeleteFile(msifile);
2456 static void test_formatrecord2(void)
2458 MSIHANDLE hpkg, hrec ;
2463 r = package_from_db(create_package_db(), &hpkg);
2464 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2466 skip("Not enough rights to perform tests\n");
2467 DeleteFile(msifile);
2470 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2472 r = MsiSetProperty(hpkg, "Manufacturer", " " );
2473 ok( r == ERROR_SUCCESS, "set property failed\n");
2475 hrec = MsiCreateRecord(2);
2476 ok(hrec, "create record failed\n");
2478 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2479 ok( r == ERROR_SUCCESS, "format record failed\n");
2483 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2484 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2486 r = MsiRecordSetString(hrec, 0, "[foo][1]");
2487 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2488 r = MsiRecordSetString(hrec, 1, "hoo");
2489 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2491 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2492 ok( sz == 3, "size wrong\n");
2493 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2494 ok( r == ERROR_SUCCESS, "format failed\n");
2496 r = MsiRecordSetString(hrec, 0, "x[~]x");
2497 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2499 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2500 ok( sz == 3, "size wrong\n");
2501 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2502 ok( r == ERROR_SUCCESS, "format failed\n");
2504 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2505 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2506 r = MsiRecordSetString(hrec, 1, "hoo");
2507 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2509 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2510 ok( sz == 3, "size wrong\n");
2511 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2512 ok( r == ERROR_SUCCESS, "format failed\n");
2514 r = MsiRecordSetString(hrec, 0, "[\\[]");
2515 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2517 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2518 ok( sz == 1, "size wrong\n");
2519 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2520 ok( r == ERROR_SUCCESS, "format failed\n");
2522 SetEnvironmentVariable("FOO", "BAR");
2523 r = MsiRecordSetString(hrec, 0, "[%FOO]");
2524 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2526 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2527 ok( sz == 3, "size wrong\n");
2528 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2529 ok( r == ERROR_SUCCESS, "format failed\n");
2531 r = MsiRecordSetString(hrec, 0, "[[1]]");
2532 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2533 r = MsiRecordSetString(hrec, 1, "%FOO");
2534 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2536 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2537 ok( sz == 3, "size wrong\n");
2538 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2539 ok( r == ERROR_SUCCESS, "format failed\n");
2541 MsiCloseHandle( hrec );
2542 MsiCloseHandle( hpkg );
2543 DeleteFile(msifile);
2546 static void test_feature_states( UINT line, MSIHANDLE package, const char *feature, UINT error,
2547 INSTALLSTATE expected_state, INSTALLSTATE expected_action, int todo )
2550 INSTALLSTATE state = 0xdeadbee;
2551 INSTALLSTATE action = 0xdeadbee;
2553 r = MsiGetFeatureState( package, feature, &state, &action );
2554 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2555 if (r == ERROR_SUCCESS)
2557 ok( state == expected_state, "%u: expected state %d got %d\n",
2558 line, expected_state, state );
2560 ok( action == expected_action, "%u: expected action %d got %d\n",
2561 line, expected_action, action );
2563 ok( action == expected_action, "%u: expected action %d got %d\n",
2564 line, expected_action, action );
2568 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line, state );
2570 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2572 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2577 static void test_component_states( UINT line, MSIHANDLE package, const char *component, UINT error,
2578 INSTALLSTATE expected_state, INSTALLSTATE expected_action, int todo )
2581 INSTALLSTATE state = 0xdeadbee;
2582 INSTALLSTATE action = 0xdeadbee;
2584 r = MsiGetComponentState( package, component, &state, &action );
2585 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2586 if (r == ERROR_SUCCESS)
2588 ok( state == expected_state, "%u: expected state %d got %d\n",
2589 line, expected_state, state );
2591 ok( action == expected_action, "%u: expected action %d got %d\n",
2592 line, expected_action, action );
2594 ok( action == expected_action, "%u: expected action %d got %d\n",
2595 line, expected_action, action );
2599 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2602 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2605 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2610 static void test_states(void)
2612 static char msifile2[] = "winetest2-package.msi";
2613 static char msifile3[] = "winetest3-package.msi";
2614 static char msifile4[] = "winetest4-package.msi";
2619 if (is_process_limited())
2621 skip("process is limited\n");
2625 hdb = create_package_db();
2626 ok ( hdb, "failed to create package database\n" );
2628 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2629 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2631 r = create_property_table( hdb );
2632 ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2634 r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2635 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2637 r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2638 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2640 r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2641 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2643 r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2644 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2646 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2647 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2649 r = create_install_execute_sequence_table( hdb );
2650 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2652 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2653 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2655 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2656 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2658 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2659 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2661 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2662 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2664 r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2665 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2667 r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2668 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2670 r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2671 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2673 r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2674 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2676 r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2677 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2679 r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2680 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2682 r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2683 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2685 r = create_media_table( hdb );
2686 ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2688 r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2689 ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2691 r = create_feature_table( hdb );
2692 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2694 r = create_component_table( hdb );
2695 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2697 /* msidbFeatureAttributesFavorLocal */
2698 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2699 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2701 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2702 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2703 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2705 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2706 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2707 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2709 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2710 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2711 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2713 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2714 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2715 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2717 /* msidbFeatureAttributesFavorSource */
2718 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2719 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2721 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2722 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2723 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2725 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2726 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2727 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2729 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2730 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2731 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2733 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2734 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2735 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2737 /* msidbFeatureAttributesFavorSource */
2738 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2739 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2741 /* msidbFeatureAttributesFavorLocal */
2742 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2743 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2746 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2747 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2749 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2750 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2751 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2753 /* no feature parent:msidbComponentAttributesLocalOnly */
2754 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2755 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2757 /* msidbFeatureAttributesFavorLocal:removed */
2758 r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2759 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2761 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2762 r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2763 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2765 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2766 r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2767 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2769 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2770 r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2771 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2773 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2774 r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2775 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2777 /* msidbFeatureAttributesFavorSource:removed */
2778 r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2779 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2781 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2782 r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2783 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2785 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2786 r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2787 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2789 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2790 r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2791 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2793 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2794 r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2795 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2797 /* msidbFeatureAttributesFavorLocal */
2798 r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2799 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2801 r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2802 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2804 /* msidbFeatureAttributesFavorSource */
2805 r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2806 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2808 r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2809 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2811 /* msidbFeatureAttributesFavorAdvertise */
2812 r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2813 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2815 r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2816 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2818 /* msidbFeatureAttributesUIDisallowAbsent */
2819 r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2820 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2822 r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2823 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2825 r = create_feature_components_table( hdb );
2826 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2828 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2829 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2831 r = add_feature_components_entry( hdb, "'one', 'beta'" );
2832 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2834 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2835 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2837 r = add_feature_components_entry( hdb, "'one', 'theta'" );
2838 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2840 r = add_feature_components_entry( hdb, "'two', 'delta'" );
2841 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2843 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2844 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2846 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2847 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2849 r = add_feature_components_entry( hdb, "'two', 'iota'" );
2850 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2852 r = add_feature_components_entry( hdb, "'three', 'eta'" );
2853 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2855 r = add_feature_components_entry( hdb, "'four', 'eta'" );
2856 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2858 r = add_feature_components_entry( hdb, "'five', 'eta'" );
2859 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2861 r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2862 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2864 r = add_feature_components_entry( hdb, "'six', 'mu'" );
2865 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2867 r = add_feature_components_entry( hdb, "'six', 'nu'" );
2868 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2870 r = add_feature_components_entry( hdb, "'six', 'xi'" );
2871 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2873 r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2874 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2876 r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2877 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2879 r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2880 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2882 r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2883 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2885 r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2886 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2888 r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2889 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2891 r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2892 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2894 r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
2895 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2897 r = create_file_table( hdb );
2898 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2900 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2901 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2903 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2904 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2906 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2907 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2909 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2910 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2912 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2913 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2915 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2916 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2918 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2919 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2921 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2922 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2924 /* compressed file */
2925 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2926 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2928 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2929 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2931 r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2932 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2934 r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2935 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2937 r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2938 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2940 r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2941 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2943 r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2944 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2946 r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2947 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2949 r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2950 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2952 r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2953 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2955 r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2956 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2958 r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2959 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2961 r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2962 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2964 r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
2965 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2967 MsiDatabaseCommit(hdb);
2969 /* these properties must not be in the saved msi file */
2970 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2971 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2973 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2974 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2976 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2977 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2979 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2980 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2982 r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2983 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2985 r = package_from_db( hdb, &hpkg );
2986 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2988 skip("Not enough rights to perform tests\n");
2989 DeleteFile(msifile);
2992 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2994 MsiCloseHandle(hdb);
2996 CopyFileA(msifile, msifile2, FALSE);
2997 CopyFileA(msifile, msifile3, FALSE);
2998 CopyFileA(msifile, msifile4, FALSE);
3000 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3001 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3003 r = MsiDoAction( hpkg, "CostInitialize");
3004 ok( r == ERROR_SUCCESS, "cost init failed\n");
3006 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3007 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3009 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3011 r = MsiDoAction( hpkg, "FileCost");
3012 ok( r == ERROR_SUCCESS, "file cost failed\n");
3014 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3015 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3017 r = MsiDoAction( hpkg, "CostFinalize");
3018 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3020 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3021 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3022 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3023 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3024 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3025 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3026 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3027 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3028 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3029 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3030 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3032 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3033 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3034 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3035 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3036 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3037 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3038 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3039 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3040 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3041 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3042 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3043 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3044 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3045 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3046 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3047 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3048 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3049 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3050 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3051 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3052 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3053 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3055 MsiCloseHandle( hpkg );
3057 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3059 /* publish the features and components */
3060 r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3061 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3063 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3064 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3066 /* these properties must not be in the saved msi file */
3067 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3068 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3070 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3071 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3073 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3074 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3076 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3077 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3079 r = package_from_db( hdb, &hpkg );
3080 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3082 MsiCloseHandle(hdb);
3084 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3085 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3087 r = MsiDoAction( hpkg, "CostInitialize");
3088 ok( r == ERROR_SUCCESS, "cost init failed\n");
3090 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3091 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3093 r = MsiDoAction( hpkg, "FileCost");
3094 ok( r == ERROR_SUCCESS, "file cost failed\n");
3096 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3097 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3099 r = MsiDoAction( hpkg, "CostFinalize");
3100 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3102 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3103 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3104 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3105 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3106 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3107 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3108 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3109 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3110 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3111 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3112 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3114 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3115 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3116 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3117 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3118 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3119 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3120 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3121 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3122 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3123 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3124 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3125 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3126 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3127 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3128 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3129 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3130 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3131 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3132 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3133 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3134 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3135 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3137 MsiCloseHandle(hpkg);
3139 /* uninstall the product */
3140 r = MsiInstallProduct(msifile, "REMOVE=ALL");
3141 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3143 /* all features installed locally */
3144 r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
3145 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3147 r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
3148 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3150 /* these properties must not be in the saved msi file */
3151 r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3152 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3154 r = package_from_db( hdb, &hpkg );
3155 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3157 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3158 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3160 r = MsiDoAction( hpkg, "CostInitialize");
3161 ok( r == ERROR_SUCCESS, "cost init failed\n");
3163 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3164 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3166 r = MsiDoAction( hpkg, "CostFinalize");
3167 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3169 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3170 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3171 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3172 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3173 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3174 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3175 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3176 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3177 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3178 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3179 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3181 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3182 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3183 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3184 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3185 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3186 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3187 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3188 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3189 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3190 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3191 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3192 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3193 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3194 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3195 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3196 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3197 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3198 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3199 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3200 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3201 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3202 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3204 MsiCloseHandle(hpkg);
3206 /* uninstall the product */
3207 r = MsiInstallProduct(msifile2, "REMOVE=ALL");
3208 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3210 /* all features installed from source */
3211 r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
3212 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3214 r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
3215 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3217 /* this property must not be in the saved msi file */
3218 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3219 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3221 r = package_from_db( hdb, &hpkg );
3222 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3224 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3225 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3227 r = MsiDoAction( hpkg, "CostInitialize");
3228 ok( r == ERROR_SUCCESS, "cost init failed\n");
3230 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3231 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3233 r = MsiDoAction( hpkg, "FileCost");
3234 ok( r == ERROR_SUCCESS, "file cost failed\n");
3236 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3237 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3239 r = MsiDoAction( hpkg, "CostFinalize");
3240 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3242 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3243 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3244 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3245 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3246 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3247 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3248 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3249 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3250 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3251 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3252 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3254 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3255 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3256 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3257 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3258 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3259 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3260 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3261 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3262 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3263 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3264 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3265 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3266 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3267 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3268 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3269 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3270 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3271 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3272 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3273 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3274 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3275 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3277 MsiCloseHandle(hpkg);
3279 /* reinstall the product */
3280 r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
3281 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3283 r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
3284 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3286 /* this property must not be in the saved msi file */
3287 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3288 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3290 r = package_from_db( hdb, &hpkg );
3291 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3293 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3294 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3296 r = MsiDoAction( hpkg, "CostInitialize");
3297 ok( r == ERROR_SUCCESS, "cost init failed\n");
3299 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3300 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3302 r = MsiDoAction( hpkg, "FileCost");
3303 ok( r == ERROR_SUCCESS, "file cost failed\n");
3305 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3306 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3308 r = MsiDoAction( hpkg, "CostFinalize");
3309 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3311 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3312 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3313 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3314 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3315 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3316 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3317 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3318 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3319 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3320 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3321 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3323 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3324 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3325 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3326 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3327 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3328 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3329 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3330 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3331 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3332 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3333 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3334 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3335 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3336 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3337 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3338 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3339 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3340 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3341 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3342 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3343 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3344 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3346 MsiCloseHandle(hpkg);
3348 /* uninstall the product */
3349 r = MsiInstallProduct(msifile4, "REMOVE=ALL");
3350 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3352 DeleteFileA(msifile);
3353 DeleteFileA(msifile2);
3354 DeleteFileA(msifile3);
3355 DeleteFileA(msifile4);
3358 static void test_getproperty(void)
3360 MSIHANDLE hPackage = 0;
3362 static CHAR empty[] = "";
3366 r = package_from_db(create_package_db(), &hPackage);
3367 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3369 skip("Not enough rights to perform tests\n");
3370 DeleteFile(msifile);
3373 ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
3375 /* set the property */
3376 r = MsiSetProperty(hPackage, "Name", "Value");
3377 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3379 /* retrieve the size, NULL pointer */
3381 r = MsiGetProperty(hPackage, "Name", NULL, &size);
3382 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3383 ok( size == 5, "Expected 5, got %d\n", size);
3385 /* retrieve the size, empty string */
3387 r = MsiGetProperty(hPackage, "Name", empty, &size);
3388 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3389 ok( size == 5, "Expected 5, got %d\n", size);
3391 /* don't change size */
3392 r = MsiGetProperty(hPackage, "Name", prop, &size);
3393 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3394 ok( size == 5, "Expected 5, got %d\n", size);
3395 ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
3397 /* increase the size by 1 */
3399 r = MsiGetProperty(hPackage, "Name", prop, &size);
3400 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3401 ok( size == 5, "Expected 5, got %d\n", size);
3402 ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
3404 r = MsiCloseHandle( hPackage);
3405 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
3406 DeleteFile(msifile);
3409 static void test_removefiles(void)
3414 INSTALLSTATE installed, action;
3416 hdb = create_package_db();
3417 ok ( hdb, "failed to create package database\n" );
3419 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3420 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3422 r = create_feature_table( hdb );
3423 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
3425 r = create_component_table( hdb );
3426 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
3428 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3429 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3431 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3432 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3434 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3435 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3437 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3438 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3440 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3441 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3443 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3444 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3446 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3447 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3449 r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3450 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3452 r = create_feature_components_table( hdb );
3453 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
3455 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
3456 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3458 r = add_feature_components_entry( hdb, "'one', 'helium'" );
3459 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3461 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
3462 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3464 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
3465 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3467 r = add_feature_components_entry( hdb, "'one', 'boron'" );
3468 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3470 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
3471 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3473 r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
3474 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3476 r = create_file_table( hdb );
3477 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3479 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3480 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3482 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3483 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3485 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3486 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3488 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3489 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3491 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3492 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3494 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3495 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3497 r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3498 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3500 r = create_remove_file_table( hdb );
3501 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
3503 r = package_from_db( hdb, &hpkg );
3504 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3506 skip("Not enough rights to perform tests\n");
3507 DeleteFile(msifile);
3510 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3512 MsiCloseHandle( hdb );
3514 create_test_file( "hydrogen.txt" );
3515 create_test_file( "helium.txt" );
3516 create_test_file( "lithium.txt" );
3517 create_test_file( "beryllium.txt" );
3518 create_test_file( "boron.txt" );
3519 create_test_file( "carbon.txt" );
3520 create_test_file( "oxygen.txt" );
3522 r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
3523 ok( r == ERROR_SUCCESS, "set property failed\n");
3525 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3527 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3528 ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
3530 r = MsiDoAction( hpkg, "CostInitialize");
3531 ok( r == ERROR_SUCCESS, "cost init failed\n");
3533 r = MsiDoAction( hpkg, "FileCost");
3534 ok( r == ERROR_SUCCESS, "file cost failed\n");
3536 installed = action = 0xdeadbeef;
3537 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3538 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3539 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3540 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3542 r = MsiDoAction( hpkg, "CostFinalize");
3543 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3545 r = MsiDoAction( hpkg, "InstallValidate");
3546 ok( r == ERROR_SUCCESS, "install validate failed\n");
3548 r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
3549 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3551 installed = action = 0xdeadbeef;
3552 r = MsiGetComponentState( hpkg, "hydrogen", &installed, &action );
3553 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3554 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3555 todo_wine ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3557 r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
3558 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3560 r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
3561 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3563 r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
3564 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3566 r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
3567 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3569 r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
3570 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
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 = MsiSetComponentState( hpkg, "oxygen", INSTALLSTATE_ABSENT );
3579 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3581 installed = action = 0xdeadbeef;
3582 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3583 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3584 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3585 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3587 r = MsiDoAction( hpkg, "RemoveFiles");
3588 ok( r == ERROR_SUCCESS, "remove files failed\n");
3590 installed = action = 0xdeadbeef;
3591 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3592 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3593 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3594 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3596 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3597 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3598 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3599 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3600 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3601 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3602 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3604 MsiCloseHandle( hpkg );
3605 DeleteFileA(msifile);
3608 static void test_appsearch(void)
3613 CHAR prop[MAX_PATH];
3616 hdb = create_package_db();
3617 ok ( hdb, "failed to create package database\n" );
3619 r = create_appsearch_table( hdb );
3620 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
3622 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
3623 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3625 r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
3626 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3628 r = create_reglocator_table( hdb );
3629 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3631 r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3632 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3634 r = create_drlocator_table( hdb );
3635 ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
3637 r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3638 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3640 r = create_signature_table( hdb );
3641 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
3643 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3644 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3646 r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3647 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3649 r = package_from_db( hdb, &hpkg );
3650 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3652 skip("Not enough rights to perform tests\n");
3653 DeleteFile(msifile);
3656 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3657 MsiCloseHandle( hdb );
3658 if (r != ERROR_SUCCESS)
3661 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3663 r = MsiDoAction( hpkg, "AppSearch" );
3664 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
3666 size = sizeof(prop);
3667 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
3668 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3669 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3671 size = sizeof(prop);
3672 r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
3673 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3676 MsiCloseHandle( hpkg );
3677 DeleteFileA(msifile);
3680 static void test_appsearch_complocator(void)
3682 MSIHANDLE hpkg, hdb;
3683 CHAR path[MAX_PATH];
3684 CHAR prop[MAX_PATH];
3689 if (!(usersid = get_user_sid()))
3692 if (is_process_limited())
3694 skip("process is limited\n");
3698 create_test_file("FileName1");
3699 create_test_file("FileName4");
3700 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
3701 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
3703 create_test_file("FileName2");
3704 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
3705 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
3707 create_test_file("FileName3");
3708 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
3709 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
3711 create_test_file("FileName5");
3712 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
3713 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
3715 create_test_file("FileName6");
3716 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
3717 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
3719 create_test_file("FileName7");
3720 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
3721 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
3723 /* dir is FALSE, but we're pretending it's a directory */
3724 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
3725 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
3727 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3728 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
3729 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
3731 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3732 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
3733 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
3735 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3736 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
3737 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
3739 hdb = create_package_db();
3740 ok(hdb, "Expected a valid database handle\n");
3742 r = create_appsearch_table(hdb);
3743 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3745 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
3746 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3748 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
3749 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3751 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
3752 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3754 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
3755 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3757 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
3758 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3760 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
3761 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3763 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
3764 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3766 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
3767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3769 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
3770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3772 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
3773 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3775 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
3776 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3778 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
3779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3781 r = create_complocator_table(hdb);
3782 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3784 /* published component, machine, file, signature, misdbLocatorTypeFile */
3785 r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
3786 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3788 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
3789 r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
3790 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3792 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
3793 r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
3794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3796 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
3797 r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
3798 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3800 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
3801 r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
3802 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3804 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
3805 r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
3806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3808 /* published component, machine, file, no signature, misdbLocatorTypeFile */
3809 r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
3810 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3812 /* unpublished component, no signature, misdbLocatorTypeDir */
3813 r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
3814 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3816 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
3817 r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
3818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3820 /* published component, signature w/ ver, misdbLocatorTypeFile */
3821 r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
3822 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3824 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
3825 r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
3826 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3828 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
3829 r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
3830 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3832 r = create_signature_table(hdb);
3833 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3835 r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
3836 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3838 r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
3839 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3841 r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
3842 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3844 r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
3845 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3847 r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
3848 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3850 r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3851 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3853 r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3854 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3856 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3857 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3859 r = package_from_db(hdb, &hpkg);
3860 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3862 skip("Not enough rights to perform tests\n");
3865 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
3867 r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
3868 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3870 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3872 r = MsiDoAction(hpkg, "AppSearch");
3873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3876 sprintf(path, "%s\\FileName1", CURR_DIR);
3877 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
3878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3879 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3882 sprintf(path, "%s\\FileName2", CURR_DIR);
3883 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
3884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3885 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3888 sprintf(path, "%s\\FileName3", CURR_DIR);
3889 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
3890 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3891 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3894 sprintf(path, "%s\\FileName4", CURR_DIR);
3895 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
3896 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3897 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3900 sprintf(path, "%s\\FileName5", CURR_DIR);
3901 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
3902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3903 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3906 sprintf(path, "%s\\", CURR_DIR);
3907 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
3908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3909 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3912 sprintf(path, "%s\\", CURR_DIR);
3913 r = MsiGetPropertyA(hpkg, "SIGPROP7", 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 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
3919 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3920 ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
3923 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
3924 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3925 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3928 sprintf(path, "%s\\FileName8.dll", CURR_DIR);
3929 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
3930 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3931 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3934 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
3935 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3936 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3939 sprintf(path, "%s\\FileName10.dll", CURR_DIR);
3940 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
3941 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3942 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3944 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
3945 MSIINSTALLCONTEXT_MACHINE, NULL);
3946 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
3947 MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
3948 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
3949 MSIINSTALLCONTEXT_USERMANAGED, usersid);
3950 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
3951 MSIINSTALLCONTEXT_MACHINE, NULL);
3952 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
3953 MSIINSTALLCONTEXT_MACHINE, NULL);
3954 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
3955 MSIINSTALLCONTEXT_MACHINE, NULL);
3956 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
3957 MSIINSTALLCONTEXT_MACHINE, NULL);
3958 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
3959 MSIINSTALLCONTEXT_MACHINE, NULL);
3960 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
3961 MSIINSTALLCONTEXT_MACHINE, NULL);
3962 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
3963 MSIINSTALLCONTEXT_MACHINE, NULL);
3965 MsiCloseHandle(hpkg);
3968 DeleteFileA("FileName1");
3969 DeleteFileA("FileName2");
3970 DeleteFileA("FileName3");
3971 DeleteFileA("FileName4");
3972 DeleteFileA("FileName5");
3973 DeleteFileA("FileName6");
3974 DeleteFileA("FileName7");
3975 DeleteFileA("FileName8.dll");
3976 DeleteFileA("FileName9.dll");
3977 DeleteFileA("FileName10.dll");
3978 DeleteFileA(msifile);
3982 static void test_appsearch_reglocator(void)
3984 MSIHANDLE hpkg, hdb;
3985 CHAR path[MAX_PATH], prop[MAX_PATH];
3986 DWORD binary[2], size, val;
3987 BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
3988 HKEY hklm, classes, hkcu, users;
3989 LPSTR pathdata, pathvar, ptr;
3996 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
3999 DeleteFileA("test.dll");
4001 res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
4002 if (res == ERROR_ACCESS_DENIED)
4004 skip("Not enough rights to perform tests\n");
4007 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4009 res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
4010 (const BYTE *)"regszdata", 10);
4011 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4013 res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
4014 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4016 res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
4017 (const BYTE *)"regszdata", 10);
4018 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4021 res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
4022 ok(res == ERROR_SUCCESS ||
4023 broken(res == ERROR_INVALID_PARAMETER),
4024 "Expected ERROR_SUCCESS, got %d\n", res);
4026 if (res == ERROR_SUCCESS)
4028 res = RegSetValueExA(users, "Value1", 0, REG_SZ,
4029 (const BYTE *)"regszdata", 10);
4030 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4033 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
4034 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4036 res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
4037 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4039 res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
4040 (const BYTE *)"regszdata", 10);
4041 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4044 res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
4045 (const BYTE *)&val, sizeof(DWORD));
4046 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4049 res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
4050 (const BYTE *)&val, sizeof(DWORD));
4051 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4053 res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
4054 (const BYTE *)"%PATH%", 7);
4055 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4057 res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
4058 (const BYTE *)"my%NOVAR%", 10);
4059 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4061 res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
4062 (const BYTE *)"one\0two\0", 9);
4063 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4065 binary[0] = 0x1234abcd;
4066 binary[1] = 0x567890ef;
4067 res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
4068 (const BYTE *)binary, sizeof(binary));
4069 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4071 res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
4072 (const BYTE *)"#regszdata", 11);
4073 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4075 create_test_file("FileName1");
4076 sprintf(path, "%s\\FileName1", CURR_DIR);
4077 res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
4078 (const BYTE *)path, lstrlenA(path) + 1);
4079 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4081 sprintf(path, "%s\\FileName2", CURR_DIR);
4082 res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
4083 (const BYTE *)path, lstrlenA(path) + 1);
4084 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4086 lstrcpyA(path, CURR_DIR);
4087 res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
4088 (const BYTE *)path, lstrlenA(path) + 1);
4089 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4091 res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
4092 (const BYTE *)"", 1);
4093 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4095 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4096 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4097 res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
4098 (const BYTE *)path, lstrlenA(path) + 1);
4099 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4101 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4102 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4103 res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
4104 (const BYTE *)path, lstrlenA(path) + 1);
4105 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4107 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4108 sprintf(path, "%s\\FileName5.dll", CURR_DIR);
4109 res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
4110 (const BYTE *)path, lstrlenA(path) + 1);
4111 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4113 sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
4114 res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
4115 (const BYTE *)path, lstrlenA(path) + 1);
4116 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4118 space = strchr(CURR_DIR, ' ') != NULL;
4119 sprintf(path, "%s\\FileName1 -option", CURR_DIR);
4120 res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
4121 (const BYTE *)path, lstrlenA(path) + 1);
4122 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4124 hdb = create_package_db();
4125 ok(hdb, "Expected a valid database handle\n");
4127 r = create_appsearch_table(hdb);
4128 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4130 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4131 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4133 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4134 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4136 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4137 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4139 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4140 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4142 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4145 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4148 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4149 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4151 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4152 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4154 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4155 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4157 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4158 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4160 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4163 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4164 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4166 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
4167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4169 r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
4170 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4172 r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
4173 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4175 r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
4176 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4178 r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
4179 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4181 r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
4182 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4184 r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
4185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4187 r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
4188 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4190 r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
4191 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4193 r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
4194 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4196 r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
4197 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4199 r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
4200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4202 r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
4203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4205 r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
4206 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4208 r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
4209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4211 r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
4212 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4214 r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
4215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4217 r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
4218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4220 r = create_reglocator_table(hdb);
4221 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4223 type = msidbLocatorTypeRawValue;
4225 type |= msidbLocatorType64bit;
4227 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4228 r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
4229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4231 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4232 r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
4233 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4235 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4236 r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
4237 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4239 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4240 r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
4241 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4243 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4244 r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
4245 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4247 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4248 r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
4249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4251 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4252 r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
4253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4255 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4256 r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
4257 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4259 type = msidbLocatorTypeFileName;
4261 type |= msidbLocatorType64bit;
4263 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4264 r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
4265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4267 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4268 r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
4269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4271 /* HKLM, msidbLocatorTypeFileName, no signature */
4272 r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
4273 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4275 type = msidbLocatorTypeDirectory;
4277 type |= msidbLocatorType64bit;
4279 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4280 r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
4281 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4283 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4284 r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
4285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4287 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4288 r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
4289 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4291 type = msidbLocatorTypeRawValue;
4293 type |= msidbLocatorType64bit;
4295 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4296 r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
4297 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4299 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4300 r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
4301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4303 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4304 r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
4305 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4307 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4308 r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
4309 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4311 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4312 r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
4313 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4315 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4316 r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
4317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4319 type = msidbLocatorTypeFileName;
4321 type |= msidbLocatorType64bit;
4323 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4324 r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
4325 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4327 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4328 r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
4329 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4331 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4332 r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
4333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4335 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4336 r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
4337 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4339 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4340 r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
4341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4343 type = msidbLocatorTypeDirectory;
4345 type |= msidbLocatorType64bit;
4347 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4348 r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
4349 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4351 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4352 r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
4353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4355 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4356 r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
4357 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4359 type = msidbLocatorTypeFileName;
4361 type |= msidbLocatorType64bit;
4363 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4364 r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
4365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4367 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4368 r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
4369 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4371 r = create_signature_table(hdb);
4372 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4374 str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4375 r = add_signature_entry(hdb, str);
4376 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4378 str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4379 r = add_signature_entry(hdb, str);
4380 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4382 str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4383 r = add_signature_entry(hdb, str);
4384 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4386 str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4387 r = add_signature_entry(hdb, str);
4388 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4390 str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4391 r = add_signature_entry(hdb, str);
4392 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4394 str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4395 r = add_signature_entry(hdb, str);
4396 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4398 ptr = strrchr(CURR_DIR, '\\') + 1;
4399 sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
4400 r = add_signature_entry(hdb, path);
4401 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4403 str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4404 r = add_signature_entry(hdb, str);
4405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4407 str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4408 r = add_signature_entry(hdb, str);
4409 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4411 str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4412 r = add_signature_entry(hdb, str);
4413 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4415 r = package_from_db(hdb, &hpkg);
4416 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4418 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4420 r = MsiDoAction(hpkg, "AppSearch");
4421 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4424 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4425 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4426 ok(!lstrcmpA(prop, "regszdata"),
4427 "Expected \"regszdata\", got \"%s\"\n", prop);
4430 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4431 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4432 ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
4435 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4436 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4437 ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
4439 memset(&si, 0, sizeof(si));
4440 if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
4442 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
4444 size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
4445 pathvar = HeapAlloc(GetProcessHeap(), 0, size);
4446 ExpandEnvironmentStringsA("%PATH%", pathvar, size);
4449 r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
4450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4452 pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
4453 r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
4454 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4455 ok(!lstrcmpA(pathdata, pathvar),
4456 "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
4458 HeapFree(GetProcessHeap(), 0, pathvar);
4459 HeapFree(GetProcessHeap(), 0, pathdata);
4463 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4464 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4466 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
4469 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4470 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4473 ok(!memcmp(prop, "\0one\0two\0\0", 10),
4474 "Expected \"\\0one\\0two\\0\\0\"\n");
4478 lstrcpyA(path, "#xCDAB3412EF907856");
4479 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4480 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4481 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4484 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4485 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4486 ok(!lstrcmpA(prop, "##regszdata"),
4487 "Expected \"##regszdata\", got \"%s\"\n", prop);
4490 sprintf(path, "%s\\FileName1", CURR_DIR);
4491 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4492 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4493 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4496 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4497 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4498 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4501 sprintf(path, "%s\\", CURR_DIR);
4502 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4503 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4504 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4507 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4508 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4509 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4512 sprintf(path, "%s\\", CURR_DIR);
4513 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
4514 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4515 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4518 r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
4519 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4520 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4523 r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
4524 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4525 ok(!lstrcmpA(prop, "regszdata"),
4526 "Expected \"regszdata\", got \"%s\"\n", prop);
4529 r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
4530 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4531 ok(!lstrcmpA(prop, "regszdata"),
4532 "Expected \"regszdata\", got \"%s\"\n", prop);
4537 r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
4538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4539 ok(!lstrcmpA(prop, "regszdata"),
4540 "Expected \"regszdata\", got \"%s\"\n", prop);
4544 r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
4545 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4546 ok(!lstrcmpA(prop, "defvalue"),
4547 "Expected \"defvalue\", got \"%s\"\n", prop);
4550 r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
4551 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4552 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4555 r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
4556 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4557 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4562 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4563 r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
4564 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4565 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4568 r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
4569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4570 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4573 sprintf(path, "%s\\FileName5.dll", CURR_DIR);
4574 r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
4575 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4576 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4580 lstrcpyA(path, CURR_DIR);
4581 ptr = strrchr(path, '\\') + 1;
4583 r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
4584 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4585 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4588 sprintf(path, "%s\\", CURR_DIR);
4589 r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
4590 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4591 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4594 r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
4595 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4596 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4599 r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
4600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4601 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4604 r = MsiGetPropertyA(hpkg, "SIGPROP28", 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\\FileName1", CURR_DIR);
4610 r = MsiGetPropertyA(hpkg, "SIGPROP29", 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);
4615 sprintf(path, "%s\\FileName1", CURR_DIR);
4616 r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
4617 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4619 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4621 todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4623 RegSetValueA(hklm, NULL, REG_SZ, "", 0);
4624 RegDeleteValueA(hklm, "Value1");
4625 RegDeleteValueA(hklm, "Value2");
4626 RegDeleteValueA(hklm, "Value3");
4627 RegDeleteValueA(hklm, "Value4");
4628 RegDeleteValueA(hklm, "Value5");
4629 RegDeleteValueA(hklm, "Value6");
4630 RegDeleteValueA(hklm, "Value7");
4631 RegDeleteValueA(hklm, "Value8");
4632 RegDeleteValueA(hklm, "Value9");
4633 RegDeleteValueA(hklm, "Value10");
4634 RegDeleteValueA(hklm, "Value11");
4635 RegDeleteValueA(hklm, "Value12");
4636 RegDeleteValueA(hklm, "Value13");
4637 RegDeleteValueA(hklm, "Value14");
4638 RegDeleteValueA(hklm, "Value15");
4639 RegDeleteValueA(hklm, "Value16");
4640 RegDeleteValueA(hklm, "Value17");
4641 RegDeleteKey(hklm, "");
4644 RegDeleteValueA(classes, "Value1");
4645 RegDeleteKeyA(classes, "");
4646 RegCloseKey(classes);
4648 RegDeleteValueA(hkcu, "Value1");
4649 RegDeleteKeyA(hkcu, "");
4652 RegDeleteValueA(users, "Value1");
4653 RegDeleteKeyA(users, "");
4656 DeleteFileA("FileName1");
4657 DeleteFileA("FileName3.dll");
4658 DeleteFileA("FileName4.dll");
4659 DeleteFileA("FileName5.dll");
4660 MsiCloseHandle(hpkg);
4661 DeleteFileA(msifile);
4664 static void delete_win_ini(LPCSTR file)
4666 CHAR path[MAX_PATH];
4668 GetWindowsDirectoryA(path, MAX_PATH);
4669 lstrcatA(path, "\\");
4670 lstrcatA(path, file);
4675 static void test_appsearch_inilocator(void)
4677 MSIHANDLE hpkg, hdb;
4678 CHAR path[MAX_PATH];
4679 CHAR prop[MAX_PATH];
4687 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4690 DeleteFileA("test.dll");
4692 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4694 create_test_file("FileName1");
4695 sprintf(path, "%s\\FileName1", CURR_DIR);
4696 WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
4698 WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
4700 sprintf(path, "%s\\IDontExist", CURR_DIR);
4701 WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
4703 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4704 sprintf(path, "%s\\FileName2.dll", CURR_DIR);
4705 WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
4707 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4708 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4709 WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
4711 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4712 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4713 WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
4715 hdb = create_package_db();
4716 ok(hdb, "Expected a valid database handle\n");
4718 r = create_appsearch_table(hdb);
4719 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4721 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4722 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4724 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4725 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4727 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4730 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4731 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4733 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4734 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4736 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4737 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4739 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4740 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4742 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4743 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4745 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4746 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4748 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4749 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4751 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4752 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4754 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4755 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4757 r = create_inilocator_table(hdb);
4758 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4760 /* msidbLocatorTypeRawValue, field 1 */
4761 str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
4762 r = add_inilocator_entry(hdb, str);
4763 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4765 /* msidbLocatorTypeRawValue, field 2 */
4766 str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
4767 r = add_inilocator_entry(hdb, str);
4768 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4770 /* msidbLocatorTypeRawValue, entire field */
4771 str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
4772 r = add_inilocator_entry(hdb, str);
4773 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4775 /* msidbLocatorTypeFile */
4776 str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4777 r = add_inilocator_entry(hdb, str);
4778 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4780 /* msidbLocatorTypeDirectory, file */
4781 str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
4782 r = add_inilocator_entry(hdb, str);
4783 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4785 /* msidbLocatorTypeDirectory, directory */
4786 str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
4787 r = add_inilocator_entry(hdb, str);
4788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4790 /* msidbLocatorTypeFile, file, no signature */
4791 str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4792 r = add_inilocator_entry(hdb, str);
4793 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4795 /* msidbLocatorTypeFile, dir, no signature */
4796 str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
4797 r = add_inilocator_entry(hdb, str);
4798 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4800 /* msidbLocatorTypeFile, file does not exist */
4801 str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
4802 r = add_inilocator_entry(hdb, str);
4803 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4805 /* msidbLocatorTypeFile, signature with version */
4806 str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
4807 r = add_inilocator_entry(hdb, str);
4808 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4810 /* msidbLocatorTypeFile, signature with version, ver > max */
4811 str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
4812 r = add_inilocator_entry(hdb, str);
4813 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4815 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4816 str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
4817 r = add_inilocator_entry(hdb, str);
4818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4820 r = create_signature_table(hdb);
4821 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4823 r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4826 r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4827 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4829 r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4830 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4832 r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4833 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4835 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4836 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4838 r = package_from_db(hdb, &hpkg);
4839 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4841 skip("Not enough rights to perform tests\n");
4844 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4846 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4848 r = MsiDoAction(hpkg, "AppSearch");
4849 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4852 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4853 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4854 ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
4857 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4859 ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
4862 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4863 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4864 ok(!lstrcmpA(prop, "keydata,field2"),
4865 "Expected \"keydata,field2\", got \"%s\"\n", prop);
4868 sprintf(path, "%s\\FileName1", CURR_DIR);
4869 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
4870 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4871 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4874 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4875 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4876 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4879 sprintf(path, "%s\\", CURR_DIR);
4880 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4881 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4882 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4885 sprintf(path, "%s\\", CURR_DIR);
4886 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4887 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4888 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4891 lstrcpyA(path, CURR_DIR);
4892 ptr = strrchr(path, '\\');
4894 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4895 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4896 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4899 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4900 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4901 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4906 sprintf(path, "%s\\FileName2.dll", CURR_DIR);
4907 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4909 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4912 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4913 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4914 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4917 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4918 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4919 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4920 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4923 MsiCloseHandle(hpkg);
4926 delete_win_ini("IniFile.ini");
4927 DeleteFileA("FileName1");
4928 DeleteFileA("FileName2.dll");
4929 DeleteFileA("FileName3.dll");
4930 DeleteFileA("FileName4.dll");
4931 DeleteFileA(msifile);
4935 * MSI AppSearch action on DrLocator table always returns absolute paths.
4936 * If a relative path was set, it returns the first absolute path that
4937 * matches or an empty string if it didn't find anything.
4938 * This helper function replicates this behaviour.
4940 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
4945 size = lstrlenA(relative);
4946 drives = GetLogicalDrives();
4947 lstrcpyA(absolute, "A:\\");
4948 for (i = 0; i < 26; absolute[0] = '\0', i++)
4950 if (!(drives & (1 << i)))
4953 absolute[0] = 'A' + i;
4954 if (GetDriveType(absolute) != DRIVE_FIXED)
4957 lstrcpynA(absolute + 3, relative, size + 1);
4958 attr = GetFileAttributesA(absolute);
4959 if (attr != INVALID_FILE_ATTRIBUTES &&
4960 (attr & FILE_ATTRIBUTE_DIRECTORY))
4962 if (absolute[3 + size - 1] != '\\')
4963 lstrcatA(absolute, "\\");
4970 static void test_appsearch_drlocator(void)
4972 MSIHANDLE hpkg, hdb;
4973 CHAR path[MAX_PATH];
4974 CHAR prop[MAX_PATH];
4981 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4984 DeleteFileA("test.dll");
4986 create_test_file("FileName1");
4987 CreateDirectoryA("one", NULL);
4988 CreateDirectoryA("one\\two", NULL);
4989 CreateDirectoryA("one\\two\\three", NULL);
4990 create_test_file("one\\two\\three\\FileName2");
4991 CreateDirectoryA("another", NULL);
4992 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4993 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4994 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4996 hdb = create_package_db();
4997 ok(hdb, "Expected a valid database handle\n");
4999 r = create_appsearch_table(hdb);
5000 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5002 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5003 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5005 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5008 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5009 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5011 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5012 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5014 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5015 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5017 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5018 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5020 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5021 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5023 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5026 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5027 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5029 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
5030 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5032 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
5033 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5035 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
5036 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5038 r = create_drlocator_table(hdb);
5039 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5041 /* no parent, full path, depth 0, signature */
5042 sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
5043 r = add_drlocator_entry(hdb, path);
5044 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5046 /* no parent, full path, depth 0, no signature */
5047 sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
5048 r = add_drlocator_entry(hdb, path);
5049 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5051 /* no parent, relative path, depth 0, no signature */
5052 sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
5053 r = add_drlocator_entry(hdb, path);
5054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5056 /* no parent, full path, depth 2, signature */
5057 sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
5058 r = add_drlocator_entry(hdb, path);
5059 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5061 /* no parent, full path, depth 3, signature */
5062 sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
5063 r = add_drlocator_entry(hdb, path);
5064 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5066 /* no parent, full path, depth 1, signature is dir */
5067 sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
5068 r = add_drlocator_entry(hdb, path);
5069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5071 /* parent is in DrLocator, relative path, depth 0, signature */
5072 sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5073 r = add_drlocator_entry(hdb, path);
5074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5076 /* no parent, full path, depth 0, signature w/ version */
5077 sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
5078 r = add_drlocator_entry(hdb, path);
5079 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5081 /* no parent, full path, depth 0, signature w/ version, ver > max */
5082 sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
5083 r = add_drlocator_entry(hdb, path);
5084 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5086 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5087 sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
5088 r = add_drlocator_entry(hdb, path);
5089 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5091 /* no parent, relative empty path, depth 0, no signature */
5092 sprintf(path, "'NewSignature11', '', '', 0");
5093 r = add_drlocator_entry(hdb, path);
5094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5096 r = create_reglocator_table(hdb);
5097 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5100 r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5103 /* parent is in RegLocator, no path, depth 0, no signature */
5104 sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
5105 r = add_drlocator_entry(hdb, path);
5106 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5108 r = create_signature_table(hdb);
5109 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5111 str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5112 r = add_signature_entry(hdb, str);
5113 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5115 str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5116 r = add_signature_entry(hdb, str);
5117 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5119 str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5120 r = add_signature_entry(hdb, str);
5121 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5123 str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5124 r = add_signature_entry(hdb, str);
5125 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5127 str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5128 r = add_signature_entry(hdb, str);
5129 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5131 str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5132 r = add_signature_entry(hdb, str);
5133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5135 str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5136 r = add_signature_entry(hdb, str);
5137 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5139 str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5140 r = add_signature_entry(hdb, str);
5141 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5143 r = package_from_db(hdb, &hpkg);
5144 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5146 skip("Not enough rights to perform tests\n");
5149 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5151 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5153 r = MsiDoAction(hpkg, "AppSearch");
5154 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5157 sprintf(path, "%s\\FileName1", CURR_DIR);
5158 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5160 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5163 sprintf(path, "%s\\", CURR_DIR);
5164 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5165 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5166 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5169 search_absolute_directory(path, CURR_DIR + 3);
5170 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5171 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5172 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5175 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5176 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5177 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5180 sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
5181 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5182 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5183 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5186 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5187 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5188 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5191 sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
5192 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5194 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5199 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
5200 r = MsiGetPropertyA(hpkg, "SIGPROP8", 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 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5206 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5207 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5210 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5211 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5212 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5216 search_absolute_directory(path, "");
5217 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5219 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5222 strcpy(path, "c:\\");
5223 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
5224 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5225 ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
5227 MsiCloseHandle(hpkg);
5230 DeleteFileA("FileName1");
5231 DeleteFileA("FileName3.dll");
5232 DeleteFileA("FileName4.dll");
5233 DeleteFileA("FileName5.dll");
5234 DeleteFileA("one\\two\\three\\FileName2");
5235 RemoveDirectoryA("one\\two\\three");
5236 RemoveDirectoryA("one\\two");
5237 RemoveDirectoryA("one");
5238 RemoveDirectoryA("another");
5239 DeleteFileA(msifile);
5242 static void test_featureparents(void)
5248 hdb = create_package_db();
5249 ok ( hdb, "failed to create package database\n" );
5251 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
5252 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
5254 r = create_feature_table( hdb );
5255 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
5257 r = create_component_table( hdb );
5258 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
5260 r = create_feature_components_table( hdb );
5261 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
5263 r = create_file_table( hdb );
5264 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
5266 /* msidbFeatureAttributesFavorLocal */
5267 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
5268 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5270 /* msidbFeatureAttributesFavorSource */
5271 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
5272 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5274 /* msidbFeatureAttributesFavorLocal */
5275 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
5276 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5278 /* msidbFeatureAttributesUIDisallowAbsent */
5279 r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
5280 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5282 /* disabled because of install level */
5283 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
5284 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5286 /* child feature of disabled feature */
5287 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5288 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5290 /* component of disabled feature (install level) */
5291 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5292 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5294 /* component of disabled child feature (install level) */
5295 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5296 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5298 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5299 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5300 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5302 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5303 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5304 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5306 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5307 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5308 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5310 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5311 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5312 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5314 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5315 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5316 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5318 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5319 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5320 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5322 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5323 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5324 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5326 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5327 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5328 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5330 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5331 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5332 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5334 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
5335 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5337 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
5338 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5340 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
5341 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5343 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
5344 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5346 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
5347 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5349 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
5350 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5352 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
5353 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5355 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
5356 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5358 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
5359 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5361 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
5362 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5364 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
5365 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5367 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
5368 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5370 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
5371 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5373 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
5374 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5376 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
5377 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5379 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
5380 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5382 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
5383 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5385 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5386 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5388 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5389 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5391 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5392 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5394 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5395 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5397 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5398 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5400 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5401 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5403 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5404 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5406 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5407 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5409 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5410 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5412 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5413 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5415 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5416 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5418 r = package_from_db( hdb, &hpkg );
5419 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5421 skip("Not enough rights to perform tests\n");
5422 DeleteFile(msifile);
5425 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5427 MsiCloseHandle( hdb );
5429 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5431 r = MsiDoAction( hpkg, "CostInitialize");
5432 ok( r == ERROR_SUCCESS, "cost init failed\n");
5434 r = MsiDoAction( hpkg, "FileCost");
5435 ok( r == ERROR_SUCCESS, "file cost failed\n");
5437 r = MsiDoAction( hpkg, "CostFinalize");
5438 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5440 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5441 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
5442 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5443 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5444 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5445 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5447 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5448 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5449 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5450 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5451 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5452 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5453 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5454 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5455 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5456 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5457 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5459 r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
5460 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5462 r = MsiSetFeatureState(hpkg, "lyra", INSTALLSTATE_ABSENT);
5463 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5465 r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
5466 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
5468 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5469 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
5470 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, 0 );
5471 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, 0 );
5472 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5473 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5475 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5476 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5477 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5478 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5479 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5480 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5481 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5482 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5483 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5484 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5485 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5487 MsiCloseHandle(hpkg);
5488 DeleteFileA(msifile);
5491 static void test_installprops(void)
5493 MSIHANDLE hpkg, hdb;
5494 CHAR path[MAX_PATH], buf[MAX_PATH];
5500 REGSAM access = KEY_ALL_ACCESS;
5502 INSTALLUILEVEL uilevel;
5505 access |= KEY_WOW64_64KEY;
5507 GetCurrentDirectory(MAX_PATH, path);
5508 lstrcat(path, "\\");
5509 lstrcat(path, msifile);
5511 uilevel = MsiSetInternalUI(INSTALLUILEVEL_BASIC|INSTALLUILEVEL_SOURCERESONLY, NULL);
5513 hdb = create_package_db();
5514 ok( hdb, "failed to create database\n");
5516 r = package_from_db(hdb, &hpkg);
5517 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5519 skip("Not enough rights to perform tests\n");
5520 MsiSetInternalUI(uilevel, NULL);
5521 DeleteFile(msifile);
5524 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5526 MsiCloseHandle(hdb);
5530 r = MsiGetProperty(hpkg, "UILevel", buf, &size);
5531 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5532 ok( !lstrcmp(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5534 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5538 r = MsiGetProperty(hpkg, "UILevel", buf, &size);
5539 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5540 ok( !lstrcmp(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5544 r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
5545 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5546 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5548 RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
5549 RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
5554 if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5558 RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
5563 r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
5564 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5565 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5570 if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5574 RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
5581 r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
5582 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5583 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5588 r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
5589 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5590 trace("VersionDatabase = %s\n", buf);
5594 r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
5595 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5596 trace("VersionMsi = %s\n", buf);
5600 r = MsiGetProperty(hpkg, "Date", buf, &size);
5601 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5602 trace("Date = %s\n", buf);
5606 r = MsiGetProperty(hpkg, "Time", buf, &size);
5607 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5608 trace("Time = %s\n", buf);
5612 r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
5613 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5614 trace("PackageCode = %s\n", buf);
5618 r = MsiGetProperty(hpkg, "ComputerName", buf, &size);
5619 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5620 trace("ComputerName = %s\n", buf);
5622 langid = GetUserDefaultLangID();
5623 sprintf(path, "%d", langid);
5627 r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
5628 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5629 ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
5631 res = GetSystemMetrics(SM_CXSCREEN);
5634 r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
5635 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5636 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5638 res = GetSystemMetrics(SM_CYSCREEN);
5641 r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
5642 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5643 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5645 if (pGetSystemInfo && pSHGetFolderPathA)
5647 pGetSystemInfo(&si);
5648 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
5652 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5653 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5654 ok(buf[0], "property not set\n");
5658 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5659 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5660 ok(buf[0], "property not set\n");
5664 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5665 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5666 ok(buf[0], "property not set\n");
5670 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5671 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5672 GetSystemDirectoryA(path, MAX_PATH);
5673 if (size) buf[size - 1] = 0;
5674 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5678 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5679 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5680 pGetSystemWow64DirectoryA(path, MAX_PATH);
5681 if (size) buf[size - 1] = 0;
5682 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5686 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
5687 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5688 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5689 if (size) buf[size - 1] = 0;
5690 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5694 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5695 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5696 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5697 if (size) buf[size - 1] = 0;
5698 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5702 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
5703 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5704 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5705 if (size) buf[size - 1] = 0;
5706 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5710 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5711 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5712 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5713 if (size) buf[size - 1] = 0;
5714 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5718 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5719 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5720 ok(buf[0], "property not set\n");
5722 else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
5728 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5729 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5730 ok(buf[0], "property not set\n");
5734 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5735 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5736 ok(!buf[0], "property set\n");
5740 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5741 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5742 ok(!buf[0], "property set\n");
5746 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5747 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5748 ok(!buf[0], "property set\n");
5752 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5753 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5754 GetSystemDirectoryA(path, MAX_PATH);
5755 if (size) buf[size - 1] = 0;
5756 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5760 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
5761 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5762 ok(!buf[0], "property set\n");
5766 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5767 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5768 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5769 if (size) buf[size - 1] = 0;
5770 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5774 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
5775 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5776 ok(!buf[0], "property set\n");
5780 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5781 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5782 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5783 if (size) buf[size - 1] = 0;
5784 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5788 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5789 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5790 ok(!buf[0], "property set\n");
5796 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5797 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5798 ok(buf[0], "property not set\n");
5802 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5803 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5804 ok(buf[0], "property not set\n");
5808 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5809 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5810 ok(buf[0], "property not set\n");
5814 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5815 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5816 GetSystemDirectoryA(path, MAX_PATH);
5817 if (size) buf[size - 1] = 0;
5818 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5822 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5823 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5824 pGetSystemWow64DirectoryA(path, MAX_PATH);
5825 if (size) buf[size - 1] = 0;
5826 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5830 r = MsiGetProperty(hpkg, "ProgramFilesFolder64", buf, &size);
5831 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5832 ok(!buf[0], "property set\n");
5836 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5837 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5838 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5839 if (size) buf[size - 1] = 0;
5840 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5844 r = MsiGetProperty(hpkg, "CommonFilesFolder64", buf, &size);
5845 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5846 ok(!buf[0], "property set\n");
5850 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5851 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5852 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5853 if (size) buf[size - 1] = 0;
5854 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5858 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5859 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5860 ok(buf[0], "property not set\n");
5867 MsiCloseHandle(hpkg);
5868 DeleteFile(msifile);
5869 MsiSetInternalUI(uilevel, NULL);
5872 static void test_launchconditions(void)
5878 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5880 hdb = create_package_db();
5881 ok( hdb, "failed to create package database\n" );
5883 r = create_launchcondition_table( hdb );
5884 ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
5886 r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
5887 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
5889 /* invalid condition */
5890 r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
5891 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
5893 r = package_from_db( hdb, &hpkg );
5894 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5896 skip("Not enough rights to perform tests\n");
5897 DeleteFile(msifile);
5900 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5902 MsiCloseHandle( hdb );
5904 r = MsiSetProperty( hpkg, "X", "1" );
5905 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5907 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5909 /* invalid conditions are ignored */
5910 r = MsiDoAction( hpkg, "LaunchConditions" );
5911 ok( r == ERROR_SUCCESS, "cost init failed\n" );
5913 /* verify LaunchConditions still does some verification */
5914 r = MsiSetProperty( hpkg, "X", "2" );
5915 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5917 r = MsiDoAction( hpkg, "LaunchConditions" );
5918 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
5920 MsiCloseHandle( hpkg );
5921 DeleteFile( msifile );
5924 static void test_ccpsearch(void)
5926 MSIHANDLE hdb, hpkg;
5927 CHAR prop[MAX_PATH];
5928 DWORD size = MAX_PATH;
5931 hdb = create_package_db();
5932 ok(hdb, "failed to create package database\n");
5934 r = create_ccpsearch_table(hdb);
5935 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5937 r = add_ccpsearch_entry(hdb, "'CCP_random'");
5938 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5940 r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
5941 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5943 r = create_reglocator_table(hdb);
5944 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5946 r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
5947 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5949 r = create_drlocator_table(hdb);
5950 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5952 r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
5953 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5955 r = create_signature_table(hdb);
5956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5958 r = package_from_db(hdb, &hpkg);
5959 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5961 skip("Not enough rights to perform tests\n");
5962 DeleteFile(msifile);
5965 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
5967 MsiCloseHandle(hdb);
5969 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5971 r = MsiDoAction(hpkg, "CCPSearch");
5972 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5974 r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
5975 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5976 ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
5978 MsiCloseHandle(hpkg);
5979 DeleteFileA(msifile);
5982 static void test_complocator(void)
5984 MSIHANDLE hdb, hpkg;
5986 CHAR prop[MAX_PATH];
5987 CHAR expected[MAX_PATH];
5988 DWORD size = MAX_PATH;
5990 hdb = create_package_db();
5991 ok(hdb, "failed to create package database\n");
5993 r = create_appsearch_table(hdb);
5994 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5996 r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
5997 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5999 r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
6000 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6002 r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
6003 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6005 r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
6006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6008 r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
6009 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6011 r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
6012 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6014 r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
6015 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6017 r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
6018 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6020 r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
6021 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6023 r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
6024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6026 r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
6027 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6029 r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
6030 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6032 r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
6033 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6035 r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
6036 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6038 r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
6039 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6041 r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
6042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6044 r = create_complocator_table(hdb);
6045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6047 r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6048 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6050 r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6053 r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6056 r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6057 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6059 r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6060 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6062 r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6063 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6065 r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6068 r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6071 r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6072 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6074 r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6075 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6077 r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6078 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6080 r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6083 r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6084 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6086 r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6087 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6089 r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6090 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6092 r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6093 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6095 r = create_signature_table(hdb);
6096 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6098 r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6099 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6101 r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6102 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6104 r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6105 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6107 r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6108 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6110 r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6111 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6113 r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6114 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6116 r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6117 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6119 r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6120 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6122 r = package_from_db(hdb, &hpkg);
6123 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6125 skip("Not enough rights to perform tests\n");
6126 DeleteFile(msifile);
6129 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6131 MsiCloseHandle(hdb);
6133 create_test_file("abelisaurus");
6134 create_test_file("bactrosaurus");
6135 create_test_file("camelotia");
6136 create_test_file("diclonius");
6137 create_test_file("echinodon");
6138 create_test_file("falcarius");
6139 create_test_file("gallimimus");
6140 create_test_file("hagryphus");
6141 CreateDirectoryA("iguanodon", NULL);
6142 CreateDirectoryA("jobaria", NULL);
6143 CreateDirectoryA("kakuru", NULL);
6144 CreateDirectoryA("labocania", NULL);
6145 CreateDirectoryA("megaraptor", NULL);
6146 CreateDirectoryA("neosodon", NULL);
6147 CreateDirectoryA("olorotitan", NULL);
6148 CreateDirectoryA("pantydraco", NULL);
6150 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
6151 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
6152 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
6153 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
6154 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
6155 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
6156 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
6157 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
6158 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
6159 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
6160 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
6161 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
6162 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
6163 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
6164 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
6165 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
6167 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6169 r = MsiDoAction(hpkg, "AppSearch");
6170 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6173 r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
6174 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6176 lstrcpyA(expected, CURR_DIR);
6177 lstrcatA(expected, "\\abelisaurus");
6178 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6179 "Expected %s or empty string, got %s\n", expected, prop);
6182 r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
6183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6184 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6187 r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
6188 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6189 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6192 r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
6193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6194 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6197 r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
6198 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6200 lstrcpyA(expected, CURR_DIR);
6201 lstrcatA(expected, "\\");
6202 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6203 "Expected %s or empty string, got %s\n", expected, prop);
6206 r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
6207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6208 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6211 r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
6212 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6213 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6216 r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
6217 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6218 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6221 r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
6222 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6223 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6226 r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
6227 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6228 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6231 r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
6232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6233 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6236 r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
6237 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6238 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6241 r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
6242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6244 lstrcpyA(expected, CURR_DIR);
6245 lstrcatA(expected, "\\");
6246 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6247 "Expected %s or empty string, got %s\n", expected, prop);
6250 r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
6251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6253 lstrcpyA(expected, CURR_DIR);
6254 lstrcatA(expected, "\\neosodon\\");
6255 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6256 "Expected %s or empty string, got %s\n", expected, prop);
6259 r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
6260 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6261 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6264 r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
6265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6266 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6268 MsiCloseHandle(hpkg);
6269 DeleteFileA("abelisaurus");
6270 DeleteFileA("bactrosaurus");
6271 DeleteFileA("camelotia");
6272 DeleteFileA("diclonius");
6273 DeleteFileA("echinodon");
6274 DeleteFileA("falcarius");
6275 DeleteFileA("gallimimus");
6276 DeleteFileA("hagryphus");
6277 RemoveDirectoryA("iguanodon");
6278 RemoveDirectoryA("jobaria");
6279 RemoveDirectoryA("kakuru");
6280 RemoveDirectoryA("labocania");
6281 RemoveDirectoryA("megaraptor");
6282 RemoveDirectoryA("neosodon");
6283 RemoveDirectoryA("olorotitan");
6284 RemoveDirectoryA("pantydraco");
6285 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6286 MSIINSTALLCONTEXT_MACHINE, NULL);
6287 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6288 MSIINSTALLCONTEXT_MACHINE, NULL);
6289 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6290 MSIINSTALLCONTEXT_MACHINE, NULL);
6291 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6292 MSIINSTALLCONTEXT_MACHINE, NULL);
6293 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6294 MSIINSTALLCONTEXT_MACHINE, NULL);
6295 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6296 MSIINSTALLCONTEXT_MACHINE, NULL);
6297 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6298 MSIINSTALLCONTEXT_MACHINE, NULL);
6299 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6300 MSIINSTALLCONTEXT_MACHINE, NULL);
6301 DeleteFileA(msifile);
6304 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
6309 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6310 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6312 r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
6313 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6315 r = MsiSummaryInfoPersist(summary);
6316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6318 MsiCloseHandle(summary);
6321 static void test_MsiGetSourcePath(void)
6323 MSIHANDLE hdb, hpkg;
6324 CHAR path[MAX_PATH];
6326 CHAR subsrc[MAX_PATH];
6327 CHAR sub2[MAX_PATH];
6331 lstrcpyA(cwd, CURR_DIR);
6332 lstrcatA(cwd, "\\");
6334 lstrcpyA(subsrc, cwd);
6335 lstrcatA(subsrc, "subsource");
6336 lstrcatA(subsrc, "\\");
6338 lstrcpyA(sub2, subsrc);
6339 lstrcatA(sub2, "sub2");
6340 lstrcatA(sub2, "\\");
6342 /* uncompressed source */
6344 hdb = create_package_db();
6345 ok( hdb, "failed to create database\n");
6347 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
6349 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
6350 ok(r == S_OK, "failed\n");
6352 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6353 ok(r == S_OK, "failed\n");
6355 r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
6356 ok(r == S_OK, "failed\n");
6358 r = MsiDatabaseCommit(hdb);
6359 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6361 r = package_from_db(hdb, &hpkg);
6362 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6364 skip("Not enough rights to perform tests\n");
6365 DeleteFile(msifile);
6368 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6370 MsiCloseHandle(hdb);
6372 /* invalid database handle */
6374 lstrcpyA(path, "kiwi");
6375 r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
6376 ok(r == ERROR_INVALID_HANDLE,
6377 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
6378 ok(!lstrcmpA(path, "kiwi"),
6379 "Expected path to be unchanged, got \"%s\"\n", path);
6380 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6384 lstrcpyA(path, "kiwi");
6385 r = MsiGetSourcePath(hpkg, NULL, path, &size);
6386 ok(r == ERROR_INVALID_PARAMETER,
6387 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6388 ok(!lstrcmpA(path, "kiwi"),
6389 "Expected path to be unchanged, got \"%s\"\n", path);
6390 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6392 /* empty szFolder */
6394 lstrcpyA(path, "kiwi");
6395 r = MsiGetSourcePath(hpkg, "", path, &size);
6396 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6397 ok(!lstrcmpA(path, "kiwi"),
6398 "Expected path to be unchanged, got \"%s\"\n", path);
6399 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6403 lstrcpyA(path, "kiwi");
6404 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6405 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6406 ok(!lstrcmpA(path, "kiwi"),
6407 "Expected path to be unchanged, got \"%s\"\n", path);
6408 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6411 lstrcpyA(path, "kiwi");
6412 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6413 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6414 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6415 ok(size == 0, "Expected 0, got %d\n", size);
6418 lstrcpyA(path, "kiwi");
6419 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6420 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6421 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6422 ok(size == 0, "Expected 0, got %d\n", size);
6426 lstrcpyA(path, "kiwi");
6427 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6428 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6429 ok(!lstrcmpA(path, "kiwi"),
6430 "Expected path to be unchanged, got \"%s\"\n", path);
6431 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6435 lstrcpyA(path, "kiwi");
6436 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6437 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6438 ok(!lstrcmpA(path, "kiwi"),
6439 "Expected path to be unchanged, got \"%s\"\n", path);
6440 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6442 /* source path does not exist, but the property exists */
6444 lstrcpyA(path, "kiwi");
6445 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6446 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6447 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6448 ok(size == 0, "Expected 0, got %d\n", size);
6451 lstrcpyA(path, "kiwi");
6452 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6453 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6454 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6455 ok(size == 0, "Expected 0, got %d\n", size);
6459 lstrcpyA(path, "kiwi");
6460 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6461 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6462 ok(!lstrcmpA(path, "kiwi"),
6463 "Expected path to be unchanged, got \"%s\"\n", path);
6464 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6468 lstrcpyA(path, "kiwi");
6469 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6470 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6471 ok(!lstrcmpA(path, "kiwi"),
6472 "Expected path to be unchanged, got \"%s\"\n", path);
6473 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6475 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6477 r = MsiDoAction(hpkg, "CostInitialize");
6478 ok(r == ERROR_SUCCESS, "cost init failed\n");
6480 /* try TARGETDIR after CostInitialize */
6482 lstrcpyA(path, "kiwi");
6483 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6484 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6485 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6486 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6488 /* try SourceDir after CostInitialize */
6490 lstrcpyA(path, "kiwi");
6491 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6492 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6493 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6494 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6496 /* try SOURCEDIR after CostInitialize */
6498 lstrcpyA(path, "kiwi");
6499 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6500 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6501 ok(!lstrcmpA(path, "kiwi"),
6502 "Expected path to be unchanged, got \"%s\"\n", path);
6503 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6505 /* source path does not exist, but the property exists */
6507 lstrcpyA(path, "kiwi");
6508 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6509 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6510 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6511 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6514 lstrcpyA(path, "kiwi");
6515 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6516 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6517 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6518 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6520 /* try SubDir after CostInitialize */
6522 lstrcpyA(path, "kiwi");
6523 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6524 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6525 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6526 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6528 /* try SubDir2 after CostInitialize */
6530 lstrcpyA(path, "kiwi");
6531 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6532 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6533 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6534 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6536 r = MsiDoAction(hpkg, "ResolveSource");
6537 ok(r == ERROR_SUCCESS, "file cost failed\n");
6539 /* try TARGETDIR after ResolveSource */
6541 lstrcpyA(path, "kiwi");
6542 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6543 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6544 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6545 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6547 /* try SourceDir after ResolveSource */
6549 lstrcpyA(path, "kiwi");
6550 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6551 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6552 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6553 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6555 /* try SOURCEDIR after ResolveSource */
6557 lstrcpyA(path, "kiwi");
6558 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6559 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6560 ok(!lstrcmpA(path, "kiwi"),
6561 "Expected path to be unchanged, got \"%s\"\n", path);
6562 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6564 /* source path does not exist, but the property exists */
6566 lstrcpyA(path, "kiwi");
6567 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6568 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6569 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6570 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6573 lstrcpyA(path, "kiwi");
6574 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6575 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6576 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6577 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6579 /* try SubDir after ResolveSource */
6581 lstrcpyA(path, "kiwi");
6582 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6583 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6584 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6585 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6587 /* try SubDir2 after ResolveSource */
6589 lstrcpyA(path, "kiwi");
6590 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6591 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6592 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6593 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6595 r = MsiDoAction(hpkg, "FileCost");
6596 ok(r == ERROR_SUCCESS, "file cost failed\n");
6598 /* try TARGETDIR after FileCost */
6600 lstrcpyA(path, "kiwi");
6601 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6602 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6603 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6604 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6606 /* try SourceDir after FileCost */
6608 lstrcpyA(path, "kiwi");
6609 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6610 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6611 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6612 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6614 /* try SOURCEDIR after FileCost */
6616 lstrcpyA(path, "kiwi");
6617 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6618 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6619 ok(!lstrcmpA(path, "kiwi"),
6620 "Expected path to be unchanged, got \"%s\"\n", path);
6621 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6623 /* source path does not exist, but the property exists */
6625 lstrcpyA(path, "kiwi");
6626 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6628 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6629 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6632 lstrcpyA(path, "kiwi");
6633 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6634 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6635 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6636 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6638 /* try SubDir after FileCost */
6640 lstrcpyA(path, "kiwi");
6641 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6642 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6643 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6644 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6646 /* try SubDir2 after FileCost */
6648 lstrcpyA(path, "kiwi");
6649 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6650 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6651 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6652 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6654 r = MsiDoAction(hpkg, "CostFinalize");
6655 ok(r == ERROR_SUCCESS, "file cost failed\n");
6657 /* try TARGETDIR after CostFinalize */
6659 lstrcpyA(path, "kiwi");
6660 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6661 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6662 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6663 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6665 /* try SourceDir after CostFinalize */
6667 lstrcpyA(path, "kiwi");
6668 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6669 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6670 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6671 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6673 /* try SOURCEDIR after CostFinalize */
6675 lstrcpyA(path, "kiwi");
6676 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6677 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6678 ok(!lstrcmpA(path, "kiwi"),
6679 "Expected path to be unchanged, got \"%s\"\n", path);
6680 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6682 /* source path does not exist, but the property exists */
6684 lstrcpyA(path, "kiwi");
6685 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6686 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6687 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6688 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6691 lstrcpyA(path, "kiwi");
6692 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6693 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6694 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6695 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6697 /* try SubDir after CostFinalize */
6699 lstrcpyA(path, "kiwi");
6700 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6701 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6702 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6703 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6705 /* try SubDir2 after CostFinalize */
6707 lstrcpyA(path, "kiwi");
6708 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6709 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6710 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6711 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6713 /* nonexistent directory */
6715 lstrcpyA(path, "kiwi");
6716 r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
6717 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6718 ok(!lstrcmpA(path, "kiwi"),
6719 "Expected path to be unchanged, got \"%s\"\n", path);
6720 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6722 /* NULL szPathBuf */
6724 r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
6725 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6726 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6728 /* NULL pcchPathBuf */
6729 lstrcpyA(path, "kiwi");
6730 r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
6731 ok(r == ERROR_INVALID_PARAMETER,
6732 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6733 ok(!lstrcmpA(path, "kiwi"),
6734 "Expected path to be unchanged, got \"%s\"\n", path);
6736 /* pcchPathBuf is 0 */
6738 lstrcpyA(path, "kiwi");
6739 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6740 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6741 ok(!lstrcmpA(path, "kiwi"),
6742 "Expected path to be unchanged, got \"%s\"\n", path);
6743 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6745 /* pcchPathBuf does not have room for NULL terminator */
6746 size = lstrlenA(cwd);
6747 lstrcpyA(path, "kiwi");
6748 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6749 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6750 ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
6751 "Expected path with no backslash, got \"%s\"\n", path);
6752 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6754 /* pcchPathBuf has room for NULL terminator */
6755 size = lstrlenA(cwd) + 1;
6756 lstrcpyA(path, "kiwi");
6757 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6758 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6759 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6760 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6762 /* remove property */
6763 r = MsiSetProperty(hpkg, "SourceDir", NULL);
6764 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6766 /* try SourceDir again */
6768 lstrcpyA(path, "kiwi");
6769 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6771 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6772 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6774 /* set property to a valid directory */
6775 r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
6776 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6778 /* try SOURCEDIR again */
6780 lstrcpyA(path, "kiwi");
6781 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6782 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6783 ok(!lstrcmpA(path, "kiwi"),
6784 "Expected path to be unchanged, got \"%s\"\n", path);
6785 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6787 MsiCloseHandle(hpkg);
6789 /* compressed source */
6791 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
6792 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6794 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
6796 r = package_from_db(hdb, &hpkg);
6797 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6801 lstrcpyA(path, "kiwi");
6802 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6803 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6804 ok(!lstrcmpA(path, "kiwi"),
6805 "Expected path to be unchanged, got \"%s\"\n", path);
6806 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6810 lstrcpyA(path, "kiwi");
6811 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6812 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6813 ok(!lstrcmpA(path, "kiwi"),
6814 "Expected path to be unchanged, got \"%s\"\n", path);
6815 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6819 lstrcpyA(path, "kiwi");
6820 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6821 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6822 ok(!lstrcmpA(path, "kiwi"),
6823 "Expected path to be unchanged, got \"%s\"\n", path);
6824 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6826 /* source path nor the property exist */
6828 lstrcpyA(path, "kiwi");
6829 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6830 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6831 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6832 ok(size == 0, "Expected 0, got %d\n", size);
6835 lstrcpyA(path, "kiwi");
6836 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6837 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6838 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6839 ok(size == 0, "Expected 0, got %d\n", size);
6843 lstrcpyA(path, "kiwi");
6844 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6845 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6846 ok(!lstrcmpA(path, "kiwi"),
6847 "Expected path to be unchanged, got \"%s\"\n", path);
6848 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6852 lstrcpyA(path, "kiwi");
6853 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6854 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6855 ok(!lstrcmpA(path, "kiwi"),
6856 "Expected path to be unchanged, got \"%s\"\n", path);
6857 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6859 r = MsiDoAction(hpkg, "CostInitialize");
6860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6862 /* try TARGETDIR after CostInitialize */
6864 lstrcpyA(path, "kiwi");
6865 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6866 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6867 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6868 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6870 /* try SourceDir after CostInitialize */
6872 lstrcpyA(path, "kiwi");
6873 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6874 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6875 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6876 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6878 /* try SOURCEDIR after CostInitialize */
6880 lstrcpyA(path, "kiwi");
6881 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6885 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6886 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6889 /* source path does not exist, but the property exists */
6891 lstrcpyA(path, "kiwi");
6892 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6893 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6894 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6895 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6898 lstrcpyA(path, "kiwi");
6899 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6900 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6901 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6902 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6904 /* try SubDir after CostInitialize */
6906 lstrcpyA(path, "kiwi");
6907 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6909 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6910 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6912 /* try SubDir2 after CostInitialize */
6914 lstrcpyA(path, "kiwi");
6915 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6916 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6917 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6918 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6920 r = MsiDoAction(hpkg, "ResolveSource");
6921 ok(r == ERROR_SUCCESS, "file cost failed\n");
6923 /* try TARGETDIR after ResolveSource */
6925 lstrcpyA(path, "kiwi");
6926 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6927 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6928 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6929 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6931 /* try SourceDir after ResolveSource */
6933 lstrcpyA(path, "kiwi");
6934 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6935 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6936 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6937 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6939 /* try SOURCEDIR after ResolveSource */
6941 lstrcpyA(path, "kiwi");
6942 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6945 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6946 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6947 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6950 /* source path and the property exist */
6952 lstrcpyA(path, "kiwi");
6953 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6954 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6955 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6956 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6959 lstrcpyA(path, "kiwi");
6960 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6961 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6962 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6963 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6965 /* try SubDir after ResolveSource */
6967 lstrcpyA(path, "kiwi");
6968 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6970 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6971 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6973 /* try SubDir2 after ResolveSource */
6975 lstrcpyA(path, "kiwi");
6976 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6977 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6978 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6979 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6981 r = MsiDoAction(hpkg, "FileCost");
6982 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6984 /* try TARGETDIR after CostFinalize */
6986 lstrcpyA(path, "kiwi");
6987 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6988 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6989 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6990 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6992 /* try SourceDir after CostFinalize */
6994 lstrcpyA(path, "kiwi");
6995 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6997 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6998 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7000 /* try SOURCEDIR after CostFinalize */
7002 lstrcpyA(path, "kiwi");
7003 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7007 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7008 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7011 /* source path and the property exist */
7013 lstrcpyA(path, "kiwi");
7014 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7015 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7016 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7017 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7020 lstrcpyA(path, "kiwi");
7021 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7022 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7023 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7024 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7026 /* try SubDir after CostFinalize */
7028 lstrcpyA(path, "kiwi");
7029 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7030 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7031 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7032 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7034 /* try SubDir2 after CostFinalize */
7036 lstrcpyA(path, "kiwi");
7037 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7038 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7039 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7040 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7042 r = MsiDoAction(hpkg, "CostFinalize");
7043 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7045 /* try TARGETDIR after CostFinalize */
7047 lstrcpyA(path, "kiwi");
7048 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
7049 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7050 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7051 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7053 /* try SourceDir after CostFinalize */
7055 lstrcpyA(path, "kiwi");
7056 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7057 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7058 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7059 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7061 /* try SOURCEDIR after CostFinalize */
7063 lstrcpyA(path, "kiwi");
7064 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7067 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7068 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7069 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7072 /* source path and the property exist */
7074 lstrcpyA(path, "kiwi");
7075 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7076 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7077 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7078 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7081 lstrcpyA(path, "kiwi");
7082 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7083 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7084 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7085 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7087 /* try SubDir after CostFinalize */
7089 lstrcpyA(path, "kiwi");
7090 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7091 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7092 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7093 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7095 /* try SubDir2 after CostFinalize */
7097 lstrcpyA(path, "kiwi");
7098 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7099 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7100 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7101 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7103 MsiCloseHandle(hpkg);
7104 DeleteFile(msifile);
7107 static void test_shortlongsource(void)
7109 MSIHANDLE hdb, hpkg;
7110 CHAR path[MAX_PATH];
7112 CHAR subsrc[MAX_PATH];
7116 lstrcpyA(cwd, CURR_DIR);
7117 lstrcatA(cwd, "\\");
7119 lstrcpyA(subsrc, cwd);
7120 lstrcatA(subsrc, "long");
7121 lstrcatA(subsrc, "\\");
7123 /* long file names */
7125 hdb = create_package_db();
7126 ok( hdb, "failed to create database\n");
7128 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
7130 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7131 ok(r == S_OK, "failed\n");
7133 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
7134 ok(r == S_OK, "failed\n");
7136 /* CostInitialize:short */
7137 r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
7138 ok(r == S_OK, "failed\n");
7140 /* CostInitialize:long */
7141 r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
7142 ok(r == S_OK, "failed\n");
7144 /* FileCost:short */
7145 r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
7146 ok(r == S_OK, "failed\n");
7149 r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7150 ok(r == S_OK, "failed\n");
7152 /* CostFinalize:short */
7153 r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7154 ok(r == S_OK, "failed\n");
7156 /* CostFinalize:long */
7157 r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7158 ok(r == S_OK, "failed\n");
7160 MsiDatabaseCommit(hdb);
7162 r = package_from_db(hdb, &hpkg);
7163 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7165 skip("Not enough rights to perform tests\n");
7166 DeleteFile(msifile);
7169 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7171 MsiCloseHandle(hdb);
7173 CreateDirectoryA("one", NULL);
7174 CreateDirectoryA("four", NULL);
7176 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7178 r = MsiDoAction(hpkg, "CostInitialize");
7179 ok(r == ERROR_SUCCESS, "file cost failed\n");
7181 CreateDirectory("five", NULL);
7182 CreateDirectory("eight", NULL);
7184 r = MsiDoAction(hpkg, "FileCost");
7185 ok(r == ERROR_SUCCESS, "file cost failed\n");
7187 CreateDirectory("nine", NULL);
7188 CreateDirectory("twelve", NULL);
7190 r = MsiDoAction(hpkg, "CostFinalize");
7191 ok(r == ERROR_SUCCESS, "file cost failed\n");
7193 /* neither short nor long source directories exist */
7195 lstrcpyA(path, "kiwi");
7196 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7197 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7198 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7199 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7201 CreateDirectoryA("short", NULL);
7203 /* short source directory exists */
7205 lstrcpyA(path, "kiwi");
7206 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7208 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7209 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7211 CreateDirectoryA("long", NULL);
7213 /* both short and long source directories exist */
7215 lstrcpyA(path, "kiwi");
7216 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7217 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7218 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7219 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7221 lstrcpyA(subsrc, cwd);
7222 lstrcatA(subsrc, "two");
7223 lstrcatA(subsrc, "\\");
7225 /* short dir exists before CostInitialize */
7227 lstrcpyA(path, "kiwi");
7228 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7230 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7231 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7233 lstrcpyA(subsrc, cwd);
7234 lstrcatA(subsrc, "four");
7235 lstrcatA(subsrc, "\\");
7237 /* long dir exists before CostInitialize */
7239 lstrcpyA(path, "kiwi");
7240 r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
7241 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7242 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7243 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7245 lstrcpyA(subsrc, cwd);
7246 lstrcatA(subsrc, "six");
7247 lstrcatA(subsrc, "\\");
7249 /* short dir exists before FileCost */
7251 lstrcpyA(path, "kiwi");
7252 r = MsiGetSourcePath(hpkg, "SubDir4", 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, "eight");
7259 lstrcatA(subsrc, "\\");
7261 /* long dir exists before FileCost */
7263 lstrcpyA(path, "kiwi");
7264 r = MsiGetSourcePath(hpkg, "SubDir5", 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, "ten");
7271 lstrcatA(subsrc, "\\");
7273 /* short dir exists before CostFinalize */
7275 lstrcpyA(path, "kiwi");
7276 r = MsiGetSourcePath(hpkg, "SubDir6", 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, "twelve");
7283 lstrcatA(subsrc, "\\");
7285 /* long dir exists before CostFinalize */
7287 lstrcpyA(path, "kiwi");
7288 r = MsiGetSourcePath(hpkg, "SubDir7", 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 MsiCloseHandle(hpkg);
7294 RemoveDirectoryA("short");
7295 RemoveDirectoryA("long");
7296 RemoveDirectoryA("one");
7297 RemoveDirectoryA("four");
7298 RemoveDirectoryA("five");
7299 RemoveDirectoryA("eight");
7300 RemoveDirectoryA("nine");
7301 RemoveDirectoryA("twelve");
7303 /* short file names */
7305 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
7306 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7308 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
7310 r = package_from_db(hdb, &hpkg);
7311 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7313 MsiCloseHandle(hdb);
7315 CreateDirectoryA("one", NULL);
7316 CreateDirectoryA("four", NULL);
7318 r = MsiDoAction(hpkg, "CostInitialize");
7319 ok(r == ERROR_SUCCESS, "file cost failed\n");
7321 CreateDirectory("five", NULL);
7322 CreateDirectory("eight", NULL);
7324 r = MsiDoAction(hpkg, "FileCost");
7325 ok(r == ERROR_SUCCESS, "file cost failed\n");
7327 CreateDirectory("nine", NULL);
7328 CreateDirectory("twelve", NULL);
7330 r = MsiDoAction(hpkg, "CostFinalize");
7331 ok(r == ERROR_SUCCESS, "file cost failed\n");
7333 lstrcpyA(subsrc, cwd);
7334 lstrcatA(subsrc, "short");
7335 lstrcatA(subsrc, "\\");
7337 /* neither short nor long source directories exist */
7339 lstrcpyA(path, "kiwi");
7340 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7342 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7343 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7345 CreateDirectoryA("short", NULL);
7347 /* short source directory exists */
7349 lstrcpyA(path, "kiwi");
7350 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7352 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7353 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7355 CreateDirectoryA("long", NULL);
7357 /* both short and long source directories exist */
7359 lstrcpyA(path, "kiwi");
7360 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7361 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7362 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7363 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7365 lstrcpyA(subsrc, cwd);
7366 lstrcatA(subsrc, "one");
7367 lstrcatA(subsrc, "\\");
7369 /* short dir exists before CostInitialize */
7371 lstrcpyA(path, "kiwi");
7372 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7373 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7374 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7375 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7377 lstrcpyA(subsrc, cwd);
7378 lstrcatA(subsrc, "three");
7379 lstrcatA(subsrc, "\\");
7381 /* long dir exists before CostInitialize */
7383 lstrcpyA(path, "kiwi");
7384 r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
7385 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7386 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7387 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7389 lstrcpyA(subsrc, cwd);
7390 lstrcatA(subsrc, "five");
7391 lstrcatA(subsrc, "\\");
7393 /* short dir exists before FileCost */
7395 lstrcpyA(path, "kiwi");
7396 r = MsiGetSourcePath(hpkg, "SubDir4", 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, "seven");
7403 lstrcatA(subsrc, "\\");
7405 /* long dir exists before FileCost */
7407 lstrcpyA(path, "kiwi");
7408 r = MsiGetSourcePath(hpkg, "SubDir5", 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, "nine");
7415 lstrcatA(subsrc, "\\");
7417 /* short dir exists before CostFinalize */
7419 lstrcpyA(path, "kiwi");
7420 r = MsiGetSourcePath(hpkg, "SubDir6", 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, "eleven");
7427 lstrcatA(subsrc, "\\");
7429 /* long dir exists before CostFinalize */
7431 lstrcpyA(path, "kiwi");
7432 r = MsiGetSourcePath(hpkg, "SubDir7", 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 MsiCloseHandle(hpkg);
7438 RemoveDirectoryA("short");
7439 RemoveDirectoryA("long");
7440 RemoveDirectoryA("one");
7441 RemoveDirectoryA("four");
7442 RemoveDirectoryA("five");
7443 RemoveDirectoryA("eight");
7444 RemoveDirectoryA("nine");
7445 RemoveDirectoryA("twelve");
7446 DeleteFileA(msifile);
7449 static void test_sourcedir(void)
7451 MSIHANDLE hdb, hpkg;
7453 CHAR path[MAX_PATH];
7455 CHAR subsrc[MAX_PATH];
7459 lstrcpyA(cwd, CURR_DIR);
7460 lstrcatA(cwd, "\\");
7462 lstrcpyA(subsrc, cwd);
7463 lstrcatA(subsrc, "long");
7464 lstrcatA(subsrc, "\\");
7466 hdb = create_package_db();
7467 ok( hdb, "failed to create database\n");
7469 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7470 ok(r == S_OK, "failed\n");
7472 sprintf(package, "#%u", hdb);
7473 r = MsiOpenPackage(package, &hpkg);
7474 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7476 skip("Not enough rights to perform tests\n");
7479 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7481 /* properties only */
7483 /* SourceDir prop */
7485 lstrcpyA(path, "kiwi");
7486 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7487 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7488 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7489 ok(size == 0, "Expected 0, got %d\n", size);
7491 /* SOURCEDIR prop */
7493 lstrcpyA(path, "kiwi");
7494 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7495 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7496 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7497 ok(size == 0, "Expected 0, got %d\n", size);
7499 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7501 r = MsiDoAction(hpkg, "CostInitialize");
7502 ok(r == ERROR_SUCCESS, "file cost failed\n");
7504 /* SourceDir after CostInitialize */
7506 lstrcpyA(path, "kiwi");
7507 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7508 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7509 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7510 ok(size == 0, "Expected 0, got %d\n", size);
7512 /* SOURCEDIR after CostInitialize */
7514 lstrcpyA(path, "kiwi");
7515 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7516 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7517 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7518 ok(size == 0, "Expected 0, got %d\n", size);
7520 r = MsiDoAction(hpkg, "FileCost");
7521 ok(r == ERROR_SUCCESS, "file cost failed\n");
7523 /* SourceDir after FileCost */
7525 lstrcpyA(path, "kiwi");
7526 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7527 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7528 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7529 ok(size == 0, "Expected 0, got %d\n", size);
7531 /* SOURCEDIR after FileCost */
7533 lstrcpyA(path, "kiwi");
7534 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7535 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7536 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7537 ok(size == 0, "Expected 0, got %d\n", size);
7539 r = MsiDoAction(hpkg, "CostFinalize");
7540 ok(r == ERROR_SUCCESS, "file cost failed\n");
7542 /* SourceDir after CostFinalize */
7544 lstrcpyA(path, "kiwi");
7545 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7546 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7547 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7548 ok(size == 0, "Expected 0, got %d\n", size);
7550 /* SOURCEDIR after CostFinalize */
7552 lstrcpyA(path, "kiwi");
7553 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7554 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7555 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7556 ok(size == 0, "Expected 0, got %d\n", size);
7559 lstrcpyA(path, "kiwi");
7560 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7561 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7562 ok(!lstrcmpA(path, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path);
7563 ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
7565 /* SOURCEDIR after calling MsiGetSourcePath */
7567 lstrcpyA(path, "kiwi");
7568 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7571 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7572 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7575 r = MsiDoAction(hpkg, "ResolveSource");
7576 ok(r == ERROR_SUCCESS, "file cost failed\n");
7578 /* SourceDir after ResolveSource */
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, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7584 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7586 /* SOURCEDIR after ResolveSource */
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, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7592 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7596 lstrcpyA(path, "kiwi");
7597 r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
7598 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7599 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7600 ok(size == 0, "Expected 0, got %d\n", size);
7602 MsiCloseHandle(hpkg);
7604 /* reset the package state */
7605 sprintf(package, "#%i", hdb);
7606 r = MsiOpenPackage(package, &hpkg);
7607 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7609 /* test how MsiGetSourcePath affects the properties */
7611 /* SourceDir prop */
7613 lstrcpyA(path, "kiwi");
7614 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7615 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7618 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7619 ok(size == 0, "Expected 0, got %d\n", size);
7623 lstrcpyA(path, "kiwi");
7624 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7625 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7626 ok(!lstrcmpA(path, "kiwi"),
7627 "Expected path to be unchanged, got \"%s\"\n", path);
7628 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7630 /* SourceDir after MsiGetSourcePath */
7632 lstrcpyA(path, "kiwi");
7633 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7634 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7637 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7638 ok(size == 0, "Expected 0, got %d\n", size);
7641 /* SOURCEDIR prop */
7643 lstrcpyA(path, "kiwi");
7644 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7645 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7648 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7649 ok(size == 0, "Expected 0, got %d\n", size);
7653 lstrcpyA(path, "kiwi");
7654 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7655 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7656 ok(!lstrcmpA(path, "kiwi"),
7657 "Expected path to be unchanged, got \"%s\"\n", path);
7658 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7660 /* SOURCEDIR prop after MsiGetSourcePath */
7662 lstrcpyA(path, "kiwi");
7663 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7664 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7667 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7668 ok(size == 0, "Expected 0, got %d\n", size);
7671 r = MsiDoAction(hpkg, "CostInitialize");
7672 ok(r == ERROR_SUCCESS, "file cost failed\n");
7674 /* SourceDir after CostInitialize */
7676 lstrcpyA(path, "kiwi");
7677 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7681 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7682 ok(size == 0, "Expected 0, got %d\n", size);
7686 lstrcpyA(path, "kiwi");
7687 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7688 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7689 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7690 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7692 /* SourceDir after MsiGetSourcePath */
7694 lstrcpyA(path, "kiwi");
7695 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7696 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7697 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7698 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7700 /* SOURCEDIR after CostInitialize */
7702 lstrcpyA(path, "kiwi");
7703 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7704 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7705 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7706 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7708 /* SOURCEDIR source path still does not exist */
7710 lstrcpyA(path, "kiwi");
7711 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7712 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7713 ok(!lstrcmpA(path, "kiwi"),
7714 "Expected path to be unchanged, got \"%s\"\n", path);
7715 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7717 r = MsiDoAction(hpkg, "FileCost");
7718 ok(r == ERROR_SUCCESS, "file cost failed\n");
7720 /* SourceDir after FileCost */
7722 lstrcpyA(path, "kiwi");
7723 r = MsiGetProperty(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 FileCost */
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 source path still does not exist */
7738 lstrcpyA(path, "kiwi");
7739 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7740 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7741 ok(!lstrcmpA(path, "kiwi"),
7742 "Expected path to be unchanged, got \"%s\"\n", path);
7743 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7745 r = MsiDoAction(hpkg, "CostFinalize");
7746 ok(r == ERROR_SUCCESS, "file cost failed\n");
7748 /* SourceDir after CostFinalize */
7750 lstrcpyA(path, "kiwi");
7751 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7752 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7753 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7754 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7756 /* SOURCEDIR after CostFinalize */
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 source path still does not exist */
7766 lstrcpyA(path, "kiwi");
7767 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7768 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7769 ok(!lstrcmpA(path, "kiwi"),
7770 "Expected path to be unchanged, got \"%s\"\n", path);
7771 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7773 r = MsiDoAction(hpkg, "ResolveSource");
7774 ok(r == ERROR_SUCCESS, "file cost failed\n");
7776 /* SourceDir after ResolveSource */
7778 lstrcpyA(path, "kiwi");
7779 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7780 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7781 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7782 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7784 /* SOURCEDIR after ResolveSource */
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 source path still does not exist */
7794 lstrcpyA(path, "kiwi");
7795 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7796 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7797 ok(!lstrcmpA(path, "kiwi"),
7798 "Expected path to be unchanged, got \"%s\"\n", path);
7799 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7801 MsiCloseHandle(hpkg);
7804 MsiCloseHandle(hdb);
7805 DeleteFileA(msifile);
7815 static const struct access_res create[16] =
7817 { TRUE, ERROR_SUCCESS, TRUE },
7818 { TRUE, ERROR_SUCCESS, TRUE },
7819 { TRUE, ERROR_SUCCESS, FALSE },
7820 { TRUE, ERROR_SUCCESS, FALSE },
7821 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7822 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7823 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7824 { TRUE, ERROR_SUCCESS, FALSE },
7825 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7826 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7827 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7828 { TRUE, ERROR_SUCCESS, TRUE },
7829 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7830 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7831 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7832 { TRUE, ERROR_SUCCESS, TRUE }
7835 static const struct access_res create_commit[16] =
7837 { TRUE, ERROR_SUCCESS, TRUE },
7838 { TRUE, ERROR_SUCCESS, TRUE },
7839 { TRUE, ERROR_SUCCESS, FALSE },
7840 { TRUE, ERROR_SUCCESS, FALSE },
7841 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7842 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7843 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7844 { TRUE, ERROR_SUCCESS, FALSE },
7845 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7846 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7847 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7848 { TRUE, ERROR_SUCCESS, TRUE },
7849 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7850 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7851 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7852 { TRUE, ERROR_SUCCESS, TRUE }
7855 static const struct access_res create_close[16] =
7857 { TRUE, ERROR_SUCCESS, FALSE },
7858 { TRUE, ERROR_SUCCESS, FALSE },
7859 { TRUE, ERROR_SUCCESS, FALSE },
7860 { TRUE, ERROR_SUCCESS, FALSE },
7861 { TRUE, ERROR_SUCCESS, FALSE },
7862 { TRUE, ERROR_SUCCESS, FALSE },
7863 { TRUE, ERROR_SUCCESS, FALSE },
7864 { TRUE, ERROR_SUCCESS, FALSE },
7865 { TRUE, ERROR_SUCCESS, FALSE },
7866 { TRUE, ERROR_SUCCESS, FALSE },
7867 { TRUE, ERROR_SUCCESS, FALSE },
7868 { TRUE, ERROR_SUCCESS, FALSE },
7869 { TRUE, ERROR_SUCCESS, FALSE },
7870 { TRUE, ERROR_SUCCESS, FALSE },
7871 { TRUE, ERROR_SUCCESS, FALSE },
7872 { TRUE, ERROR_SUCCESS }
7875 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
7877 DWORD access = 0, share = 0;
7882 for (i = 0; i < 4; i++)
7884 if (i == 0) access = 0;
7885 if (i == 1) access = GENERIC_READ;
7886 if (i == 2) access = GENERIC_WRITE;
7887 if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
7889 for (j = 0; j < 4; j++)
7891 if (ares[idx].ignore)
7894 if (j == 0) share = 0;
7895 if (j == 1) share = FILE_SHARE_READ;
7896 if (j == 2) share = FILE_SHARE_WRITE;
7897 if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
7899 SetLastError(0xdeadbeef);
7900 hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
7901 FILE_ATTRIBUTE_NORMAL, 0);
7902 lasterr = GetLastError();
7904 ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
7905 "(%d, handle, %d): Expected %d, got %d\n",
7906 line, idx, ares[idx].gothandle,
7907 (hfile != INVALID_HANDLE_VALUE));
7909 ok(lasterr == ares[idx].lasterr, "(%d, lasterr, %d): Expected %d, got %d\n",
7910 line, idx, ares[idx].lasterr, lasterr);
7918 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
7920 static void test_access(void)
7925 r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
7926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7928 test_file_access(msifile, create);
7930 r = MsiDatabaseCommit(hdb);
7931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7933 test_file_access(msifile, create_commit);
7934 MsiCloseHandle(hdb);
7936 test_file_access(msifile, create_close);
7937 DeleteFileA(msifile);
7939 r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
7940 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7942 test_file_access(msifile, create);
7944 r = MsiDatabaseCommit(hdb);
7945 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7947 test_file_access(msifile, create_commit);
7948 MsiCloseHandle(hdb);
7950 test_file_access(msifile, create_close);
7951 DeleteFileA(msifile);
7954 static void test_emptypackage(void)
7956 MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
7957 MSIHANDLE hview = 0, hrec = 0;
7958 MSICONDITION condition;
7959 CHAR buffer[MAX_PATH];
7963 r = MsiOpenPackageA("", &hpkg);
7964 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7966 skip("Not enough rights to perform tests\n");
7971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7974 hdb = MsiGetActiveDatabase(hpkg);
7977 ok(hdb != 0, "Expected a valid database handle\n");
7980 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
7983 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7985 r = MsiViewExecute(hview, 0);
7988 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7991 r = MsiViewFetch(hview, &hrec);
7994 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7999 r = MsiRecordGetString(hrec, 1, buffer, &size);
8002 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8003 ok(!lstrcmpA(buffer, "_Property"),
8004 "Expected \"_Property\", got \"%s\"\n", buffer);
8007 MsiCloseHandle(hrec);
8009 r = MsiViewFetch(hview, &hrec);
8012 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8016 r = MsiRecordGetString(hrec, 1, buffer, &size);
8019 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8020 ok(!lstrcmpA(buffer, "#_FolderCache"),
8021 "Expected \"_Property\", got \"%s\"\n", buffer);
8024 MsiCloseHandle(hrec);
8025 MsiViewClose(hview);
8026 MsiCloseHandle(hview);
8028 condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
8031 ok(condition == MSICONDITION_FALSE,
8032 "Expected MSICONDITION_FALSE, got %d\n", condition);
8035 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
8038 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8040 r = MsiViewExecute(hview, 0);
8043 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8046 /* _Property table is not empty */
8047 r = MsiViewFetch(hview, &hrec);
8050 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8053 MsiCloseHandle(hrec);
8054 MsiViewClose(hview);
8055 MsiCloseHandle(hview);
8057 condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
8060 ok(condition == MSICONDITION_FALSE,
8061 "Expected MSICONDITION_FALSE, got %d\n", condition);
8064 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
8067 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8069 r = MsiViewExecute(hview, 0);
8072 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8075 /* #_FolderCache is not empty */
8076 r = MsiViewFetch(hview, &hrec);
8079 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8082 MsiCloseHandle(hrec);
8083 MsiViewClose(hview);
8084 MsiCloseHandle(hview);
8086 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
8089 ok(r == ERROR_BAD_QUERY_SYNTAX,
8090 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8093 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
8096 ok(r == ERROR_BAD_QUERY_SYNTAX,
8097 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8100 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
8103 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
8104 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
8107 MsiCloseHandle(hsuminfo);
8109 r = MsiDatabaseCommit(hdb);
8112 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8115 MsiCloseHandle(hdb);
8116 MsiCloseHandle(hpkg);
8119 static void test_MsiGetProductProperty(void)
8121 MSIHANDLE hprod, hdb;
8123 CHAR path[MAX_PATH];
8124 CHAR query[MAX_PATH];
8125 CHAR keypath[MAX_PATH*2];
8126 CHAR prodcode[MAX_PATH];
8127 CHAR prod_squashed[MAX_PATH];
8128 HKEY prodkey, userkey, props;
8132 REGSAM access = KEY_ALL_ACCESS;
8134 GetCurrentDirectoryA(MAX_PATH, path);
8135 lstrcatA(path, "\\");
8137 create_test_guid(prodcode, prod_squashed);
8140 access |= KEY_WOW64_64KEY;
8142 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
8143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8145 r = MsiDatabaseCommit(hdb);
8146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8148 r = set_summary_info(hdb);
8149 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8152 "CREATE TABLE `Directory` ( "
8153 "`Directory` CHAR(255) NOT NULL, "
8154 "`Directory_Parent` CHAR(255), "
8155 "`DefaultDir` CHAR(255) NOT NULL "
8156 "PRIMARY KEY `Directory`)");
8157 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8160 "CREATE TABLE `Property` ( "
8161 "`Property` CHAR(72) NOT NULL, "
8162 "`Value` CHAR(255) "
8163 "PRIMARY KEY `Property`)");
8164 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8166 sprintf(query, "INSERT INTO `Property` "
8167 "(`Property`, `Value`) "
8168 "VALUES( 'ProductCode', '%s' )", prodcode);
8169 r = run_query(hdb, query);
8170 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8172 r = MsiDatabaseCommit(hdb);
8173 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8175 MsiCloseHandle(hdb);
8177 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8178 lstrcatA(keypath, prod_squashed);
8180 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8181 if (res == ERROR_ACCESS_DENIED)
8183 skip("Not enough rights to perform tests\n");
8184 DeleteFile(msifile);
8187 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8189 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8190 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8191 lstrcatA(keypath, prod_squashed);
8193 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
8194 if (res == ERROR_ACCESS_DENIED)
8196 skip("Not enough rights to perform tests\n");
8197 RegDeleteKeyA(prodkey, "");
8198 RegCloseKey(prodkey);
8201 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8203 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8204 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8206 lstrcpyA(val, path);
8207 lstrcatA(val, "\\");
8208 lstrcatA(val, msifile);
8209 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8210 (const BYTE *)val, lstrlenA(val) + 1);
8211 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8214 r = MsiOpenProductA(prodcode, &hprod);
8215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8216 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
8218 /* hProduct is invalid */
8220 lstrcpyA(val, "apple");
8221 r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
8222 ok(r == ERROR_INVALID_HANDLE,
8223 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8224 ok(!lstrcmpA(val, "apple"),
8225 "Expected val to be unchanged, got \"%s\"\n", val);
8226 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8228 /* szProperty is NULL */
8230 lstrcpyA(val, "apple");
8231 r = MsiGetProductPropertyA(hprod, NULL, val, &size);
8232 ok(r == ERROR_INVALID_PARAMETER,
8233 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8234 ok(!lstrcmpA(val, "apple"),
8235 "Expected val to be unchanged, got \"%s\"\n", val);
8236 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8238 /* szProperty is empty */
8240 lstrcpyA(val, "apple");
8241 r = MsiGetProductPropertyA(hprod, "", val, &size);
8242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8243 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8244 ok(size == 0, "Expected 0, got %d\n", size);
8246 /* get the property */
8248 lstrcpyA(val, "apple");
8249 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8250 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8251 ok(!lstrcmpA(val, prodcode),
8252 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8253 ok(size == lstrlenA(prodcode),
8254 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8256 /* lpValueBuf is NULL */
8258 r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
8259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8260 ok(size == lstrlenA(prodcode),
8261 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8263 /* pcchValueBuf is NULL */
8264 lstrcpyA(val, "apple");
8265 r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
8266 ok(r == ERROR_INVALID_PARAMETER,
8267 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8268 ok(!lstrcmpA(val, "apple"),
8269 "Expected val to be unchanged, got \"%s\"\n", val);
8270 ok(size == lstrlenA(prodcode),
8271 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8273 /* pcchValueBuf is too small */
8275 lstrcpyA(val, "apple");
8276 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8277 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8278 ok(!strncmp(val, prodcode, 3),
8279 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
8280 ok(size == lstrlenA(prodcode),
8281 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8283 /* pcchValueBuf does not leave room for NULL terminator */
8284 size = lstrlenA(prodcode);
8285 lstrcpyA(val, "apple");
8286 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8287 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8288 ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
8289 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
8290 ok(size == lstrlenA(prodcode),
8291 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8293 /* pcchValueBuf has enough room for NULL terminator */
8294 size = lstrlenA(prodcode) + 1;
8295 lstrcpyA(val, "apple");
8296 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8297 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8298 ok(!lstrcmpA(val, prodcode),
8299 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8300 ok(size == lstrlenA(prodcode),
8301 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8303 /* nonexistent property */
8305 lstrcpyA(val, "apple");
8306 r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
8307 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8308 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8309 ok(size == 0, "Expected 0, got %d\n", size);
8311 r = MsiSetPropertyA(hprod, "NewProperty", "value");
8312 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8314 /* non-product property set */
8316 lstrcpyA(val, "apple");
8317 r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
8318 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8319 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8320 ok(size == 0, "Expected 0, got %d\n", size);
8322 r = MsiSetPropertyA(hprod, "ProductCode", "value");
8323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8325 /* non-product property that is also a product property set */
8327 lstrcpyA(val, "apple");
8328 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8329 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8330 ok(!lstrcmpA(val, prodcode),
8331 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8332 ok(size == lstrlenA(prodcode),
8333 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8335 MsiCloseHandle(hprod);
8337 RegDeleteValueA(props, "LocalPackage");
8338 delete_key(props, "", access);
8340 delete_key(userkey, "", access);
8341 RegCloseKey(userkey);
8342 delete_key(prodkey, "", access);
8343 RegCloseKey(prodkey);
8344 DeleteFileA(msifile);
8347 static void test_MsiSetProperty(void)
8349 MSIHANDLE hpkg, hdb, hrec;
8355 r = package_from_db(create_package_db(), &hpkg);
8356 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8358 skip("Not enough rights to perform tests\n");
8359 DeleteFile(msifile);
8362 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
8364 /* invalid hInstall */
8365 r = MsiSetPropertyA(0, "Prop", "Val");
8366 ok(r == ERROR_INVALID_HANDLE,
8367 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8369 /* invalid hInstall */
8370 r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8371 ok(r == ERROR_INVALID_HANDLE,
8372 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8374 /* szName is NULL */
8375 r = MsiSetPropertyA(hpkg, NULL, "Val");
8376 ok(r == ERROR_INVALID_PARAMETER,
8377 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8379 /* both szName and szValue are NULL */
8380 r = MsiSetPropertyA(hpkg, NULL, NULL);
8381 ok(r == ERROR_INVALID_PARAMETER,
8382 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8384 /* szName is empty */
8385 r = MsiSetPropertyA(hpkg, "", "Val");
8386 ok(r == ERROR_FUNCTION_FAILED,
8387 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8389 /* szName is empty and szValue is NULL */
8390 r = MsiSetPropertyA(hpkg, "", NULL);
8391 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8393 /* set a property */
8394 r = MsiSetPropertyA(hpkg, "Prop", "Val");
8395 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8397 /* get the property */
8399 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8400 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8401 ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
8402 ok(size == 3, "Expected 3, got %d\n", size);
8404 /* update the property */
8405 r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
8406 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8408 /* get the property */
8410 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8412 ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
8413 ok(size == 4, "Expected 4, got %d\n", size);
8415 hdb = MsiGetActiveDatabase(hpkg);
8416 ok(hdb != 0, "Expected a valid database handle\n");
8418 /* set prop is not in the _Property table */
8419 query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8420 r = do_query(hdb, query, &hrec);
8421 ok(r == ERROR_BAD_QUERY_SYNTAX,
8422 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8424 /* set prop is not in the Property table */
8425 query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8426 r = do_query(hdb, query, &hrec);
8427 ok(r == ERROR_BAD_QUERY_SYNTAX,
8428 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8430 MsiCloseHandle(hdb);
8432 /* szValue is an empty string */
8433 r = MsiSetPropertyA(hpkg, "Prop", "");
8434 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8436 /* try to get the property */
8438 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8439 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8440 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8441 ok(size == 0, "Expected 0, got %d\n", size);
8443 /* reset the property */
8444 r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
8445 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8447 /* delete the property */
8448 r = MsiSetPropertyA(hpkg, "Prop", NULL);
8449 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8451 /* try to get the property */
8453 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8454 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8455 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8456 ok(size == 0, "Expected 0, got %d\n", size);
8458 MsiCloseHandle(hpkg);
8459 DeleteFileA(msifile);
8462 static void test_MsiApplyMultiplePatches(void)
8464 UINT r, type = GetDriveType(NULL);
8466 if (!pMsiApplyMultiplePatchesA) {
8467 win_skip("MsiApplyMultiplePatchesA not found\n");
8471 r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
8472 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8474 r = pMsiApplyMultiplePatchesA("", NULL, NULL);
8475 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8477 r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
8478 if (type == DRIVE_FIXED)
8479 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8481 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8483 r = pMsiApplyMultiplePatchesA(" ;", NULL, NULL);
8484 if (type == DRIVE_FIXED)
8485 todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
8487 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8489 r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
8490 if (type == DRIVE_FIXED)
8491 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8493 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8495 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
8496 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8498 r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
8499 if (type == DRIVE_FIXED)
8500 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8502 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8504 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
8505 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8507 r = pMsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL, NULL);
8508 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8511 static void test_MsiApplyPatch(void)
8515 r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
8516 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8518 r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
8519 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8522 static void test_MsiEnumComponentCosts(void)
8524 MSIHANDLE hdb, hpkg;
8525 char package[12], drive[3];
8530 hdb = create_package_db();
8531 ok( hdb, "failed to create database\n" );
8533 r = create_property_table( hdb );
8534 ok( r == ERROR_SUCCESS, "cannot create Property table %u\n", r );
8536 r = add_property_entry( hdb, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8537 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8539 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
8540 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8542 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
8543 ok( r == ERROR_SUCCESS, "failed to add directory entry %u\n" , r );
8545 r = create_media_table( hdb );
8546 ok( r == ERROR_SUCCESS, "cannot create Media table %u\n", r );
8548 r = add_media_entry( hdb, "'1', '2', 'cabinet', '', '', ''");
8549 ok( r == ERROR_SUCCESS, "cannot add media entry %u\n", r );
8551 r = create_file_table( hdb );
8552 ok( r == ERROR_SUCCESS, "cannot create File table %u\n", r );
8554 r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8555 ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
8557 r = create_component_table( hdb );
8558 ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
8560 r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8561 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8563 r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8564 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8566 r = create_feature_table( hdb );
8567 ok( r == ERROR_SUCCESS, "cannot create Feature table %u\n", r );
8569 r = add_feature_entry( hdb, "'one', '', '', '', 0, 1, '', 0" );
8570 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8572 r = add_feature_entry( hdb, "'two', '', '', '', 0, 1, '', 0" );
8573 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8575 r = create_feature_components_table( hdb );
8576 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table %u\n", r );
8578 r = add_feature_components_entry( hdb, "'one', 'one'" );
8579 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8581 r = add_feature_components_entry( hdb, "'two', 'two'" );
8582 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8584 r = create_install_execute_sequence_table( hdb );
8585 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table %u\n", r );
8587 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
8588 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8590 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
8591 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8593 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
8594 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8596 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1100'" );
8597 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8599 MsiDatabaseCommit( hdb );
8601 sprintf( package, "#%u", hdb );
8602 r = MsiOpenPackageA( package, &hpkg );
8603 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8605 skip("Not enough rights to perform tests\n");
8608 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8610 r = MsiEnumComponentCostsA( 0, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8611 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8613 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8614 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8616 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8617 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8619 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8620 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8622 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8623 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8625 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, NULL, NULL, NULL );
8626 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8628 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, NULL, NULL, NULL );
8629 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8631 len = sizeof(drive);
8632 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, NULL, NULL );
8633 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8635 len = sizeof(drive);
8636 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, NULL );
8637 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8639 len = sizeof(drive);
8640 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8641 todo_wine ok( r == ERROR_INVALID_HANDLE_STATE, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r );
8643 len = sizeof(drive);
8644 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, &len, &cost, &temp );
8645 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8647 MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );
8649 r = MsiDoAction( hpkg, "CostInitialize" );
8650 ok( r == ERROR_SUCCESS, "CostInitialize failed %u\n", r );
8652 r = MsiDoAction( hpkg, "FileCost" );
8653 ok( r == ERROR_SUCCESS, "FileCost failed %u\n", r );
8655 len = sizeof(drive);
8656 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8657 ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8659 r = MsiDoAction( hpkg, "CostFinalize" );
8660 ok( r == ERROR_SUCCESS, "CostFinalize failed %u\n", r );
8662 /* contrary to what msdn says InstallValidate must be called too */
8663 len = sizeof(drive);
8664 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8665 todo_wine ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8667 r = MsiDoAction( hpkg, "InstallValidate" );
8668 ok( r == ERROR_SUCCESS, "InstallValidate failed %u\n", r );
8671 r = MsiEnumComponentCostsA( hpkg, "three", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8672 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
8675 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8676 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8677 ok( len == 2, "expected len == 2, got %u\n", len );
8680 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8681 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8682 ok( len == 2, "expected len == 2, got %u\n", len );
8685 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8686 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8687 ok( len == 2, "expected len == 2, got %u\n", len );
8689 /* install state doesn't seem to matter */
8690 len = sizeof(drive);
8691 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8692 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8694 len = sizeof(drive);
8695 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_ABSENT, drive, &len, &cost, &temp );
8696 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8698 len = sizeof(drive);
8699 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_SOURCE, drive, &len, &cost, &temp );
8700 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8702 len = sizeof(drive);
8704 cost = temp = 0xdead;
8705 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8706 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8707 ok( len == 2, "expected len == 2, got %u\n", len );
8708 ok( drive[0], "expected a drive\n" );
8709 ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
8710 ok( !temp, "expected temp == 0, got %d\n", temp );
8712 len = sizeof(drive);
8714 cost = temp = 0xdead;
8715 r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8716 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8717 ok( len == 2, "expected len == 2, got %u\n", len );
8718 ok( drive[0], "expected a drive\n" );
8719 ok( !cost, "expected cost == 0, got %d\n", cost );
8720 ok( !temp, "expected temp == 0, got %d\n", temp );
8722 len = sizeof(drive);
8724 cost = temp = 0xdead;
8725 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8726 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8727 ok( len == 2, "expected len == 2, got %u\n", len );
8728 ok( drive[0], "expected a drive\n" );
8729 ok( !cost, "expected cost == 0, got %d\n", cost );
8730 ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
8732 /* increased index */
8733 len = sizeof(drive);
8734 r = MsiEnumComponentCostsA( hpkg, "one", 1, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8735 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8737 len = sizeof(drive);
8738 r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8739 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8741 MsiCloseHandle( hpkg );
8743 MsiCloseHandle( hdb );
8744 DeleteFileA( msifile );
8747 static void test_MsiDatabaseCommit(void)
8750 MSIHANDLE hdb, hpkg = 0;
8751 char buf[32], package[12];
8754 hdb = create_package_db();
8755 ok( hdb, "failed to create database\n" );
8757 r = create_property_table( hdb );
8758 ok( r == ERROR_SUCCESS, "can't create Property table %u\n", r );
8760 sprintf( package, "#%u", hdb );
8761 r = MsiOpenPackage( package, &hpkg );
8762 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8764 skip("Not enough rights to perform tests\n");
8767 ok( r == ERROR_SUCCESS, "got %u\n", r );
8769 r = MsiSetPropertyA( hpkg, "PROP", "value" );
8770 ok( r == ERROR_SUCCESS, "got %u\n", r );
8774 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8775 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8776 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8778 r = MsiDatabaseCommit( hdb );
8779 ok( r == ERROR_SUCCESS, "MsiDatabaseCommit returned %u\n", r );
8783 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8784 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8785 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8787 MsiCloseHandle( hpkg );
8789 MsiCloseHandle( hdb );
8790 DeleteFileA( msifile );
8795 STATEMGRSTATUS status;
8798 init_functionpointers();
8800 if (pIsWow64Process)
8801 pIsWow64Process(GetCurrentProcess(), &is_wow64);
8803 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
8805 /* Create a restore point ourselves so we circumvent the multitude of restore points
8806 * that would have been created by all the installation and removal tests.
8808 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
8809 * creation of restore points.
8811 if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
8813 memset(&status, 0, sizeof(status));
8814 ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
8817 test_createpackage();
8819 test_gettargetpath_bad();
8820 test_settargetpath();
8822 test_property_table();
8825 test_formatrecord2();
8830 test_appsearch_complocator();
8831 test_appsearch_reglocator();
8832 test_appsearch_inilocator();
8833 test_appsearch_drlocator();
8834 test_featureparents();
8835 test_installprops();
8836 test_launchconditions();
8839 test_MsiGetSourcePath();
8840 test_shortlongsource();
8843 test_emptypackage();
8844 test_MsiGetProductProperty();
8845 test_MsiSetProperty();
8846 test_MsiApplyMultiplePatches();
8847 test_MsiApplyPatch();
8848 test_MsiEnumComponentCosts();
8849 test_MsiDatabaseCommit();
8851 if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
8853 ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
8855 remove_restore_point(status.llSequenceNumber);