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 const WCHAR msifileW
[] =
37 {'w','i','n','e','t','e','s','t','-','p','a','c','k','a','g','e','.','m','s','i',0};
38 static char CURR_DIR
[MAX_PATH
];
40 static UINT (WINAPI
*pMsiApplyMultiplePatchesA
)(LPCSTR
, LPCSTR
, LPCSTR
);
41 static INSTALLSTATE (WINAPI
*pMsiGetComponentPathExA
)(LPCSTR
, LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPSTR
, LPDWORD
);
42 static HRESULT (WINAPI
*pSHGetFolderPathA
)(HWND
, int, HANDLE
, DWORD
, LPSTR
);
44 static BOOL (WINAPI
*pCheckTokenMembership
)(HANDLE
,PSID
,PBOOL
);
45 static BOOL (WINAPI
*pConvertSidToStringSidA
)(PSID
, LPSTR
*);
46 static BOOL (WINAPI
*pOpenProcessToken
)( HANDLE
, DWORD
, PHANDLE
);
47 static LONG (WINAPI
*pRegDeleteKeyExA
)(HKEY
, LPCSTR
, REGSAM
, DWORD
);
48 static LONG (WINAPI
*pRegDeleteKeyExW
)(HKEY
, LPCWSTR
, REGSAM
, DWORD
);
49 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
, PBOOL
);
50 static void (WINAPI
*pGetSystemInfo
)(LPSYSTEM_INFO
);
51 static void (WINAPI
*pGetNativeSystemInfo
)(LPSYSTEM_INFO
);
52 static UINT (WINAPI
*pGetSystemWow64DirectoryA
)(LPSTR
, UINT
);
54 static BOOL (WINAPI
*pSRRemoveRestorePoint
)(DWORD
);
55 static BOOL (WINAPI
*pSRSetRestorePointA
)(RESTOREPOINTINFOA
*, STATEMGRSTATUS
*);
57 static void init_functionpointers(void)
59 HMODULE hmsi
= GetModuleHandleA("msi.dll");
60 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
61 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
62 HMODULE hshell32
= GetModuleHandleA("shell32.dll");
65 #define GET_PROC(mod, func) \
66 p ## func = (void*)GetProcAddress(mod, #func);
68 GET_PROC(hmsi
, MsiApplyMultiplePatchesA
);
69 GET_PROC(hmsi
, MsiGetComponentPathExA
);
70 GET_PROC(hshell32
, SHGetFolderPathA
);
72 GET_PROC(hadvapi32
, CheckTokenMembership
);
73 GET_PROC(hadvapi32
, ConvertSidToStringSidA
);
74 GET_PROC(hadvapi32
, OpenProcessToken
);
75 GET_PROC(hadvapi32
, RegDeleteKeyExA
)
76 GET_PROC(hadvapi32
, RegDeleteKeyExW
)
77 GET_PROC(hkernel32
, IsWow64Process
)
78 GET_PROC(hkernel32
, GetNativeSystemInfo
)
79 GET_PROC(hkernel32
, GetSystemInfo
)
80 GET_PROC(hkernel32
, GetSystemWow64DirectoryA
)
82 hsrclient
= LoadLibraryA("srclient.dll");
83 GET_PROC(hsrclient
, SRRemoveRestorePoint
);
84 GET_PROC(hsrclient
, SRSetRestorePointA
);
88 static BOOL
is_process_limited(void)
90 SID_IDENTIFIER_AUTHORITY NtAuthority
= {SECURITY_NT_AUTHORITY
};
95 if (!pCheckTokenMembership
|| !pOpenProcessToken
) return FALSE
;
97 if (!AllocateAndInitializeSid(&NtAuthority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
98 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0, &Group
) ||
99 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
101 trace("Could not check if the current user is an administrator\n");
109 if (!AllocateAndInitializeSid(&NtAuthority
, 2,
110 SECURITY_BUILTIN_DOMAIN_RID
,
111 DOMAIN_ALIAS_RID_POWER_USERS
,
112 0, 0, 0, 0, 0, 0, &Group
) ||
113 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
115 trace("Could not check if the current user is a power user\n");
120 /* Only administrators and power users can be powerful */
125 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
128 TOKEN_ELEVATION_TYPE type
= TokenElevationTypeDefault
;
131 ret
= GetTokenInformation(token
, TokenElevationType
, &type
, sizeof(type
), &size
);
133 return (ret
&& type
== TokenElevationTypeLimited
);
138 static LONG
delete_key( HKEY key
, LPCSTR subkey
, REGSAM access
)
140 if (pRegDeleteKeyExA
)
141 return pRegDeleteKeyExA( key
, subkey
, access
, 0 );
142 return RegDeleteKeyA( key
, subkey
);
145 static char *get_user_sid(void)
150 char *usersid
= NULL
;
152 if (!pConvertSidToStringSidA
)
154 win_skip("ConvertSidToStringSidA is not available\n");
157 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
158 GetTokenInformation(token
, TokenUser
, NULL
, size
, &size
);
160 user
= HeapAlloc(GetProcessHeap(), 0, size
);
161 GetTokenInformation(token
, TokenUser
, user
, size
, &size
);
162 pConvertSidToStringSidA(user
->User
.Sid
, &usersid
);
163 HeapFree(GetProcessHeap(), 0, user
);
169 /* RegDeleteTreeW from dlls/advapi32/registry.c */
170 static LSTATUS
package_RegDeleteTreeW(HKEY hKey
, LPCWSTR lpszSubKey
, REGSAM access
)
173 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
174 DWORD dwMaxLen
, dwSize
;
175 WCHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
180 ret
= RegOpenKeyExW(hKey
, lpszSubKey
, 0, access
, &hSubKey
);
184 ret
= RegQueryInfoKeyW(hSubKey
, NULL
, NULL
, NULL
, NULL
,
185 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
186 if (ret
) goto cleanup
;
190 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
191 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(WCHAR
))
193 /* Name too big: alloc a buffer for it */
194 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(WCHAR
))))
196 ret
= ERROR_NOT_ENOUGH_MEMORY
;
201 /* Recursively delete all the subkeys */
205 if (RegEnumKeyExW(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
206 NULL
, NULL
, NULL
)) break;
208 ret
= package_RegDeleteTreeW(hSubKey
, lpszName
, access
);
209 if (ret
) goto cleanup
;
214 if (pRegDeleteKeyExW
)
215 ret
= pRegDeleteKeyExW(hKey
, lpszSubKey
, access
, 0);
217 ret
= RegDeleteKeyW(hKey
, lpszSubKey
);
223 if (RegEnumValueW(hKey
, 0, lpszName
, &dwSize
,
224 NULL
, NULL
, NULL
, NULL
)) break;
226 ret
= RegDeleteValueW(hKey
, lpszName
);
227 if (ret
) goto cleanup
;
231 if (lpszName
!= szNameBuf
)
232 HeapFree(GetProcessHeap(), 0, lpszName
);
234 RegCloseKey(hSubKey
);
238 static BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
243 if (FAILED(CLSIDFromString((LPCOLESTR
)in
, &guid
)))
257 out
[17+i
*2] = in
[n
++];
258 out
[16+i
*2] = in
[n
++];
263 out
[17+i
*2] = in
[n
++];
264 out
[16+i
*2] = in
[n
++];
270 static void create_test_guid(LPSTR prodcode
, LPSTR squashed
)
272 WCHAR guidW
[MAX_PATH
];
273 WCHAR squashedW
[MAX_PATH
];
278 hr
= CoCreateGuid(&guid
);
279 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
281 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
282 ok(size
== 39, "Expected 39, got %d\n", hr
);
284 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, prodcode
, MAX_PATH
, NULL
, NULL
);
285 squash_guid(guidW
, squashedW
);
286 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
289 static void set_component_path(LPCSTR filename
, MSIINSTALLCONTEXT context
,
290 LPCSTR guid
, LPSTR usersid
, BOOL dir
)
292 WCHAR guidW
[MAX_PATH
];
293 WCHAR squashedW
[MAX_PATH
];
294 CHAR squashed
[MAX_PATH
];
295 CHAR comppath
[MAX_PATH
];
296 CHAR prodpath
[MAX_PATH
];
300 REGSAM access
= KEY_ALL_ACCESS
;
303 access
|= KEY_WOW64_64KEY
;
305 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
306 squash_guid(guidW
, squashedW
);
307 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
309 if (context
== MSIINSTALLCONTEXT_MACHINE
)
311 prod
= "3D0DAE300FACA1300AD792060BCDAA92";
313 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
314 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
316 "SOFTWARE\\Classes\\Installer\\"
317 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
319 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
321 prod
= "7D2F387510109040002000060BECB6AB";
323 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
324 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
326 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
327 "Installer\\%s\\Installer\\Products\\"
328 "7D2F387510109040002000060BECB6AB", usersid
);
330 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
332 prod
= "7D2F387510109040002000060BECB6AB";
334 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
335 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
337 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
338 "Installer\\Managed\\%s\\Installer\\Products\\"
339 "7D2F387510109040002000060BECB6AB", usersid
);
342 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, comppath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
344 lstrcpyA(path
, CURR_DIR
);
345 lstrcatA(path
, "\\");
346 if (!dir
) lstrcatA(path
, filename
);
348 RegSetValueExA(hkey
, prod
, 0, REG_SZ
, (LPBYTE
)path
, lstrlenA(path
));
351 RegCreateKeyExA(HKEY_LOCAL_MACHINE
, prodpath
, 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
355 static void delete_component_path(LPCSTR guid
, MSIINSTALLCONTEXT context
, LPSTR usersid
)
357 WCHAR guidW
[MAX_PATH
];
358 WCHAR squashedW
[MAX_PATH
];
359 WCHAR substrW
[MAX_PATH
];
360 CHAR squashed
[MAX_PATH
];
361 CHAR comppath
[MAX_PATH
];
362 CHAR prodpath
[MAX_PATH
];
363 REGSAM access
= KEY_ALL_ACCESS
;
366 access
|= KEY_WOW64_64KEY
;
368 MultiByteToWideChar(CP_ACP
, 0, guid
, -1, guidW
, MAX_PATH
);
369 squash_guid(guidW
, squashedW
);
370 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
372 if (context
== MSIINSTALLCONTEXT_MACHINE
)
375 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
376 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed
);
378 "SOFTWARE\\Classes\\Installer\\"
379 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
381 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
384 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
385 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
387 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
388 "Installer\\%s\\Installer\\Products\\"
389 "7D2F387510109040002000060BECB6AB", usersid
);
391 else if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
394 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
395 "Installer\\UserData\\%s\\Components\\%s", usersid
, squashed
);
397 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
398 "Installer\\Managed\\%s\\Installer\\Products\\"
399 "7D2F387510109040002000060BECB6AB", usersid
);
402 MultiByteToWideChar(CP_ACP
, 0, comppath
, -1, substrW
, MAX_PATH
);
403 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
405 MultiByteToWideChar(CP_ACP
, 0, prodpath
, -1, substrW
, MAX_PATH
);
406 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE
, substrW
, access
);
409 static UINT
do_query(MSIHANDLE hdb
, const char *query
, MSIHANDLE
*phrec
)
414 /* open a select query */
415 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
416 if (r
!= ERROR_SUCCESS
)
418 r
= MsiViewExecute(hview
, 0);
419 if (r
!= ERROR_SUCCESS
)
421 ret
= MsiViewFetch(hview
, phrec
);
422 r
= MsiViewClose(hview
);
423 if (r
!= ERROR_SUCCESS
)
425 r
= MsiCloseHandle(hview
);
426 if (r
!= ERROR_SUCCESS
)
431 static UINT
run_query( MSIHANDLE hdb
, const char *query
)
436 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
437 if( r
!= ERROR_SUCCESS
)
440 r
= MsiViewExecute(hview
, 0);
441 if( r
== ERROR_SUCCESS
)
442 r
= MsiViewClose(hview
);
443 MsiCloseHandle(hview
);
447 static UINT
create_component_table( MSIHANDLE hdb
)
449 return run_query( hdb
,
450 "CREATE TABLE `Component` ( "
451 "`Component` CHAR(72) NOT NULL, "
452 "`ComponentId` CHAR(38), "
453 "`Directory_` CHAR(72) NOT NULL, "
454 "`Attributes` SHORT NOT NULL, "
455 "`Condition` CHAR(255), "
456 "`KeyPath` CHAR(72) "
457 "PRIMARY KEY `Component`)" );
460 static UINT
create_feature_table( MSIHANDLE hdb
)
462 return run_query( hdb
,
463 "CREATE TABLE `Feature` ( "
464 "`Feature` CHAR(38) NOT NULL, "
465 "`Feature_Parent` CHAR(38), "
467 "`Description` CHAR(255), "
468 "`Display` SHORT NOT NULL, "
469 "`Level` SHORT NOT NULL, "
470 "`Directory_` CHAR(72), "
471 "`Attributes` SHORT NOT NULL "
472 "PRIMARY KEY `Feature`)" );
475 static UINT
create_feature_components_table( MSIHANDLE hdb
)
477 return run_query( hdb
,
478 "CREATE TABLE `FeatureComponents` ( "
479 "`Feature_` CHAR(38) NOT NULL, "
480 "`Component_` CHAR(72) NOT NULL "
481 "PRIMARY KEY `Feature_`, `Component_` )" );
484 static UINT
create_file_table( MSIHANDLE hdb
)
486 return run_query( hdb
,
487 "CREATE TABLE `File` ("
488 "`File` CHAR(72) NOT NULL, "
489 "`Component_` CHAR(72) NOT NULL, "
490 "`FileName` CHAR(255) NOT NULL, "
491 "`FileSize` LONG NOT NULL, "
492 "`Version` CHAR(72), "
493 "`Language` CHAR(20), "
494 "`Attributes` SHORT, "
495 "`Sequence` SHORT NOT NULL "
496 "PRIMARY KEY `File`)" );
499 static UINT
create_remove_file_table( MSIHANDLE hdb
)
501 return run_query( hdb
,
502 "CREATE TABLE `RemoveFile` ("
503 "`FileKey` CHAR(72) NOT NULL, "
504 "`Component_` CHAR(72) NOT NULL, "
505 "`FileName` CHAR(255) LOCALIZABLE, "
506 "`DirProperty` CHAR(72) NOT NULL, "
507 "`InstallMode` SHORT NOT NULL "
508 "PRIMARY KEY `FileKey`)" );
511 static UINT
create_appsearch_table( MSIHANDLE hdb
)
513 return run_query( hdb
,
514 "CREATE TABLE `AppSearch` ("
515 "`Property` CHAR(72) NOT NULL, "
516 "`Signature_` CHAR(72) NOT NULL "
517 "PRIMARY KEY `Property`, `Signature_`)" );
520 static UINT
create_reglocator_table( MSIHANDLE hdb
)
522 return run_query( hdb
,
523 "CREATE TABLE `RegLocator` ("
524 "`Signature_` CHAR(72) NOT NULL, "
525 "`Root` SHORT NOT NULL, "
526 "`Key` CHAR(255) NOT NULL, "
529 "PRIMARY KEY `Signature_`)" );
532 static UINT
create_signature_table( MSIHANDLE hdb
)
534 return run_query( hdb
,
535 "CREATE TABLE `Signature` ("
536 "`Signature` CHAR(72) NOT NULL, "
537 "`FileName` CHAR(255) NOT NULL, "
538 "`MinVersion` CHAR(20), "
539 "`MaxVersion` CHAR(20), "
544 "`Languages` CHAR(255) "
545 "PRIMARY KEY `Signature`)" );
548 static UINT
create_launchcondition_table( MSIHANDLE hdb
)
550 return run_query( hdb
,
551 "CREATE TABLE `LaunchCondition` ("
552 "`Condition` CHAR(255) NOT NULL, "
553 "`Description` CHAR(255) NOT NULL "
554 "PRIMARY KEY `Condition`)" );
557 static UINT
create_property_table( MSIHANDLE hdb
)
559 return run_query( hdb
,
560 "CREATE TABLE `Property` ("
561 "`Property` CHAR(72) NOT NULL, "
563 "PRIMARY KEY `Property`)" );
566 static UINT
create_install_execute_sequence_table( MSIHANDLE hdb
)
568 return run_query( hdb
,
569 "CREATE TABLE `InstallExecuteSequence` ("
570 "`Action` CHAR(72) NOT NULL, "
571 "`Condition` CHAR(255), "
573 "PRIMARY KEY `Action`)" );
576 static UINT
create_media_table( MSIHANDLE hdb
)
578 return run_query( hdb
,
579 "CREATE TABLE `Media` ("
580 "`DiskId` SHORT NOT NULL, "
581 "`LastSequence` SHORT NOT NULL, "
582 "`DiskPrompt` CHAR(64), "
583 "`Cabinet` CHAR(255), "
584 "`VolumeLabel` CHAR(32), "
586 "PRIMARY KEY `DiskId`)" );
589 static UINT
create_ccpsearch_table( MSIHANDLE hdb
)
591 return run_query( hdb
,
592 "CREATE TABLE `CCPSearch` ("
593 "`Signature_` CHAR(72) NOT NULL "
594 "PRIMARY KEY `Signature_`)" );
597 static UINT
create_drlocator_table( MSIHANDLE hdb
)
599 return run_query( hdb
,
600 "CREATE TABLE `DrLocator` ("
601 "`Signature_` CHAR(72) NOT NULL, "
602 "`Parent` CHAR(72), "
605 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
608 static UINT
create_complocator_table( MSIHANDLE hdb
)
610 return run_query( hdb
,
611 "CREATE TABLE `CompLocator` ("
612 "`Signature_` CHAR(72) NOT NULL, "
613 "`ComponentId` CHAR(38) NOT NULL, "
615 "PRIMARY KEY `Signature_`)" );
618 static UINT
create_inilocator_table( MSIHANDLE hdb
)
620 return run_query( hdb
,
621 "CREATE TABLE `IniLocator` ("
622 "`Signature_` CHAR(72) NOT NULL, "
623 "`FileName` CHAR(255) NOT NULL, "
624 "`Section` CHAR(96)NOT NULL, "
625 "`Key` CHAR(128)NOT NULL, "
628 "PRIMARY KEY `Signature_`)" );
631 static UINT
create_custom_action_table( MSIHANDLE hdb
)
633 return run_query( hdb
,
634 "CREATE TABLE `CustomAction` ("
635 "`Action` CHAR(72) NOT NULL, "
636 "`Type` SHORT NOT NULL, "
637 "`Source` CHAR(75), "
638 "`Target` CHAR(255) "
639 "PRIMARY KEY `Action`)" );
642 #define make_add_entry(type, qtext) \
643 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
645 char insert[] = qtext; \
648 sz = strlen(values) + sizeof insert; \
649 query = HeapAlloc(GetProcessHeap(),0,sz); \
650 sprintf(query,insert,values); \
651 r = run_query( hdb, query ); \
652 HeapFree(GetProcessHeap(), 0, query); \
656 make_add_entry(component
,
657 "INSERT INTO `Component` "
658 "(`Component`, `ComponentId`, `Directory_`, "
659 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
661 make_add_entry(directory
,
662 "INSERT INTO `Directory` "
663 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
665 make_add_entry(feature
,
666 "INSERT INTO `Feature` "
667 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
668 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
670 make_add_entry(feature_components
,
671 "INSERT INTO `FeatureComponents` "
672 "(`Feature_`, `Component_`) VALUES( %s )")
675 "INSERT INTO `File` "
676 "(`File`, `Component_`, `FileName`, `FileSize`, "
677 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
679 make_add_entry(appsearch
,
680 "INSERT INTO `AppSearch` "
681 "(`Property`, `Signature_`) VALUES( %s )")
683 make_add_entry(signature
,
684 "INSERT INTO `Signature` "
685 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
686 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
689 make_add_entry(launchcondition
,
690 "INSERT INTO `LaunchCondition` "
691 "(`Condition`, `Description`) VALUES( %s )")
693 make_add_entry(property
,
694 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
696 make_add_entry(install_execute_sequence
,
697 "INSERT INTO `InstallExecuteSequence` "
698 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
700 make_add_entry(media
,
701 "INSERT INTO `Media` "
702 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
703 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
705 make_add_entry(ccpsearch
,
706 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
708 make_add_entry(drlocator
,
709 "INSERT INTO `DrLocator` "
710 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
712 make_add_entry(complocator
,
713 "INSERT INTO `CompLocator` "
714 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
716 make_add_entry(inilocator
,
717 "INSERT INTO `IniLocator` "
718 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
721 make_add_entry(custom_action
,
722 "INSERT INTO `CustomAction` "
723 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
725 static UINT
add_reglocator_entry( MSIHANDLE hdb
, const char *sig
, UINT root
, const char *path
,
726 const char *name
, UINT type
)
728 const char insert
[] =
729 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
730 "VALUES( '%s', %u, '%s', '%s', %u )";
734 sz
= strlen( sig
) + 10 + strlen( path
) + strlen( name
) + 10 + sizeof( insert
);
735 query
= HeapAlloc( GetProcessHeap(), 0, sz
);
736 sprintf( query
, insert
, sig
, root
, path
, name
, type
);
737 r
= run_query( hdb
, query
);
738 HeapFree( GetProcessHeap(), 0, query
);
742 static UINT
set_summary_info(MSIHANDLE hdb
)
747 /* build summary info */
748 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
749 ok( res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n" );
751 res
= MsiSummaryInfoSetPropertyA(suminfo
,2, VT_LPSTR
, 0,NULL
,
752 "Installation Database");
753 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
755 res
= MsiSummaryInfoSetPropertyA(suminfo
,3, VT_LPSTR
, 0,NULL
,
756 "Installation Database");
757 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
759 res
= MsiSummaryInfoSetPropertyA(suminfo
,4, VT_LPSTR
, 0,NULL
,
761 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
763 res
= MsiSummaryInfoSetPropertyA(suminfo
,7, VT_LPSTR
, 0,NULL
,
765 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
767 res
= MsiSummaryInfoSetPropertyA(suminfo
,9, VT_LPSTR
, 0,NULL
,
768 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
769 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
771 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
772 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
774 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
775 ok( res
== ERROR_SUCCESS
, "Failed to set summary info\n" );
777 res
= MsiSummaryInfoPersist(suminfo
);
778 ok( res
== ERROR_SUCCESS
, "Failed to make summary info persist\n" );
780 res
= MsiCloseHandle( suminfo
);
781 ok( res
== ERROR_SUCCESS
, "Failed to close suminfo\n" );
787 static MSIHANDLE
create_package_db(void)
792 DeleteFileA(msifile
);
794 /* create an empty database */
795 res
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
796 ok( res
== ERROR_SUCCESS
, "Failed to create database %u\n", res
);
797 if( res
!= ERROR_SUCCESS
)
800 res
= MsiDatabaseCommit( hdb
);
801 ok( res
== ERROR_SUCCESS
, "Failed to commit database\n" );
803 res
= set_summary_info(hdb
);
804 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
806 res
= run_query( hdb
,
807 "CREATE TABLE `Directory` ( "
808 "`Directory` CHAR(255) NOT NULL, "
809 "`Directory_Parent` CHAR(255), "
810 "`DefaultDir` CHAR(255) NOT NULL "
811 "PRIMARY KEY `Directory`)" );
812 ok( res
== ERROR_SUCCESS
, "Failed to create directory table\n" );
817 static UINT
package_from_db(MSIHANDLE hdb
, MSIHANDLE
*handle
)
823 sprintf(szPackage
, "#%u", hdb
);
824 res
= MsiOpenPackageA(szPackage
, &hPackage
);
825 if (res
!= ERROR_SUCCESS
)
831 res
= MsiCloseHandle(hdb
);
832 if (res
!= ERROR_SUCCESS
)
834 MsiCloseHandle(hPackage
);
839 return ERROR_SUCCESS
;
842 static void create_test_file(const CHAR
*name
)
847 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
848 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
849 WriteFile(file
, name
, strlen(name
), &written
, NULL
);
850 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
854 typedef struct _tagVS_VERSIONINFO
861 VS_FIXEDFILEINFO Value
;
866 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
867 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
869 static BOOL
create_file_with_version(const CHAR
*name
, LONG ms
, LONG ls
)
871 VS_VERSIONINFO
*pVerInfo
;
872 VS_FIXEDFILEINFO
*pFixedInfo
;
879 GetSystemDirectoryA(path
, MAX_PATH
);
880 /* Some dlls can't be updated on Vista/W2K8 */
881 lstrcatA(path
, "\\version.dll");
883 CopyFileA(path
, name
, FALSE
);
885 size
= GetFileVersionInfoSizeA(path
, &handle
);
886 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
888 GetFileVersionInfoA(path
, 0, size
, buffer
);
890 pVerInfo
= (VS_VERSIONINFO
*)buffer
;
891 ofs
= (BYTE
*)&pVerInfo
->szKey
[lstrlenW(pVerInfo
->szKey
) + 1];
892 pFixedInfo
= (VS_FIXEDFILEINFO
*)roundpos(pVerInfo
, ofs
, 4);
894 pFixedInfo
->dwFileVersionMS
= ms
;
895 pFixedInfo
->dwFileVersionLS
= ls
;
896 pFixedInfo
->dwProductVersionMS
= ms
;
897 pFixedInfo
->dwProductVersionLS
= ls
;
899 resource
= BeginUpdateResourceA(name
, FALSE
);
903 if (!UpdateResourceA(resource
, (LPCSTR
)RT_VERSION
, (LPCSTR
)MAKEINTRESOURCE(VS_VERSION_INFO
),
904 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), buffer
, size
))
907 if (!EndUpdateResourceA(resource
, FALSE
))
913 HeapFree(GetProcessHeap(), 0, buffer
);
917 static BOOL
notify_system_change(DWORD event_type
, STATEMGRSTATUS
*status
)
919 RESTOREPOINTINFOA spec
;
921 spec
.dwEventType
= event_type
;
922 spec
.dwRestorePtType
= APPLICATION_INSTALL
;
923 spec
.llSequenceNumber
= status
->llSequenceNumber
;
924 lstrcpyA(spec
.szDescription
, "msitest restore point");
926 return pSRSetRestorePointA(&spec
, status
);
929 static void remove_restore_point(DWORD seq_number
)
933 res
= pSRRemoveRestorePoint(seq_number
);
934 if (res
!= ERROR_SUCCESS
)
935 trace("Failed to remove the restore point : %08x\n", res
);
938 static BOOL
is_root(const char *path
)
940 return (isalpha(path
[0]) && path
[1] == ':' && path
[2] == '\\' && !path
[3]);
943 static void test_createpackage(void)
945 MSIHANDLE hPackage
= 0;
948 res
= package_from_db(create_package_db(), &hPackage
);
949 if (res
== ERROR_INSTALL_PACKAGE_REJECTED
)
951 skip("Not enough rights to perform tests\n");
952 DeleteFileA(msifile
);
955 ok( res
== ERROR_SUCCESS
, " Failed to create package %u\n", res
);
957 res
= MsiCloseHandle( hPackage
);
958 ok( res
== ERROR_SUCCESS
, "Failed to close package\n" );
959 DeleteFileA(msifile
);
962 static void test_doaction( void )
967 r
= MsiDoActionA( -1, NULL
);
968 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
970 r
= package_from_db(create_package_db(), &hpkg
);
971 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
973 skip("Not enough rights to perform tests\n");
974 DeleteFileA(msifile
);
977 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
979 r
= MsiDoActionA(hpkg
, NULL
);
980 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
982 r
= MsiDoActionA(0, "boo");
983 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
985 r
= MsiDoActionA(hpkg
, "boo");
986 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "wrong return val\n");
988 MsiCloseHandle( hpkg
);
989 DeleteFileA(msifile
);
992 static void test_gettargetpath_bad(void)
994 static const WCHAR boo
[] = {'b','o','o',0};
995 static const WCHAR empty
[] = {0};
1002 r
= package_from_db(create_package_db(), &hpkg
);
1003 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1005 skip("Not enough rights to perform tests\n");
1006 DeleteFileA(msifile
);
1009 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1011 r
= MsiGetTargetPathA( 0, NULL
, NULL
, NULL
);
1012 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1014 r
= MsiGetTargetPathA( 0, NULL
, NULL
, &sz
);
1015 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1017 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1018 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1020 r
= MsiGetTargetPathA( 0, "boo", NULL
, NULL
);
1021 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1023 r
= MsiGetTargetPathA( hpkg
, "boo", NULL
, NULL
);
1024 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1026 r
= MsiGetTargetPathA( hpkg
, "boo", buffer
, NULL
);
1027 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1030 r
= MsiGetTargetPathA( hpkg
, "", buffer
, &sz
);
1031 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1033 r
= MsiGetTargetPathW( 0, NULL
, NULL
, NULL
);
1034 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1036 r
= MsiGetTargetPathW( 0, NULL
, NULL
, &sz
);
1037 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1039 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1040 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1042 r
= MsiGetTargetPathW( 0, boo
, NULL
, NULL
);
1043 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1045 r
= MsiGetTargetPathW( hpkg
, boo
, NULL
, NULL
);
1046 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1048 r
= MsiGetTargetPathW( hpkg
, boo
, bufferW
, NULL
);
1049 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1052 r
= MsiGetTargetPathW( hpkg
, empty
, bufferW
, &sz
);
1053 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1055 MsiCloseHandle( hpkg
);
1056 DeleteFileA(msifile
);
1059 static void query_file_path(MSIHANDLE hpkg
, LPCSTR file
, LPSTR buff
)
1065 rec
= MsiCreateRecord( 1 );
1066 ok(rec
, "MsiCreate record failed\n");
1068 r
= MsiRecordSetStringA( rec
, 0, file
);
1069 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1072 r
= MsiFormatRecordA( hpkg
, rec
, buff
, &size
);
1073 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1075 MsiCloseHandle( rec
);
1078 static void test_settargetpath(void)
1080 char tempdir
[MAX_PATH
+8], buffer
[MAX_PATH
], file
[MAX_PATH
];
1086 hdb
= create_package_db();
1087 ok ( hdb
, "failed to create package database\n" );
1089 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
1090 ok( r
== S_OK
, "failed to add directory entry: %d\n" , r
);
1092 r
= create_component_table( hdb
);
1093 ok( r
== S_OK
, "cannot create Component table: %d\n", r
);
1095 r
= add_component_entry( hdb
, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1096 ok( r
== S_OK
, "cannot add dummy component: %d\n", r
);
1098 r
= add_component_entry( hdb
, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1099 ok( r
== S_OK
, "cannot add test component: %d\n", r
);
1101 r
= create_feature_table( hdb
);
1102 ok( r
== S_OK
, "cannot create Feature table: %d\n", r
);
1104 r
= add_feature_entry( hdb
, "'TestFeature', '', '', '', 0, 1, '', 0" );
1105 ok( r
== ERROR_SUCCESS
, "cannot add TestFeature to Feature table: %d\n", r
);
1107 r
= create_feature_components_table( hdb
);
1108 ok( r
== S_OK
, "cannot create FeatureComponents table: %d\n", r
);
1110 r
= add_feature_components_entry( hdb
, "'TestFeature', 'RootComp'" );
1111 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
1113 r
= add_feature_components_entry( hdb
, "'TestFeature', 'TestComp'" );
1114 ok( r
== S_OK
, "cannot insert component into FeatureComponents table: %d\n", r
);
1116 add_directory_entry( hdb
, "'TestParent', 'TARGETDIR', 'TestParent'" );
1117 add_directory_entry( hdb
, "'TestDir', 'TestParent', 'TestDir'" );
1119 r
= create_file_table( hdb
);
1120 ok( r
== S_OK
, "cannot create File table: %d\n", r
);
1122 r
= add_file_entry( hdb
, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1123 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
1125 r
= add_file_entry( hdb
, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1126 ok( r
== S_OK
, "cannot add file to the File table: %d\n", r
);
1128 r
= package_from_db( hdb
, &hpkg
);
1129 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1131 skip("Not enough rights to perform tests\n");
1132 DeleteFileA(msifile
);
1135 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1137 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
1139 r
= MsiDoActionA( hpkg
, "CostInitialize");
1140 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
1142 r
= MsiDoActionA( hpkg
, "FileCost");
1143 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
1145 r
= MsiDoActionA( hpkg
, "CostFinalize");
1146 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
1149 sz
= sizeof(buffer
);
1150 r
= MsiGetPropertyA( hpkg
, "OutOfNoRbDiskSpace", buffer
, &sz
);
1151 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1152 trace( "OutOfNoRbDiskSpace = \"%s\"\n", buffer
);
1154 r
= MsiSetTargetPathA( 0, NULL
, NULL
);
1155 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1157 r
= MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1158 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
1160 r
= MsiSetTargetPathA( hpkg
, "boo", NULL
);
1161 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
1163 r
= MsiSetTargetPathA( hpkg
, "boo", "c:\\bogusx" );
1164 ok( r
== ERROR_DIRECTORY
, "wrong return val\n");
1166 sz
= sizeof tempdir
- 1;
1167 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", tempdir
, &sz
);
1168 sprintf( file
, "%srootfile.txt", tempdir
);
1170 query_file_path( hpkg
, "[#RootFile]", buffer
);
1171 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1172 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1174 GetTempFileNameA( tempdir
, "_wt", 0, buffer
);
1175 sprintf( tempdir
, "%s\\subdir", buffer
);
1177 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1178 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1179 "MsiSetTargetPath on file returned %d\n", r
);
1181 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1182 ok( r
== ERROR_SUCCESS
|| r
== ERROR_DIRECTORY
,
1183 "MsiSetTargetPath on 'subdir' of file returned %d\n", r
);
1185 DeleteFileA( buffer
);
1187 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", buffer
);
1188 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1190 r
= GetFileAttributesA( buffer
);
1191 ok ( r
== INVALID_FILE_ATTRIBUTES
, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r
);
1193 r
= MsiSetTargetPathA( hpkg
, "TARGETDIR", tempdir
);
1194 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath on subsubdir returned %d\n", r
);
1197 sz
= sizeof buffer
- 1;
1198 lstrcatA( tempdir
, "\\" );
1199 r
= MsiGetTargetPathA( hpkg
, "TARGETDIR", buffer
, &sz
);
1200 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1201 ok( !lstrcmpA(buffer
, tempdir
), "Expected %s, got %s\n", tempdir
, buffer
);
1203 sprintf( file
, "%srootfile.txt", tempdir
);
1204 query_file_path( hpkg
, "[#RootFile]", buffer
);
1205 ok( !lstrcmpA(buffer
, file
), "Expected %s, got %s\n", file
, buffer
);
1208 sz
= sizeof(buffer
);
1209 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1210 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1211 lstrcatA( tempdir
, "TestParent\\" );
1212 ok( !lstrcmpiA(buffer
, tempdir
), "Expected \"%s\", got \"%s\"\n", tempdir
, buffer
);
1214 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two" );
1215 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1218 sz
= sizeof(buffer
);
1219 r
= MsiGetPropertyA( hpkg
, "TestParent", buffer
, &sz
);
1220 ok( r
== ERROR_SUCCESS
, "MsiGetProperty returned %u\n", r
);
1221 ok( lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\"),
1222 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer
);
1225 query_file_path( hpkg
, "[#TestFile]", buffer
);
1226 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\TestDir\\testfile.txt"),
1227 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer
);
1230 sz
= sizeof buffer
- 1;
1231 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1232 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1233 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer
);
1235 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\one\\two\\three" );
1236 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1239 sz
= sizeof buffer
- 1;
1240 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1241 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1242 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer
);
1244 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\one\\\\two " );
1245 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1248 sz
= sizeof buffer
- 1;
1249 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1250 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1251 ok( !lstrcmpiA(buffer
, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer
);
1253 r
= MsiSetTargetPathA( hpkg
, "TestParent", "C:\\\\ Program Files \\\\ " );
1254 ok( r
== ERROR_SUCCESS
, "MsiSetTargetPath returned %d\n", r
);
1257 sz
= sizeof buffer
- 1;
1258 r
= MsiGetTargetPathA( hpkg
, "TestParent", buffer
, &sz
);
1259 ok( r
== ERROR_SUCCESS
, "failed to get target path: %d\n", r
);
1260 ok( !lstrcmpiA(buffer
, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer
);
1262 MsiCloseHandle( hpkg
);
1265 static void test_condition(void)
1267 static const WCHAR cond1
[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1268 static const WCHAR cond2
[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1269 static const WCHAR cond3
[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1270 static const WCHAR cond4
[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1274 r
= package_from_db(create_package_db(), &hpkg
);
1275 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
1277 skip("Not enough rights to perform tests\n");
1278 DeleteFileA(msifile
);
1281 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
1283 r
= MsiEvaluateConditionA(0, NULL
);
1284 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1286 r
= MsiEvaluateConditionA(hpkg
, NULL
);
1287 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1289 r
= MsiEvaluateConditionA(hpkg
, "");
1290 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1292 r
= MsiEvaluateConditionA(hpkg
, "1");
1293 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1295 r
= MsiEvaluateConditionA(hpkg
, "0");
1296 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1298 r
= MsiEvaluateConditionA(hpkg
, "-1");
1299 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1301 r
= MsiEvaluateConditionA(hpkg
, "0 = 0");
1302 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1304 r
= MsiEvaluateConditionA(hpkg
, "0 <> 0");
1305 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1307 r
= MsiEvaluateConditionA(hpkg
, "0 = 1");
1308 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1310 r
= MsiEvaluateConditionA(hpkg
, "0 > 1");
1311 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1313 r
= MsiEvaluateConditionA(hpkg
, "0 ~> 1");
1314 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1316 r
= MsiEvaluateConditionA(hpkg
, "1 > 1");
1317 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1319 r
= MsiEvaluateConditionA(hpkg
, "1 ~> 1");
1320 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1322 r
= MsiEvaluateConditionA(hpkg
, "0 >= 1");
1323 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1325 r
= MsiEvaluateConditionA(hpkg
, "0 ~>= 1");
1326 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1328 r
= MsiEvaluateConditionA(hpkg
, "1 >= 1");
1329 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1331 r
= MsiEvaluateConditionA(hpkg
, "1 ~>= 1");
1332 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1334 r
= MsiEvaluateConditionA(hpkg
, "0 < 1");
1335 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1337 r
= MsiEvaluateConditionA(hpkg
, "0 ~< 1");
1338 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1340 r
= MsiEvaluateConditionA(hpkg
, "1 < 1");
1341 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1343 r
= MsiEvaluateConditionA(hpkg
, "1 ~< 1");
1344 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1346 r
= MsiEvaluateConditionA(hpkg
, "0 <= 1");
1347 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1349 r
= MsiEvaluateConditionA(hpkg
, "0 ~<= 1");
1350 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1352 r
= MsiEvaluateConditionA(hpkg
, "1 <= 1");
1353 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1355 r
= MsiEvaluateConditionA(hpkg
, "1 ~<= 1");
1356 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1358 r
= MsiEvaluateConditionA(hpkg
, "0 >=");
1359 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1361 r
= MsiEvaluateConditionA(hpkg
, " ");
1362 ok( r
== MSICONDITION_NONE
, "wrong return val\n");
1364 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"1\"");
1365 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1367 r
= MsiEvaluateConditionA(hpkg
, "LicView <> \"0\"");
1368 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1370 r
= MsiEvaluateConditionA(hpkg
, "LicView <> LicView");
1371 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1373 r
= MsiEvaluateConditionA(hpkg
, "not 0");
1374 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1376 r
= MsiEvaluateConditionA(hpkg
, "not LicView");
1377 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1379 r
= MsiEvaluateConditionA(hpkg
, "\"Testing\" ~<< \"Testing\"");
1380 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1382 r
= MsiEvaluateConditionA(hpkg
, "LicView ~<< \"Testing\"");
1383 ok (r
== MSICONDITION_FALSE
, "wrong return val\n");
1385 r
= MsiEvaluateConditionA(hpkg
, "Not LicView ~<< \"Testing\"");
1386 ok (r
== MSICONDITION_TRUE
, "wrong return val\n");
1388 r
= MsiEvaluateConditionA(hpkg
, "not \"A\"");
1389 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1391 r
= MsiEvaluateConditionA(hpkg
, "~not \"A\"");
1392 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1394 r
= MsiEvaluateConditionA(hpkg
, "\"0\"");
1395 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1397 r
= MsiEvaluateConditionA(hpkg
, "1 and 2");
1398 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1400 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 3");
1401 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1403 r
= MsiEvaluateConditionA(hpkg
, "not 0 and 0");
1404 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1406 r
= MsiEvaluateConditionA(hpkg
, "not 0 or 1");
1407 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1409 r
= MsiEvaluateConditionA(hpkg
, "(0)");
1410 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1412 r
= MsiEvaluateConditionA(hpkg
, "(((((1))))))");
1413 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1415 r
= MsiEvaluateConditionA(hpkg
, "(((((1)))))");
1416 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1418 r
= MsiEvaluateConditionA(hpkg
, " \"A\" < \"B\" ");
1419 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1421 r
= MsiEvaluateConditionA(hpkg
, " \"A\" > \"B\" ");
1422 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1424 r
= MsiEvaluateConditionA(hpkg
, " \"1\" > \"12\" ");
1425 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1427 r
= MsiEvaluateConditionA(hpkg
, " \"100\" < \"21\" ");
1428 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1430 r
= MsiEvaluateConditionA(hpkg
, "0 < > 0");
1431 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1433 r
= MsiEvaluateConditionA(hpkg
, "(1<<1) == 2");
1434 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1436 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = \"a\" ");
1437 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1439 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~ = \"a\" ");
1440 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1442 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= \"a\" ");
1443 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1445 r
= MsiEvaluateConditionA(hpkg
, " \"A\" ~= 1 ");
1446 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1448 r
= MsiEvaluateConditionA(hpkg
, " \"A\" = 1 ");
1449 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1451 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= 1 ");
1452 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1454 r
= MsiEvaluateConditionA(hpkg
, " 1 ~= \"1\" ");
1455 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1457 r
= MsiEvaluateConditionA(hpkg
, " 1 = \"1\" ");
1458 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1460 r
= MsiEvaluateConditionA(hpkg
, " 0 = \"1\" ");
1461 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1463 r
= MsiEvaluateConditionA(hpkg
, " 0 < \"100\" ");
1464 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1466 r
= MsiEvaluateConditionA(hpkg
, " 100 > \"0\" ");
1467 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1469 r
= MsiEvaluateConditionA(hpkg
, "1 XOR 1");
1470 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1472 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1");
1473 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1475 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 0");
1476 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1478 r
= MsiEvaluateConditionA(hpkg
, "0 IMP 0");
1479 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1481 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 0");
1482 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1484 r
= MsiEvaluateConditionA(hpkg
, "0 EQV 1");
1485 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1487 r
= MsiEvaluateConditionA(hpkg
, "1 IMP 1 OR 0");
1488 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1490 r
= MsiEvaluateConditionA(hpkg
, "1 IMPL 1");
1491 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1493 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" >< \"S\" ");
1494 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1496 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"s\" ");
1497 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1499 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"\" ");
1500 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1502 r
= MsiEvaluateConditionA(hpkg
, "\"ASFD\" ~>< \"sss\" ");
1503 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1505 MsiSetPropertyA(hpkg
, "mm", "5" );
1507 r
= MsiEvaluateConditionA(hpkg
, "mm = 5");
1508 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1510 r
= MsiEvaluateConditionA(hpkg
, "mm < 6");
1511 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1513 r
= MsiEvaluateConditionA(hpkg
, "mm <= 5");
1514 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1516 r
= MsiEvaluateConditionA(hpkg
, "mm > 4");
1517 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1519 r
= MsiEvaluateConditionA(hpkg
, "mm < 12");
1520 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1522 r
= MsiEvaluateConditionA(hpkg
, "mm = \"5\"");
1523 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1525 r
= MsiEvaluateConditionA(hpkg
, "0 = \"\"");
1526 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1528 r
= MsiEvaluateConditionA(hpkg
, "0 AND \"\"");
1529 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1531 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"\"");
1532 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1534 r
= MsiEvaluateConditionA(hpkg
, "1 AND \"1\"");
1535 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1537 r
= MsiEvaluateConditionA(hpkg
, "3 >< 1");
1538 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1540 r
= MsiEvaluateConditionA(hpkg
, "3 >< 4");
1541 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1543 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 0");
1544 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1546 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1");
1547 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1549 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 OR 0");
1550 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1552 r
= MsiEvaluateConditionA(hpkg
, "0 AND 1 OR 1");
1553 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1555 r
= MsiEvaluateConditionA(hpkg
, "0 AND 0 OR 1");
1556 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1558 r
= MsiEvaluateConditionA(hpkg
, "NOT 0 AND 1 OR 0");
1559 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1561 r
= MsiEvaluateConditionA(hpkg
, "_1 = _1");
1562 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1564 r
= MsiEvaluateConditionA(hpkg
, "( 1 AND 1 ) = 2");
1565 ok( r
== MSICONDITION_ERROR
, "wrong return val\n");
1567 r
= MsiEvaluateConditionA(hpkg
, "NOT ( 1 AND 1 )");
1568 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1570 r
= MsiEvaluateConditionA(hpkg
, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1571 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1573 r
= MsiEvaluateConditionA(hpkg
, "Installed<>\"\"");
1574 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1576 r
= MsiEvaluateConditionA(hpkg
, "NOT 1 AND 0");
1577 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1579 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1580 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1582 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1583 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1585 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<0");
1586 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1588 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>0");
1589 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1591 r
= MsiEvaluateConditionA(hpkg
, "bandalmael>=0");
1592 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1594 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<=0");
1595 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1597 r
= MsiEvaluateConditionA(hpkg
, "bandalmael~<>0");
1598 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1600 MsiSetPropertyA(hpkg
, "bandalmael", "0" );
1601 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1602 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1604 MsiSetPropertyA(hpkg
, "bandalmael", "" );
1605 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1606 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1608 MsiSetPropertyA(hpkg
, "bandalmael", "asdf" );
1609 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1610 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1612 MsiSetPropertyA(hpkg
, "bandalmael", "0asdf" );
1613 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1614 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1616 MsiSetPropertyA(hpkg
, "bandalmael", "0 " );
1617 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1618 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1620 MsiSetPropertyA(hpkg
, "bandalmael", "-0" );
1621 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1622 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1624 MsiSetPropertyA(hpkg
, "bandalmael", "0000000000000" );
1625 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1626 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1628 MsiSetPropertyA(hpkg
, "bandalmael", "--0" );
1629 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1630 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1632 MsiSetPropertyA(hpkg
, "bandalmael", "0x00" );
1633 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1634 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1636 MsiSetPropertyA(hpkg
, "bandalmael", "-" );
1637 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1638 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1640 MsiSetPropertyA(hpkg
, "bandalmael", "+0" );
1641 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1642 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1644 MsiSetPropertyA(hpkg
, "bandalmael", "0.0" );
1645 r
= MsiEvaluateConditionA(hpkg
, "bandalmael=0");
1646 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1647 r
= MsiEvaluateConditionA(hpkg
, "bandalmael<>0");
1648 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1650 MsiSetPropertyA(hpkg
, "one", "hi");
1651 MsiSetPropertyA(hpkg
, "two", "hithere");
1652 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1653 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1655 MsiSetPropertyA(hpkg
, "one", "hithere");
1656 MsiSetPropertyA(hpkg
, "two", "hi");
1657 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1658 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1660 MsiSetPropertyA(hpkg
, "one", "hello");
1661 MsiSetPropertyA(hpkg
, "two", "hi");
1662 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1663 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1665 MsiSetPropertyA(hpkg
, "one", "hellohithere");
1666 MsiSetPropertyA(hpkg
, "two", "hi");
1667 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1668 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1670 MsiSetPropertyA(hpkg
, "one", "");
1671 MsiSetPropertyA(hpkg
, "two", "hi");
1672 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1673 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1675 MsiSetPropertyA(hpkg
, "one", "hi");
1676 MsiSetPropertyA(hpkg
, "two", "");
1677 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1678 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1680 MsiSetPropertyA(hpkg
, "one", "");
1681 MsiSetPropertyA(hpkg
, "two", "");
1682 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1683 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1685 MsiSetPropertyA(hpkg
, "one", "1234");
1686 MsiSetPropertyA(hpkg
, "two", "1");
1687 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1688 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1690 MsiSetPropertyA(hpkg
, "one", "one 1234");
1691 MsiSetPropertyA(hpkg
, "two", "1");
1692 r
= MsiEvaluateConditionA(hpkg
, "one >< two");
1693 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1695 MsiSetPropertyA(hpkg
, "one", "hithere");
1696 MsiSetPropertyA(hpkg
, "two", "hi");
1697 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1698 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1700 MsiSetPropertyA(hpkg
, "one", "hi");
1701 MsiSetPropertyA(hpkg
, "two", "hithere");
1702 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1703 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1705 MsiSetPropertyA(hpkg
, "one", "hi");
1706 MsiSetPropertyA(hpkg
, "two", "hi");
1707 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1708 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1710 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1711 MsiSetPropertyA(hpkg
, "two", "hi");
1712 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1713 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1715 MsiSetPropertyA(hpkg
, "one", "");
1716 MsiSetPropertyA(hpkg
, "two", "hi");
1717 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1718 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1720 MsiSetPropertyA(hpkg
, "one", "hithere");
1721 MsiSetPropertyA(hpkg
, "two", "");
1722 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1723 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1725 MsiSetPropertyA(hpkg
, "one", "");
1726 MsiSetPropertyA(hpkg
, "two", "");
1727 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1728 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1730 MsiSetPropertyA(hpkg
, "one", "1234");
1731 MsiSetPropertyA(hpkg
, "two", "1");
1732 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1733 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1735 MsiSetPropertyA(hpkg
, "one", "1234 one");
1736 MsiSetPropertyA(hpkg
, "two", "1");
1737 r
= MsiEvaluateConditionA(hpkg
, "one << two");
1738 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1740 MsiSetPropertyA(hpkg
, "one", "hithere");
1741 MsiSetPropertyA(hpkg
, "two", "there");
1742 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1743 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1745 MsiSetPropertyA(hpkg
, "one", "hithere");
1746 MsiSetPropertyA(hpkg
, "two", "hi");
1747 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1748 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1750 MsiSetPropertyA(hpkg
, "one", "there");
1751 MsiSetPropertyA(hpkg
, "two", "hithere");
1752 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1753 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1755 MsiSetPropertyA(hpkg
, "one", "there");
1756 MsiSetPropertyA(hpkg
, "two", "there");
1757 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1758 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1760 MsiSetPropertyA(hpkg
, "one", "abcdhithere");
1761 MsiSetPropertyA(hpkg
, "two", "hi");
1762 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1763 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1765 MsiSetPropertyA(hpkg
, "one", "");
1766 MsiSetPropertyA(hpkg
, "two", "there");
1767 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1768 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1770 MsiSetPropertyA(hpkg
, "one", "there");
1771 MsiSetPropertyA(hpkg
, "two", "");
1772 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1773 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1775 MsiSetPropertyA(hpkg
, "one", "");
1776 MsiSetPropertyA(hpkg
, "two", "");
1777 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1778 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1780 MsiSetPropertyA(hpkg
, "one", "1234");
1781 MsiSetPropertyA(hpkg
, "two", "4");
1782 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1783 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1785 MsiSetPropertyA(hpkg
, "one", "one 1234");
1786 MsiSetPropertyA(hpkg
, "two", "4");
1787 r
= MsiEvaluateConditionA(hpkg
, "one >> two");
1788 ok( r
== MSICONDITION_TRUE
, "wrong return val\n");
1790 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", NULL
); /* make sure it's empty */
1792 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1793 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1795 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport > \"1.1.4322\"");
1796 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1798 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport >= \"1.1.4322\"");
1799 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1801 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <= \"1.1.4322\"");
1802 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1804 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport <> \"1.1.4322\"");
1805 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1807 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1808 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1810 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"abcd\"");
1811 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1813 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a1.1.4322\"");
1814 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1816 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322a\"");
1817 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1819 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1820 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1822 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1823 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1825 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1826 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1828 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1");
1829 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1831 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"1.1\"");
1832 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1834 r
= MsiEvaluateConditionA(hpkg
, "\"2\" < \"12.1\"");
1835 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1837 r
= MsiEvaluateConditionA(hpkg
, "\"02.1\" < \"2.11\"");
1838 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1840 r
= MsiEvaluateConditionA(hpkg
, "\"02.1.1\" < \"2.1\"");
1841 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1843 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1844 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1846 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
1847 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1849 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"0\"");
1850 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1852 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"-1\"");
1853 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1855 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a\"");
1856 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1858 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1859 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1861 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"!\"");
1862 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1864 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"/\"");
1865 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1867 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \" \"");
1868 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1870 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"azAZ_\"");
1871 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1873 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]\"");
1874 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1876 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a[a]a\"");
1877 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1879 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]\"");
1880 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1882 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a]a\"");
1883 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1885 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a}\"");
1886 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1888 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"{a\"");
1889 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1891 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"[a\"");
1892 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1894 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a{\"");
1895 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1897 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"a]\"");
1898 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1900 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"A\"");
1901 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1903 MsiSetPropertyA(hpkg
, "MsiNetAssemblySupport", "1.1.4322");
1904 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.4322\"");
1905 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1907 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.14322\"");
1908 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1910 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1.5\"");
1911 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1913 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1.1\"");
1914 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1916 r
= MsiEvaluateConditionA(hpkg
, "MsiNetAssemblySupport < \"1\"");
1917 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1919 MsiSetPropertyA(hpkg
, "one", "1");
1920 r
= MsiEvaluateConditionA(hpkg
, "one < \"1\"");
1921 ok( r
== MSICONDITION_FALSE
, "wrong return val\n");
1923 MsiSetPropertyA(hpkg
, "X", "5.0");
1925 r
= MsiEvaluateConditionA(hpkg
, "X != \"\"");
1926 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1928 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\"");
1929 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1931 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.1\"");
1932 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1934 r
= MsiEvaluateConditionA(hpkg
, "X =\"6.0\"");
1935 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1937 r
= MsiEvaluateConditionA(hpkg
, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1938 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1940 r
= MsiEvaluateConditionA(hpkg
, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1941 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1943 r
= MsiEvaluateConditionA(hpkg
, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1944 ok( r
== MSICONDITION_ERROR
, "wrong return val (%d)\n", r
);
1946 /* feature doesn't exist */
1947 r
= MsiEvaluateConditionA(hpkg
, "&nofeature");
1948 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1950 MsiSetPropertyA(hpkg
, "A", "2");
1951 MsiSetPropertyA(hpkg
, "X", "50");
1953 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
1954 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1956 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1957 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1959 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
1960 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1962 MsiSetPropertyA(hpkg
, "X", "50val");
1964 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
1965 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1967 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1968 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1970 MsiSetPropertyA(hpkg
, "A", "7");
1971 MsiSetPropertyA(hpkg
, "X", "50");
1973 r
= MsiEvaluateConditionA(hpkg
, "7 <= X");
1974 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1976 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1977 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1979 r
= MsiEvaluateConditionA(hpkg
, "A <= 50");
1980 ok( r
== MSICONDITION_TRUE
, "wrong return val (%d)\n", r
);
1982 MsiSetPropertyA(hpkg
, "X", "50val");
1984 r
= MsiEvaluateConditionA(hpkg
, "2 <= X");
1985 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1987 r
= MsiEvaluateConditionA(hpkg
, "A <= X");
1988 ok( r
== MSICONDITION_FALSE
, "wrong return val (%d)\n", r
);
1990 r
= MsiEvaluateConditionW(hpkg
, cond1
);
1991 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
1992 "wrong return val (%d)\n", r
);
1994 r
= MsiEvaluateConditionW(hpkg
, cond2
);
1995 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
1996 "wrong return val (%d)\n", r
);
1998 r
= MsiEvaluateConditionW(hpkg
, cond3
);
1999 ok( r
== MSICONDITION_TRUE
|| broken(r
== MSICONDITION_FALSE
),
2000 "wrong return val (%d)\n", r
);
2002 r
= MsiEvaluateConditionW(hpkg
, cond4
);
2003 ok( r
== MSICONDITION_FALSE
|| broken(r
== MSICONDITION_TRUE
),
2004 "wrong return val (%d)\n", r
);
2006 MsiCloseHandle( hpkg
);
2007 DeleteFileA(msifile
);
2010 static BOOL
check_prop_empty( MSIHANDLE hpkg
, const char * prop
)
2018 r
= MsiGetPropertyA( hpkg
, prop
, buffer
, &sz
);
2019 return r
== ERROR_SUCCESS
&& buffer
[0] == 0 && sz
== 0;
2022 static void test_props(void)
2024 MSIHANDLE hpkg
, hdb
;
2029 hdb
= create_package_db();
2031 "CREATE TABLE `Property` ( "
2032 "`Property` CHAR(255) NOT NULL, "
2033 "`Value` CHAR(255) "
2034 "PRIMARY KEY `Property`)" );
2035 ok( r
== ERROR_SUCCESS
, "Failed\n" );
2038 "INSERT INTO `Property` "
2039 "(`Property`, `Value`) "
2040 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
2041 ok( r
== ERROR_SUCCESS
, "Failed\n" );
2043 r
= package_from_db( hdb
, &hpkg
);
2044 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2046 skip("Not enough rights to perform tests\n");
2047 DeleteFileA(msifile
);
2050 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2052 /* test invalid values */
2053 r
= MsiGetPropertyA( 0, NULL
, NULL
, NULL
);
2054 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2056 r
= MsiGetPropertyA( hpkg
, NULL
, NULL
, NULL
);
2057 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2059 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, NULL
);
2060 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2062 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, NULL
);
2063 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2065 /* test retrieving an empty/nonexistent property */
2067 r
= MsiGetPropertyA( hpkg
, "boo", NULL
, &sz
);
2068 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2069 ok( sz
== 0, "wrong size returned\n");
2071 check_prop_empty( hpkg
, "boo");
2074 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2075 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2076 ok( !strcmp(buffer
,"x"), "buffer was changed\n");
2077 ok( sz
== 0, "wrong size returned\n");
2081 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2082 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2083 ok( buffer
[0] == 0, "buffer was not changed\n");
2084 ok( sz
== 0, "wrong size returned\n");
2086 /* set the property to something */
2087 r
= MsiSetPropertyA( 0, NULL
, NULL
);
2088 ok( r
== ERROR_INVALID_HANDLE
, "wrong return val\n");
2090 r
= MsiSetPropertyA( hpkg
, NULL
, NULL
);
2091 ok( r
== ERROR_INVALID_PARAMETER
, "wrong return val\n");
2093 r
= MsiSetPropertyA( hpkg
, "", NULL
);
2094 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2096 /* try set and get some illegal property identifiers */
2097 r
= MsiSetPropertyA( hpkg
, "", "asdf" );
2098 ok( r
== ERROR_FUNCTION_FAILED
, "wrong return val\n");
2100 r
= MsiSetPropertyA( hpkg
, "=", "asdf" );
2101 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2103 r
= MsiSetPropertyA( hpkg
, " ", "asdf" );
2104 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2106 r
= MsiSetPropertyA( hpkg
, "'", "asdf" );
2107 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2111 r
= MsiGetPropertyA( hpkg
, "'", buffer
, &sz
);
2112 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2113 ok( !strcmp(buffer
,"asdf"), "buffer was not changed\n");
2115 /* set empty values */
2116 r
= MsiSetPropertyA( hpkg
, "boo", NULL
);
2117 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2118 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2120 r
= MsiSetPropertyA( hpkg
, "boo", "" );
2121 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2122 ok( check_prop_empty( hpkg
, "boo"), "prop wasn't empty\n");
2124 /* set a non-empty value */
2125 r
= MsiSetPropertyA( hpkg
, "boo", "xyz" );
2126 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2130 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2131 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2132 ok( buffer
[0] == 0, "buffer was not changed\n");
2133 ok( sz
== 3, "wrong size returned\n");
2137 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2138 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2139 ok( !strcmp(buffer
,"xyz"), "buffer was not changed\n");
2140 ok( sz
== 3, "wrong size returned\n");
2144 r
= MsiGetPropertyA( hpkg
, "boo", buffer
, &sz
);
2145 ok( r
== ERROR_MORE_DATA
, "wrong return val\n");
2146 ok( !strcmp(buffer
,"xy"), "buffer was not changed\n");
2147 ok( sz
== 3, "wrong size returned\n");
2149 r
= MsiSetPropertyA(hpkg
, "SourceDir", "foo");
2150 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2153 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", buffer
, &sz
);
2154 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2155 ok( !strcmp(buffer
,""), "buffer wrong\n");
2156 ok( sz
== 0, "wrong size returned\n");
2159 r
= MsiGetPropertyA(hpkg
, "SOMERANDOMNAME", buffer
, &sz
);
2160 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2161 ok( !strcmp(buffer
,""), "buffer wrong\n");
2162 ok( sz
== 0, "wrong size returned\n");
2165 r
= MsiGetPropertyA(hpkg
, "SourceDir", buffer
, &sz
);
2166 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2167 ok( !strcmp(buffer
,"foo"), "buffer wrong\n");
2168 ok( sz
== 3, "wrong size returned\n");
2170 r
= MsiSetPropertyA(hpkg
, "MetadataCompName", "Photoshop.dll");
2171 ok( r
== ERROR_SUCCESS
, "wrong return val\n");
2174 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", NULL
, &sz
);
2175 ok( r
== ERROR_SUCCESS
, "return wrong\n");
2176 ok( sz
== 13, "size wrong (%d)\n", sz
);
2179 r
= MsiGetPropertyA(hpkg
, "MetadataCompName", buffer
, &sz
);
2180 ok( r
== ERROR_MORE_DATA
, "return wrong\n");
2181 ok( !strcmp(buffer
,"Photoshop.dl"), "buffer wrong\n");
2183 r
= MsiSetPropertyA(hpkg
, "property", "value");
2184 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2187 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2188 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2189 ok( !strcmp(buffer
, "value"), "Expected value, got %s\n", buffer
);
2191 r
= MsiSetPropertyA(hpkg
, "property", NULL
);
2192 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2195 r
= MsiGetPropertyA(hpkg
, "property", buffer
, &sz
);
2196 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2197 ok(!buffer
[0], "Expected empty string, got %s\n", buffer
);
2199 MsiCloseHandle( hpkg
);
2200 DeleteFileA(msifile
);
2203 static BOOL
find_prop_in_property(MSIHANDLE hdb
, LPCSTR prop
, LPCSTR val
, int len
)
2205 MSIHANDLE hview
, hrec
;
2207 CHAR buffer
[MAX_PATH
];
2211 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
2212 ok(r
== ERROR_SUCCESS
, "MsiDatabaseOpenView failed\n");
2213 r
= MsiViewExecute(hview
, 0);
2214 ok(r
== ERROR_SUCCESS
, "MsiViewExecute failed\n");
2216 if (len
< 0) len
= lstrlenA(val
);
2218 while (r
== ERROR_SUCCESS
&& !found
)
2220 r
= MsiViewFetch(hview
, &hrec
);
2221 if (r
!= ERROR_SUCCESS
) break;
2224 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &sz
);
2225 if (r
== ERROR_SUCCESS
&& !lstrcmpA(buffer
, prop
))
2228 r
= MsiRecordGetStringA(hrec
, 2, buffer
, &sz
);
2229 if (r
== ERROR_SUCCESS
&& !memcmp(buffer
, val
, len
) && !buffer
[len
])
2231 ok(sz
== len
, "wrong size %u\n", sz
);
2236 MsiCloseHandle(hrec
);
2238 MsiViewClose(hview
);
2239 MsiCloseHandle(hview
);
2243 static void test_property_table(void)
2247 MSIHANDLE hpkg
, hdb
, hrec
;
2248 char buffer
[MAX_PATH
], package
[10];
2252 hdb
= create_package_db();
2253 ok( hdb
, "failed to create package\n");
2255 r
= package_from_db(hdb
, &hpkg
);
2256 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2258 skip("Not enough rights to perform tests\n");
2259 DeleteFileA(msifile
);
2262 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2264 MsiCloseHandle(hdb
);
2266 hdb
= MsiGetActiveDatabase(hpkg
);
2268 query
= "CREATE TABLE `_Property` ( "
2269 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2270 r
= run_query(hdb
, query
);
2271 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2273 MsiCloseHandle(hdb
);
2274 MsiCloseHandle(hpkg
);
2275 DeleteFileA(msifile
);
2277 hdb
= create_package_db();
2278 ok( hdb
, "failed to create package\n");
2280 query
= "CREATE TABLE `_Property` ( "
2281 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2282 r
= run_query(hdb
, query
);
2283 ok(r
== ERROR_SUCCESS
, "failed to create table\n");
2285 query
= "ALTER `_Property` ADD `foo` INTEGER";
2286 r
= run_query(hdb
, query
);
2287 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2289 query
= "ALTER TABLE `_Property` ADD `foo` INTEGER";
2290 r
= run_query(hdb
, query
);
2291 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "failed to add column\n");
2293 query
= "ALTER TABLE `_Property` ADD `extra` INTEGER";
2294 r
= run_query(hdb
, query
);
2295 ok(r
== ERROR_SUCCESS
, "failed to add column\n");
2297 sprintf(package
, "#%i", hdb
);
2298 r
= MsiOpenPackageA(package
, &hpkg
);
2299 ok(r
!= ERROR_SUCCESS
, "MsiOpenPackage succeeded\n");
2300 if (r
== ERROR_SUCCESS
)
2301 MsiCloseHandle(hpkg
);
2303 r
= MsiCloseHandle(hdb
);
2304 ok(r
== ERROR_SUCCESS
, "MsiCloseHandle failed %u\n", r
);
2306 hdb
= create_package_db();
2307 ok (hdb
, "failed to create package database\n");
2309 r
= create_property_table(hdb
);
2310 ok(r
== ERROR_SUCCESS
, "cannot create Property table: %d\n", r
);
2312 r
= add_property_entry(hdb
, "'prop', 'val'");
2313 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
2315 r
= create_custom_action_table(hdb
);
2316 ok(r
== ERROR_SUCCESS
, "cannot create CustomAction table: %d\n", r
);
2318 r
= add_custom_action_entry( hdb
, "'EmbedNull', 51, 'prop2', '[~]np'" );
2319 ok( r
== ERROR_SUCCESS
, "cannot add custom action: %d\n", r
);
2321 r
= package_from_db(hdb
, &hpkg
);
2322 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2324 MsiCloseHandle(hdb
);
2327 r
= MsiGetPropertyA(hpkg
, "prop", buffer
, &sz
);
2328 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2329 ok(!lstrcmpA(buffer
, "val"), "Expected val, got %s\n", buffer
);
2331 hdb
= MsiGetActiveDatabase(hpkg
);
2333 found
= find_prop_in_property(hdb
, "prop", "val", -1);
2334 ok(found
, "prop should be in the _Property table\n");
2336 r
= add_property_entry(hdb
, "'dantes', 'mercedes'");
2337 ok(r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
2339 query
= "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2340 r
= do_query(hdb
, query
, &hrec
);
2341 ok(r
== ERROR_BAD_QUERY_SYNTAX
, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
2343 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2344 ok(found
== FALSE
, "dantes should not be in the _Property table\n");
2347 lstrcpyA(buffer
, "aaa");
2348 r
= MsiGetPropertyA(hpkg
, "dantes", buffer
, &sz
);
2349 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2350 ok(!buffer
[0], "Expected empty string, got %s\n", buffer
);
2352 r
= MsiSetPropertyA(hpkg
, "dantes", "mercedes");
2353 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2355 found
= find_prop_in_property(hdb
, "dantes", "mercedes", -1);
2356 ok(found
== TRUE
, "dantes should be in the _Property table\n");
2358 r
= MsiDoActionA( hpkg
, "EmbedNull" );
2359 ok( r
== ERROR_SUCCESS
, "EmbedNull failed: %d\n", r
);
2362 memset( buffer
, 'a', sizeof(buffer
) );
2363 r
= MsiGetPropertyA( hpkg
, "prop2", buffer
, &sz
);
2364 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
2365 ok( !memcmp( buffer
, "\0np", sizeof("\0np") ), "wrong value\n");
2366 ok( sz
== sizeof("\0np") - 1, "got %u\n", sz
);
2368 found
= find_prop_in_property(hdb
, "prop2", "\0np", 3);
2369 ok(found
== TRUE
, "prop2 should be in the _Property table\n");
2371 MsiCloseHandle(hdb
);
2372 MsiCloseHandle(hpkg
);
2373 DeleteFileA(msifile
);
2376 static UINT
try_query_param( MSIHANDLE hdb
, LPCSTR szQuery
, MSIHANDLE hrec
)
2381 res
= MsiDatabaseOpenViewA( hdb
, szQuery
, &htab
);
2382 if( res
== ERROR_SUCCESS
)
2386 r
= MsiViewExecute( htab
, hrec
);
2387 if( r
!= ERROR_SUCCESS
)
2390 fprintf(stderr
,"MsiViewExecute failed %08x\n", res
);
2393 r
= MsiViewClose( htab
);
2394 if( r
!= ERROR_SUCCESS
)
2397 r
= MsiCloseHandle( htab
);
2398 if( r
!= ERROR_SUCCESS
)
2404 static UINT
try_query( MSIHANDLE hdb
, LPCSTR szQuery
)
2406 return try_query_param( hdb
, szQuery
, 0 );
2409 static void set_summary_str(MSIHANDLE hdb
, DWORD pid
, LPCSTR value
)
2414 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2415 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2417 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_LPSTR
, 0, NULL
, value
);
2418 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2420 r
= MsiSummaryInfoPersist(summary
);
2421 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2423 MsiCloseHandle(summary
);
2426 static void set_summary_dword(MSIHANDLE hdb
, DWORD pid
, DWORD value
)
2431 r
= MsiGetSummaryInformationA(hdb
, NULL
, 1, &summary
);
2432 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2434 r
= MsiSummaryInfoSetPropertyA(summary
, pid
, VT_I4
, value
, NULL
, NULL
);
2435 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2437 r
= MsiSummaryInfoPersist(summary
);
2438 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
2440 MsiCloseHandle(summary
);
2443 static void test_msipackage(void)
2445 MSIHANDLE hdb
= 0, hpack
= 100;
2450 /* NULL szPackagePath */
2451 r
= MsiOpenPackageA(NULL
, &hpack
);
2452 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2454 /* empty szPackagePath */
2455 r
= MsiOpenPackageA("", &hpack
);
2456 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2458 skip("Not enough rights to perform tests\n");
2463 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2466 if (r
== ERROR_SUCCESS
)
2467 MsiCloseHandle(hpack
);
2469 /* nonexistent szPackagePath */
2470 r
= MsiOpenPackageA("nonexistent", &hpack
);
2471 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
2474 r
= MsiOpenPackageA(msifile
, NULL
);
2475 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2479 r
= MsiOpenPackageA(name
, &hpack
);
2480 ok(r
== ERROR_INVALID_HANDLE
, "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
2482 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2483 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2485 /* database exists, but is empty */
2486 sprintf(name
, "#%d", hdb
);
2487 r
= MsiOpenPackageA(name
, &hpack
);
2488 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2489 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2491 query
= "CREATE TABLE `Property` ( "
2492 "`Property` CHAR(72), `Value` CHAR(0) "
2493 "PRIMARY KEY `Property`)";
2494 r
= try_query(hdb
, query
);
2495 ok(r
== ERROR_SUCCESS
, "failed to create Properties table\n");
2497 query
= "CREATE TABLE `InstallExecuteSequence` ("
2498 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2499 "PRIMARY KEY `Action`)";
2500 r
= try_query(hdb
, query
);
2501 ok(r
== ERROR_SUCCESS
, "failed to create InstallExecuteSequence table\n");
2503 /* a few key tables exist */
2504 sprintf(name
, "#%d", hdb
);
2505 r
= MsiOpenPackageA(name
, &hpack
);
2506 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2507 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2509 MsiCloseHandle(hdb
);
2510 DeleteFileA(msifile
);
2512 /* start with a clean database to show what constitutes a valid package */
2513 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
2514 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2516 sprintf(name
, "#%d", hdb
);
2518 /* The following summary information props must exist:
2523 set_summary_dword(hdb
, PID_PAGECOUNT
, 100);
2524 r
= MsiOpenPackageA(name
, &hpack
);
2525 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
2526 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
2528 set_summary_str(hdb
, PID_REVNUMBER
, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2529 r
= MsiOpenPackageA(name
, &hpack
);
2530 ok(r
== ERROR_SUCCESS
,
2531 "Expected ERROR_SUCCESS, got %d\n", r
);
2533 MsiCloseHandle(hpack
);
2534 MsiCloseHandle(hdb
);
2535 DeleteFileA(msifile
);
2538 static void test_formatrecord2(void)
2540 MSIHANDLE hpkg
, hrec
;
2545 r
= package_from_db(create_package_db(), &hpkg
);
2546 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
2548 skip("Not enough rights to perform tests\n");
2549 DeleteFileA(msifile
);
2552 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
2554 r
= MsiSetPropertyA(hpkg
, "Manufacturer", " " );
2555 ok( r
== ERROR_SUCCESS
, "set property failed\n");
2557 hrec
= MsiCreateRecord(2);
2558 ok(hrec
, "create record failed\n");
2560 r
= MsiRecordSetStringA( hrec
, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2561 ok( r
== ERROR_SUCCESS
, "format record failed\n");
2565 r
= MsiFormatRecordA( hpkg
, hrec
, buffer
, &sz
);
2566 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2568 r
= MsiRecordSetStringA(hrec
, 0, "[foo][1]");
2569 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2570 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2571 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2573 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2574 ok( sz
== 3, "size wrong\n");
2575 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2576 ok( r
== ERROR_SUCCESS
, "format failed\n");
2578 r
= MsiRecordSetStringA(hrec
, 0, "x[~]x");
2579 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2581 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2582 ok( sz
== 3, "size wrong\n");
2583 ok( 0 == strcmp(buffer
,"x"), "wrong output %s\n",buffer
);
2584 ok( r
== ERROR_SUCCESS
, "format failed\n");
2586 r
= MsiRecordSetStringA(hrec
, 0, "[foo.$%}][1]");
2587 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2588 r
= MsiRecordSetStringA(hrec
, 1, "hoo");
2589 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2591 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2592 ok( sz
== 3, "size wrong\n");
2593 ok( 0 == strcmp(buffer
,"hoo"), "wrong output %s\n",buffer
);
2594 ok( r
== ERROR_SUCCESS
, "format failed\n");
2596 r
= MsiRecordSetStringA(hrec
, 0, "[\\[]");
2597 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2599 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2600 ok( sz
== 1, "size wrong\n");
2601 ok( 0 == strcmp(buffer
,"["), "wrong output %s\n",buffer
);
2602 ok( r
== ERROR_SUCCESS
, "format failed\n");
2604 SetEnvironmentVariableA("FOO", "BAR");
2605 r
= MsiRecordSetStringA(hrec
, 0, "[%FOO]");
2606 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2608 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2609 ok( sz
== 3, "size wrong\n");
2610 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2611 ok( r
== ERROR_SUCCESS
, "format failed\n");
2613 r
= MsiRecordSetStringA(hrec
, 0, "[[1]]");
2614 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2615 r
= MsiRecordSetStringA(hrec
, 1, "%FOO");
2616 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
2618 r
= MsiFormatRecordA(hpkg
, hrec
, buffer
, &sz
);
2619 ok( sz
== 3, "size wrong\n");
2620 ok( 0 == strcmp(buffer
,"BAR"), "wrong output %s\n",buffer
);
2621 ok( r
== ERROR_SUCCESS
, "format failed\n");
2623 MsiCloseHandle( hrec
);
2624 MsiCloseHandle( hpkg
);
2625 DeleteFileA(msifile
);
2628 static void test_feature_states( UINT line
, MSIHANDLE package
, const char *feature
, UINT error
,
2629 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
2632 INSTALLSTATE state
= 0xdeadbee;
2633 INSTALLSTATE action
= 0xdeadbee;
2635 r
= MsiGetFeatureStateA( package
, feature
, &state
, &action
);
2636 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
2637 if (r
== ERROR_SUCCESS
)
2639 ok( state
== expected_state
, "%u: expected state %d got %d\n",
2640 line
, expected_state
, state
);
2642 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2643 line
, expected_action
, action
);
2647 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line
, state
);
2649 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line
, action
);
2654 static void test_component_states( UINT line
, MSIHANDLE package
, const char *component
, UINT error
,
2655 INSTALLSTATE expected_state
, INSTALLSTATE expected_action
, BOOL todo
)
2658 INSTALLSTATE state
= 0xdeadbee;
2659 INSTALLSTATE action
= 0xdeadbee;
2661 r
= MsiGetComponentStateA( package
, component
, &state
, &action
);
2662 ok( r
== error
, "%u: expected %d got %d\n", line
, error
, r
);
2663 if (r
== ERROR_SUCCESS
)
2665 ok( state
== expected_state
, "%u: expected state %d got %d\n",
2666 line
, expected_state
, state
);
2668 ok( action
== expected_action
, "%u: expected action %d got %d\n",
2669 line
, expected_action
, action
);
2673 ok( state
== 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2676 ok( action
== 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2681 static void test_states(void)
2683 static const char msifile2
[] = "winetest2-package.msi";
2684 static const char msifile3
[] = "winetest3-package.msi";
2685 static const char msifile4
[] = "winetest4-package.msi";
2686 static const WCHAR msifile2W
[] =
2687 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
2688 static const WCHAR msifile3W
[] =
2689 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
2690 static const WCHAR msifile4W
[] =
2691 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
2697 if (is_process_limited())
2699 skip("process is limited\n");
2703 hdb
= create_package_db();
2704 ok ( hdb
, "failed to create package database\n" );
2706 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
2707 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
2709 r
= create_property_table( hdb
);
2710 ok( r
== ERROR_SUCCESS
, "cannot create Property table: %d\n", r
);
2712 r
= add_property_entry( hdb
, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2713 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2715 r
= add_property_entry( hdb
, "'ProductLanguage', '1033'" );
2716 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2718 r
= add_property_entry( hdb
, "'ProductName', 'MSITEST'" );
2719 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2721 r
= add_property_entry( hdb
, "'ProductVersion', '1.1.1'" );
2722 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2724 r
= add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
2725 ok( r
== ERROR_SUCCESS
, "cannot add property entry: %d\n", r
);
2727 r
= create_install_execute_sequence_table( hdb
);
2728 ok( r
== ERROR_SUCCESS
, "cannot create InstallExecuteSequence table: %d\n", r
);
2730 r
= add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
2731 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2733 r
= add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
2734 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2736 r
= add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
2737 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2739 r
= add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1400'" );
2740 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2742 r
= add_install_execute_sequence_entry( hdb
, "'InstallInitialize', '', '1500'" );
2743 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2745 r
= add_install_execute_sequence_entry( hdb
, "'ProcessComponents', '', '1600'" );
2746 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2748 r
= add_install_execute_sequence_entry( hdb
, "'UnpublishFeatures', '', '1800'" );
2749 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2751 r
= add_install_execute_sequence_entry( hdb
, "'RegisterProduct', '', '6100'" );
2752 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2754 r
= add_install_execute_sequence_entry( hdb
, "'PublishFeatures', '', '6300'" );
2755 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2757 r
= add_install_execute_sequence_entry( hdb
, "'PublishProduct', '', '6400'" );
2758 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2760 r
= add_install_execute_sequence_entry( hdb
, "'InstallFinalize', '', '6600'" );
2761 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry: %d\n", r
);
2763 r
= create_media_table( hdb
);
2764 ok( r
== ERROR_SUCCESS
, "cannot create media table: %d\n", r
);
2766 r
= add_media_entry( hdb
, "'1', '3', '', '', 'DISK1', ''");
2767 ok( r
== ERROR_SUCCESS
, "cannot add media entry: %d\n", r
);
2769 r
= create_feature_table( hdb
);
2770 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
2772 r
= create_component_table( hdb
);
2773 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
2775 /* msidbFeatureAttributesFavorLocal */
2776 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
2777 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2779 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2780 r
= add_component_entry( hdb
, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2781 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2783 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2784 r
= add_component_entry( hdb
, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2785 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2787 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2788 r
= add_component_entry( hdb
, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2789 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2791 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2792 r
= add_component_entry( hdb
, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2793 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2795 /* msidbFeatureAttributesFavorSource */
2796 r
= add_feature_entry( hdb
, "'two', '', '', '', 2, 1, '', 1" );
2797 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2799 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2800 r
= add_component_entry( hdb
, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2801 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2803 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2804 r
= add_component_entry( hdb
, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2805 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2807 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2808 r
= add_component_entry( hdb
, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2809 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2811 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2812 r
= add_component_entry( hdb
, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2813 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2815 /* msidbFeatureAttributesFavorSource */
2816 r
= add_feature_entry( hdb
, "'three', '', '', '', 2, 1, '', 1" );
2817 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2819 /* msidbFeatureAttributesFavorLocal */
2820 r
= add_feature_entry( hdb
, "'four', '', '', '', 2, 1, '', 0" );
2821 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2824 r
= add_feature_entry( hdb
, "'five', '', '', '', 2, 0, '', 1" );
2825 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2827 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2828 r
= add_component_entry( hdb
, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2829 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2831 /* no feature parent:msidbComponentAttributesLocalOnly */
2832 r
= add_component_entry( hdb
, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2833 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2835 /* msidbFeatureAttributesFavorLocal:removed */
2836 r
= add_feature_entry( hdb
, "'six', '', '', '', 2, 1, '', 0" );
2837 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2839 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2840 r
= add_component_entry( hdb
, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2841 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2843 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2844 r
= add_component_entry( hdb
, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2845 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2847 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2848 r
= add_component_entry( hdb
, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2849 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2851 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2852 r
= add_component_entry( hdb
, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2853 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2855 /* msidbFeatureAttributesFavorSource:removed */
2856 r
= add_feature_entry( hdb
, "'seven', '', '', '', 2, 1, '', 1" );
2857 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2859 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2860 r
= add_component_entry( hdb
, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2861 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2863 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2864 r
= add_component_entry( hdb
, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2865 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2867 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2868 r
= add_component_entry( hdb
, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2869 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2871 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2872 r
= add_component_entry( hdb
, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2873 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2875 /* msidbFeatureAttributesFavorLocal */
2876 r
= add_feature_entry( hdb
, "'eight', '', '', '', 2, 1, '', 0" );
2877 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2879 r
= add_component_entry( hdb
, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2880 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2882 /* msidbFeatureAttributesFavorSource */
2883 r
= add_feature_entry( hdb
, "'nine', '', '', '', 2, 1, '', 1" );
2884 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2886 r
= add_component_entry( hdb
, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2887 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2889 /* msidbFeatureAttributesFavorAdvertise */
2890 r
= add_feature_entry( hdb
, "'ten', '', '', '', 2, 1, '', 4" );
2891 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2893 r
= add_component_entry( hdb
, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2894 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2896 /* msidbFeatureAttributesUIDisallowAbsent */
2897 r
= add_feature_entry( hdb
, "'eleven', '', '', '', 2, 1, '', 16" );
2898 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2900 r
= add_component_entry( hdb
, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2901 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2903 /* high install level */
2904 r
= add_feature_entry( hdb
, "'twelve', '', '', '', 2, 2, '', 0" );
2905 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2907 r
= add_component_entry( hdb
, "'upsilon', '{557e0c04-ceba-4c58-86a9-4a73352e8cf6}', 'TARGETDIR', 1, '', 'upsilon_file'" );
2908 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
2910 /* msidbFeatureAttributesFollowParent */
2911 r
= add_feature_entry( hdb
, "'thirteen', '', '', '', 2, 2, '', 2" );
2912 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
2914 r
= create_feature_components_table( hdb
);
2915 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
2917 r
= add_feature_components_entry( hdb
, "'one', 'alpha'" );
2918 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2920 r
= add_feature_components_entry( hdb
, "'one', 'beta'" );
2921 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2923 r
= add_feature_components_entry( hdb
, "'one', 'gamma'" );
2924 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2926 r
= add_feature_components_entry( hdb
, "'one', 'theta'" );
2927 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2929 r
= add_feature_components_entry( hdb
, "'two', 'delta'" );
2930 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2932 r
= add_feature_components_entry( hdb
, "'two', 'epsilon'" );
2933 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2935 r
= add_feature_components_entry( hdb
, "'two', 'zeta'" );
2936 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2938 r
= add_feature_components_entry( hdb
, "'two', 'iota'" );
2939 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2941 r
= add_feature_components_entry( hdb
, "'three', 'eta'" );
2942 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2944 r
= add_feature_components_entry( hdb
, "'four', 'eta'" );
2945 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2947 r
= add_feature_components_entry( hdb
, "'five', 'eta'" );
2948 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2950 r
= add_feature_components_entry( hdb
, "'six', 'lambda'" );
2951 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2953 r
= add_feature_components_entry( hdb
, "'six', 'mu'" );
2954 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2956 r
= add_feature_components_entry( hdb
, "'six', 'nu'" );
2957 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2959 r
= add_feature_components_entry( hdb
, "'six', 'xi'" );
2960 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2962 r
= add_feature_components_entry( hdb
, "'seven', 'omicron'" );
2963 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2965 r
= add_feature_components_entry( hdb
, "'seven', 'pi'" );
2966 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2968 r
= add_feature_components_entry( hdb
, "'seven', 'rho'" );
2969 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2971 r
= add_feature_components_entry( hdb
, "'seven', 'sigma'" );
2972 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2974 r
= add_feature_components_entry( hdb
, "'eight', 'tau'" );
2975 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2977 r
= add_feature_components_entry( hdb
, "'nine', 'phi'" );
2978 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2980 r
= add_feature_components_entry( hdb
, "'ten', 'chi'" );
2981 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2983 r
= add_feature_components_entry( hdb
, "'eleven', 'psi'" );
2984 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2986 r
= add_feature_components_entry( hdb
, "'twelve', 'upsilon'" );
2987 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2989 r
= add_feature_components_entry( hdb
, "'thirteen', 'upsilon'" );
2990 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
2992 r
= create_file_table( hdb
);
2993 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
2995 r
= add_file_entry( hdb
, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2996 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
2998 r
= add_file_entry( hdb
, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2999 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3001 r
= add_file_entry( hdb
, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
3002 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3004 r
= add_file_entry( hdb
, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
3005 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3007 r
= add_file_entry( hdb
, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
3008 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3010 r
= add_file_entry( hdb
, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
3011 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3013 r
= add_file_entry( hdb
, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
3014 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3016 r
= add_file_entry( hdb
, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
3017 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3019 /* compressed file */
3020 r
= add_file_entry( hdb
, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3021 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3023 r
= add_file_entry( hdb
, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3024 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3026 r
= add_file_entry( hdb
, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3027 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3029 r
= add_file_entry( hdb
, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3030 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3032 r
= add_file_entry( hdb
, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3033 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3035 r
= add_file_entry( hdb
, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3036 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3038 r
= add_file_entry( hdb
, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3039 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3041 r
= add_file_entry( hdb
, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3042 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3044 r
= add_file_entry( hdb
, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3045 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3047 r
= add_file_entry( hdb
, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3048 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3050 r
= add_file_entry( hdb
, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3051 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3053 r
= add_file_entry( hdb
, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3054 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3056 r
= add_file_entry( hdb
, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3057 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3059 r
= add_file_entry( hdb
, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3060 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3062 r
= add_file_entry( hdb
, "'upsilon_file', 'upsilon', 'upsilon.txt', 0, '', '1033', 16384, 1" );
3063 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3065 MsiDatabaseCommit(hdb
);
3067 /* these properties must not be in the saved msi file */
3068 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3069 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3071 r
= add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3072 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3074 r
= add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3075 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3077 r
= add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3078 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3080 r
= add_property_entry( hdb
, "'REINSTALLMODE', 'omus'");
3081 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3083 r
= package_from_db( hdb
, &hpkg
);
3084 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3086 skip("Not enough rights to perform tests\n");
3087 DeleteFileA(msifile
);
3090 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3092 MsiCloseHandle(hdb
);
3094 CopyFileA(msifile
, msifile2
, FALSE
);
3095 CopyFileA(msifile
, msifile3
, FALSE
);
3096 CopyFileA(msifile
, msifile4
, FALSE
);
3098 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3099 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3101 r
= MsiDoActionA( hpkg
, "CostInitialize");
3102 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3104 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3105 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3107 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3109 r
= MsiDoActionA( hpkg
, "FileCost");
3110 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3112 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3113 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3115 r
= MsiDoActionA( hpkg
, "CostFinalize");
3116 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3118 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3119 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3120 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3121 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3122 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3123 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3124 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3125 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3126 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3127 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3128 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3129 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3130 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3132 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3133 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3134 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3135 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3136 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3137 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3138 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
3139 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3140 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
3141 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3142 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3143 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3144 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3145 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3146 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3147 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3148 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3149 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3150 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3151 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3152 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3153 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3154 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3156 MsiCloseHandle( hpkg
);
3158 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3160 /* publish the features and components */
3161 r
= MsiInstallProductA(msifile
, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3162 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3164 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
3165 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3167 /* these properties must not be in the saved msi file */
3168 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,four'");
3169 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3171 r
= add_property_entry( hdb
, "'ADDSOURCE', 'two,three'");
3172 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3174 r
= add_property_entry( hdb
, "'REMOVE', 'six,seven'");
3175 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3177 r
= add_property_entry( hdb
, "'REINSTALL', 'eight,nine,ten'");
3178 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3180 r
= package_from_db( hdb
, &hpkg
);
3181 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3183 MsiCloseHandle(hdb
);
3185 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3186 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3188 r
= MsiDoActionA( hpkg
, "CostInitialize");
3189 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3191 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3192 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3194 r
= MsiDoActionA( hpkg
, "FileCost");
3195 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3197 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3198 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3200 r
= MsiDoActionA( hpkg
, "CostFinalize");
3201 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3203 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3204 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3205 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3206 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3207 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3208 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3209 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3210 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3211 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3212 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3213 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3214 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3215 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3217 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3218 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3219 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3220 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3221 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3222 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3223 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3224 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3225 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3226 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3227 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3228 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3229 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3230 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3231 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3232 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3233 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3234 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3235 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3236 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3237 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3238 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3239 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3241 MsiCloseHandle(hpkg
);
3243 /* uninstall the product */
3244 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
3245 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3247 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3248 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3249 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3250 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3252 /* all features installed locally */
3253 r
= MsiInstallProductA(msifile2
, "ADDLOCAL=ALL");
3254 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3256 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3257 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3258 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3259 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3261 r
= MsiOpenDatabaseW(msifile2W
, MSIDBOPEN_DIRECT
, &hdb
);
3262 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3264 /* these properties must not be in the saved msi file */
3265 r
= add_property_entry( hdb
, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten,twelve'");
3266 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3268 r
= package_from_db( hdb
, &hpkg
);
3269 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3271 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3272 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3274 r
= MsiDoActionA( hpkg
, "CostInitialize");
3275 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3277 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3278 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3280 r
= MsiDoActionA( hpkg
, "CostFinalize");
3281 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3283 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3284 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3285 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3286 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3287 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3288 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3289 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_LOCAL
, FALSE
);
3290 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3291 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3292 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, TRUE
);
3293 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3294 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3295 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3297 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3298 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3299 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3300 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3301 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3302 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3303 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3304 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3305 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3306 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3307 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3308 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3309 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3310 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3311 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3312 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3313 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3314 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3315 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3316 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3317 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3318 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3319 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3321 MsiCloseHandle(hpkg
);
3323 /* uninstall the product */
3324 r
= MsiInstallProductA(msifile2
, "REMOVE=ALL");
3325 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3327 /* all features installed from source */
3328 r
= MsiInstallProductA(msifile3
, "ADDSOURCE=ALL");
3329 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3331 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3332 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3333 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3334 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3336 r
= MsiOpenDatabaseW(msifile3W
, MSIDBOPEN_DIRECT
, &hdb
);
3337 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3339 /* this property must not be in the saved msi file */
3340 r
= add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3341 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3343 r
= package_from_db( hdb
, &hpkg
);
3344 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3346 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3347 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3349 r
= MsiDoActionA( hpkg
, "CostInitialize");
3350 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3352 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3353 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3355 r
= MsiDoActionA( hpkg
, "FileCost");
3356 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3358 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3359 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3361 r
= MsiDoActionA( hpkg
, "CostFinalize");
3362 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3364 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3365 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3366 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3367 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3368 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3369 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3370 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3371 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3372 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3373 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3374 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3375 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3376 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3378 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3379 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3380 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3381 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3382 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3383 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3384 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3385 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3386 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3387 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3388 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3389 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3390 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3391 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3392 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3393 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3394 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3395 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3396 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3397 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3398 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3399 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3400 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, TRUE
);
3402 MsiCloseHandle(hpkg
);
3404 /* reinstall the product */
3405 r
= MsiInstallProductA(msifile3
, "REINSTALL=ALL");
3406 ok(r
== ERROR_SUCCESS
|| broken(r
== ERROR_INSTALL_FAILURE
) /* win2k3 */, "Expected ERROR_SUCCESS, got %d\n", r
);
3408 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3409 ok(state
== INSTALLSTATE_UNKNOWN
, "state = %d\n", state
);
3410 state
= MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3411 ok(state
== INSTALLSTATE_LOCAL
, "state = %d\n", state
);
3413 r
= MsiOpenDatabaseW(msifile4W
, MSIDBOPEN_DIRECT
, &hdb
);
3414 ok(r
== ERROR_SUCCESS
, "failed to open database: %d\n", r
);
3416 /* this property must not be in the saved msi file */
3417 r
= add_property_entry( hdb
, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3418 ok( r
== ERROR_SUCCESS
, "cannot add property: %d\n", r
);
3420 r
= package_from_db( hdb
, &hpkg
);
3421 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3423 test_feature_states( __LINE__
, hpkg
, "one", ERROR_UNKNOWN_FEATURE
, 0, 0, FALSE
);
3424 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_UNKNOWN_COMPONENT
, 0, 0, FALSE
);
3426 r
= MsiDoActionA( hpkg
, "CostInitialize");
3427 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3429 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3430 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3432 r
= MsiDoActionA( hpkg
, "FileCost");
3433 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3435 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3436 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
3438 r
= MsiDoActionA( hpkg
, "CostFinalize");
3439 ok( r
== ERROR_SUCCESS
, "cost finalize failed: %d\n", r
);
3441 test_feature_states( __LINE__
, hpkg
, "one", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3442 test_feature_states( __LINE__
, hpkg
, "two", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3443 test_feature_states( __LINE__
, hpkg
, "three", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3444 test_feature_states( __LINE__
, hpkg
, "four", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3445 test_feature_states( __LINE__
, hpkg
, "five", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3446 test_feature_states( __LINE__
, hpkg
, "six", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3447 test_feature_states( __LINE__
, hpkg
, "seven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3448 test_feature_states( __LINE__
, hpkg
, "eight", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3449 test_feature_states( __LINE__
, hpkg
, "nine", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3450 test_feature_states( __LINE__
, hpkg
, "ten", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_SOURCE
, FALSE
);
3451 test_feature_states( __LINE__
, hpkg
, "eleven", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, TRUE
);
3452 test_feature_states( __LINE__
, hpkg
, "twelve", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3453 test_feature_states( __LINE__
, hpkg
, "thirteen", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_UNKNOWN
, FALSE
);
3455 test_component_states( __LINE__
, hpkg
, "alpha", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3456 test_component_states( __LINE__
, hpkg
, "beta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3457 test_component_states( __LINE__
, hpkg
, "gamma", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3458 test_component_states( __LINE__
, hpkg
, "theta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3459 test_component_states( __LINE__
, hpkg
, "delta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3460 test_component_states( __LINE__
, hpkg
, "epsilon", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3461 test_component_states( __LINE__
, hpkg
, "zeta", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3462 test_component_states( __LINE__
, hpkg
, "iota", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3463 test_component_states( __LINE__
, hpkg
, "eta", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3464 test_component_states( __LINE__
, hpkg
, "kappa", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
3465 test_component_states( __LINE__
, hpkg
, "lambda", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3466 test_component_states( __LINE__
, hpkg
, "mu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3467 test_component_states( __LINE__
, hpkg
, "nu", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3468 test_component_states( __LINE__
, hpkg
, "xi", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3469 test_component_states( __LINE__
, hpkg
, "omicron", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3470 test_component_states( __LINE__
, hpkg
, "pi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3471 test_component_states( __LINE__
, hpkg
, "rho", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3472 test_component_states( __LINE__
, hpkg
, "sigma", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, FALSE
);
3473 test_component_states( __LINE__
, hpkg
, "tau", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3474 test_component_states( __LINE__
, hpkg
, "phi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3475 test_component_states( __LINE__
, hpkg
, "chi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3476 test_component_states( __LINE__
, hpkg
, "psi", ERROR_SUCCESS
, INSTALLSTATE_SOURCE
, INSTALLSTATE_UNKNOWN
, FALSE
);
3477 test_component_states( __LINE__
, hpkg
, "upsilon", ERROR_SUCCESS
, INSTALLSTATE_LOCAL
, INSTALLSTATE_LOCAL
, TRUE
);
3479 MsiCloseHandle(hpkg
);
3481 /* uninstall the product */
3482 r
= MsiInstallProductA(msifile4
, "REMOVE=ALL");
3483 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3485 DeleteFileA(msifile
);
3486 DeleteFileA(msifile2
);
3487 DeleteFileA(msifile3
);
3488 DeleteFileA(msifile4
);
3491 static void test_getproperty(void)
3493 MSIHANDLE hPackage
= 0;
3495 static CHAR empty
[] = "";
3499 r
= package_from_db(create_package_db(), &hPackage
);
3500 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3502 skip("Not enough rights to perform tests\n");
3503 DeleteFileA(msifile
);
3506 ok( r
== ERROR_SUCCESS
, "Failed to create package %u\n", r
);
3508 /* set the property */
3509 r
= MsiSetPropertyA(hPackage
, "Name", "Value");
3510 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3512 /* retrieve the size, NULL pointer */
3514 r
= MsiGetPropertyA(hPackage
, "Name", NULL
, &size
);
3515 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3516 ok( size
== 5, "Expected 5, got %d\n", size
);
3518 /* retrieve the size, empty string */
3520 r
= MsiGetPropertyA(hPackage
, "Name", empty
, &size
);
3521 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3522 ok( size
== 5, "Expected 5, got %d\n", size
);
3524 /* don't change size */
3525 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3526 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
3527 ok( size
== 5, "Expected 5, got %d\n", size
);
3528 ok( !lstrcmpA(prop
, "Valu"), "Expected Valu, got %s\n", prop
);
3530 /* increase the size by 1 */
3532 r
= MsiGetPropertyA(hPackage
, "Name", prop
, &size
);
3533 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3534 ok( size
== 5, "Expected 5, got %d\n", size
);
3535 ok( !lstrcmpA(prop
, "Value"), "Expected Value, got %s\n", prop
);
3537 r
= MsiCloseHandle( hPackage
);
3538 ok( r
== ERROR_SUCCESS
, "Failed to close package\n" );
3539 DeleteFileA(msifile
);
3542 static void test_removefiles(void)
3547 INSTALLSTATE installed
, action
;
3549 hdb
= create_package_db();
3550 ok ( hdb
, "failed to create package database\n" );
3552 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
3553 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
3555 r
= create_feature_table( hdb
);
3556 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
3558 r
= create_component_table( hdb
);
3559 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
3561 r
= add_feature_entry( hdb
, "'one', '', '', '', 2, 1, '', 0" );
3562 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
3564 r
= add_component_entry( hdb
, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3565 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3567 r
= add_component_entry( hdb
, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3568 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3570 r
= add_component_entry( hdb
, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3571 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3573 r
= add_component_entry( hdb
, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3574 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3576 r
= add_component_entry( hdb
, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3577 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3579 r
= add_component_entry( hdb
, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3580 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3582 r
= add_component_entry( hdb
, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3583 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
3585 r
= create_feature_components_table( hdb
);
3586 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
3588 r
= add_feature_components_entry( hdb
, "'one', 'hydrogen'" );
3589 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3591 r
= add_feature_components_entry( hdb
, "'one', 'helium'" );
3592 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3594 r
= add_feature_components_entry( hdb
, "'one', 'lithium'" );
3595 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3597 r
= add_feature_components_entry( hdb
, "'one', 'beryllium'" );
3598 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3600 r
= add_feature_components_entry( hdb
, "'one', 'boron'" );
3601 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3603 r
= add_feature_components_entry( hdb
, "'one', 'carbon'" );
3604 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3606 r
= add_feature_components_entry( hdb
, "'one', 'oxygen'" );
3607 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
3609 r
= create_file_table( hdb
);
3610 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
3612 r
= add_file_entry( hdb
, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3613 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3615 r
= add_file_entry( hdb
, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3616 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3618 r
= add_file_entry( hdb
, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3619 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3621 r
= add_file_entry( hdb
, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3622 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3624 r
= add_file_entry( hdb
, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3625 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3627 r
= add_file_entry( hdb
, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3628 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3630 r
= add_file_entry( hdb
, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3631 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
3633 r
= create_remove_file_table( hdb
);
3634 ok( r
== ERROR_SUCCESS
, "cannot create Remove File table: %d\n", r
);
3636 r
= package_from_db( hdb
, &hpkg
);
3637 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3639 skip("Not enough rights to perform tests\n");
3640 DeleteFileA(msifile
);
3643 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3645 MsiCloseHandle( hdb
);
3647 create_test_file( "hydrogen.txt" );
3648 create_test_file( "helium.txt" );
3649 create_test_file( "lithium.txt" );
3650 create_test_file( "beryllium.txt" );
3651 create_test_file( "boron.txt" );
3652 create_test_file( "carbon.txt" );
3653 create_test_file( "oxygen.txt" );
3655 r
= MsiSetPropertyA( hpkg
, "TARGETDIR", CURR_DIR
);
3656 ok( r
== ERROR_SUCCESS
, "set property failed\n");
3658 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3660 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3661 ok( r
== ERROR_UNKNOWN_COMPONENT
, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
3663 r
= MsiDoActionA( hpkg
, "CostInitialize");
3664 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
3666 r
= MsiDoActionA( hpkg
, "FileCost");
3667 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
3669 installed
= action
= 0xdeadbeef;
3670 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3671 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3672 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3673 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3675 r
= MsiDoActionA( hpkg
, "CostFinalize");
3676 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
3678 r
= MsiDoActionA( hpkg
, "InstallValidate");
3679 ok( r
== ERROR_SUCCESS
, "install validate failed\n");
3681 r
= MsiSetComponentStateA( hpkg
, "hydrogen", INSTALLSTATE_ABSENT
);
3682 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3684 installed
= action
= 0xdeadbeef;
3685 r
= MsiGetComponentStateA( hpkg
, "hydrogen", &installed
, &action
);
3686 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3687 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3688 todo_wine
ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3690 r
= MsiSetComponentStateA( hpkg
, "helium", INSTALLSTATE_LOCAL
);
3691 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3693 r
= MsiSetComponentStateA( hpkg
, "lithium", INSTALLSTATE_SOURCE
);
3694 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3696 r
= MsiSetComponentStateA( hpkg
, "beryllium", INSTALLSTATE_ABSENT
);
3697 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3699 r
= MsiSetComponentStateA( hpkg
, "boron", INSTALLSTATE_LOCAL
);
3700 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3702 r
= MsiSetComponentStateA( hpkg
, "carbon", INSTALLSTATE_SOURCE
);
3703 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3705 installed
= action
= 0xdeadbeef;
3706 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3707 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3708 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3709 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3711 r
= MsiSetComponentStateA( hpkg
, "oxygen", INSTALLSTATE_ABSENT
);
3712 ok( r
== ERROR_SUCCESS
, "failed to set component state: %d\n", r
);
3714 installed
= action
= 0xdeadbeef;
3715 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3716 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3717 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3718 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3720 r
= MsiDoActionA( hpkg
, "RemoveFiles");
3721 ok( r
== ERROR_SUCCESS
, "remove files failed\n");
3723 installed
= action
= 0xdeadbeef;
3724 r
= MsiGetComponentStateA( hpkg
, "oxygen", &installed
, &action
);
3725 ok( r
== ERROR_SUCCESS
, "failed to get component state %u\n", r
);
3726 ok( installed
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed
);
3727 ok( action
== INSTALLSTATE_UNKNOWN
, "expected INSTALLSTATE_UNKNOWN, got %d\n", action
);
3729 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3730 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3731 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3732 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3733 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3734 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3735 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3737 MsiCloseHandle( hpkg
);
3738 DeleteFileA(msifile
);
3741 static void test_appsearch(void)
3746 CHAR prop
[MAX_PATH
];
3749 const char reg_expand_value
[] = "%systemroot%\\system32\\notepad.exe";
3751 hdb
= create_package_db();
3752 ok ( hdb
, "failed to create package database\n" );
3754 r
= create_appsearch_table( hdb
);
3755 ok( r
== ERROR_SUCCESS
, "cannot create AppSearch table: %d\n", r
);
3757 r
= add_appsearch_entry( hdb
, "'WEBBROWSERPROG', 'NewSignature1'" );
3758 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3760 r
= add_appsearch_entry( hdb
, "'NOTEPAD', 'NewSignature2'" );
3761 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3763 r
= add_appsearch_entry( hdb
, "'REGEXPANDVAL', 'NewSignature3'" );
3764 ok( r
== ERROR_SUCCESS
, "cannot add entry: %d\n", r
);
3766 r
= create_reglocator_table( hdb
);
3767 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3769 r
= add_reglocator_entry( hdb
, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3770 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3772 r
= RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Winetest_msi", 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
3773 ok( r
== ERROR_SUCCESS
, "Could not create key: %d.\n", r
);
3774 r
= RegSetValueExA(hkey
, NULL
, 0, REG_EXPAND_SZ
, (const BYTE
*)reg_expand_value
, strlen(reg_expand_value
) + 1);
3775 ok( r
== ERROR_SUCCESS
, "Could not set key value: %d.\n", r
);
3777 r
= add_reglocator_entry( hdb
, "NewSignature3", 1, "Software\\Winetest_msi", "", 1 );
3778 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3780 r
= create_drlocator_table( hdb
);
3781 ok( r
== ERROR_SUCCESS
, "cannot create DrLocator table: %d\n", r
);
3783 r
= add_drlocator_entry( hdb
, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3784 ok( r
== ERROR_SUCCESS
, "cannot create RegLocator table: %d\n", r
);
3786 r
= create_signature_table( hdb
);
3787 ok( r
== ERROR_SUCCESS
, "cannot create Signature table: %d\n", r
);
3789 r
= add_signature_entry( hdb
, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3790 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3792 r
= add_signature_entry( hdb
, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3793 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3795 r
= add_signature_entry( hdb
, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3796 ok( r
== ERROR_SUCCESS
, "cannot add signature: %d\n", r
);
3798 r
= package_from_db( hdb
, &hpkg
);
3799 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
3801 skip("Not enough rights to perform tests\n");
3802 DeleteFileA(msifile
);
3805 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
3806 MsiCloseHandle( hdb
);
3807 if (r
!= ERROR_SUCCESS
)
3810 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
3812 r
= MsiDoActionA( hpkg
, "AppSearch" );
3813 ok( r
== ERROR_SUCCESS
, "AppSearch failed: %d\n", r
);
3815 size
= sizeof(prop
);
3816 r
= MsiGetPropertyA( hpkg
, "WEBBROWSERPROG", prop
, &size
);
3817 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3818 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
3820 size
= sizeof(prop
);
3821 r
= MsiGetPropertyA( hpkg
, "NOTEPAD", prop
, &size
);
3822 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3824 size
= sizeof(prop
);
3825 r
= MsiGetPropertyA( hpkg
, "REGEXPANDVAL", prop
, &size
);
3826 ok( r
== ERROR_SUCCESS
, "get property failed: %d\n", r
);
3827 ok( lstrlenA(prop
) != 0, "Expected non-zero length\n");
3830 MsiCloseHandle( hpkg
);
3831 DeleteFileA(msifile
);
3832 RegDeleteKeyA(HKEY_CURRENT_USER
, "Software\\Winetest_msi");
3835 static void test_appsearch_complocator(void)
3837 MSIHANDLE hpkg
, hdb
;
3838 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
3843 if (!(usersid
= get_user_sid()))
3846 if (is_process_limited())
3848 skip("process is limited\n");
3852 create_test_file("FileName1");
3853 create_test_file("FileName4");
3854 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE
,
3855 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL
, FALSE
);
3857 create_test_file("FileName2");
3858 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED
,
3859 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid
, FALSE
);
3861 create_test_file("FileName3");
3862 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED
,
3863 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid
, FALSE
);
3865 create_test_file("FileName5");
3866 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE
,
3867 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL
, TRUE
);
3869 create_test_file("FileName6");
3870 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE
,
3871 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL
, TRUE
);
3873 create_test_file("FileName7");
3874 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE
,
3875 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL
, FALSE
);
3877 /* dir is FALSE, but we're pretending it's a directory */
3878 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE
,
3879 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL
, FALSE
);
3881 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3882 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE
,
3883 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL
, FALSE
);
3885 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3886 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE
,
3887 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL
, FALSE
);
3889 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3890 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE
,
3891 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL
, FALSE
);
3893 hdb
= create_package_db();
3894 ok(hdb
, "Expected a valid database handle\n");
3896 r
= create_appsearch_table(hdb
);
3897 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3899 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
3900 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3902 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
3903 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3905 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
3906 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3908 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
3909 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3911 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
3912 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3914 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
3915 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3917 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
3918 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3920 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
3921 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3923 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
3924 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3926 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
3927 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3929 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
3930 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3932 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
3933 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3935 r
= create_complocator_table(hdb
);
3936 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3938 /* published component, machine, file, signature, misdbLocatorTypeFile */
3939 r
= add_complocator_entry(hdb
, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
3940 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3942 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
3943 r
= add_complocator_entry(hdb
, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
3944 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3946 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
3947 r
= add_complocator_entry(hdb
, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
3948 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3950 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
3951 r
= add_complocator_entry(hdb
, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
3952 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3954 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
3955 r
= add_complocator_entry(hdb
, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
3956 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3958 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
3959 r
= add_complocator_entry(hdb
, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
3960 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3962 /* published component, machine, file, no signature, misdbLocatorTypeFile */
3963 r
= add_complocator_entry(hdb
, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
3964 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3966 /* unpublished component, no signature, misdbLocatorTypeDir */
3967 r
= add_complocator_entry(hdb
, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
3968 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3970 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
3971 r
= add_complocator_entry(hdb
, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
3972 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3974 /* published component, signature w/ ver, misdbLocatorTypeFile */
3975 r
= add_complocator_entry(hdb
, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
3976 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3978 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
3979 r
= add_complocator_entry(hdb
, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
3980 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3982 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
3983 r
= add_complocator_entry(hdb
, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
3984 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3986 r
= create_signature_table(hdb
);
3987 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3989 r
= add_signature_entry(hdb
, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
3990 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3992 r
= add_signature_entry(hdb
, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
3993 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3995 r
= add_signature_entry(hdb
, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
3996 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3998 r
= add_signature_entry(hdb
, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
3999 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4001 r
= add_signature_entry(hdb
, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
4002 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4004 r
= add_signature_entry(hdb
, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4005 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4007 r
= add_signature_entry(hdb
, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4008 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4010 r
= add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4011 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4013 r
= package_from_db(hdb
, &hpkg
);
4014 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
4016 skip("Not enough rights to perform tests\n");
4019 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4021 r
= MsiSetPropertyA(hpkg
, "SIGPROP8", "october");
4022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4024 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4026 r
= MsiDoActionA(hpkg
, "AppSearch");
4027 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4029 strcpy(expected
, CURR_DIR
);
4030 if (is_root(CURR_DIR
)) expected
[2] = 0;
4033 sprintf(path
, "%s\\FileName1", expected
);
4034 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4035 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4036 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4039 sprintf(path
, "%s\\FileName2", expected
);
4040 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4041 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4042 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4045 sprintf(path
, "%s\\FileName3", expected
);
4046 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4047 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4048 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4051 sprintf(path
, "%s\\FileName4", expected
);
4052 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
4053 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4054 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4057 sprintf(path
, "%s\\FileName5", expected
);
4058 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4059 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4060 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4063 sprintf(path
, "%s\\", expected
);
4064 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4065 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4066 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4069 sprintf(path
, "%s\\", expected
);
4070 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4071 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4072 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4075 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4076 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4077 ok(!lstrcmpA(prop
, "october"), "Expected \"october\", got \"%s\"\n", prop
);
4080 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4081 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4082 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4085 sprintf(path
, "%s\\FileName8.dll", expected
);
4086 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4087 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4088 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4091 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4092 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4093 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4096 sprintf(path
, "%s\\FileName10.dll", expected
);
4097 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4098 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4099 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4101 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4102 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4103 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4104 MSIINSTALLCONTEXT_USERUNMANAGED
, usersid
);
4105 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4106 MSIINSTALLCONTEXT_USERMANAGED
, usersid
);
4107 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4108 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4109 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4110 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4111 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4112 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4113 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4114 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4115 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4116 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4117 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4118 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4119 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4120 MSIINSTALLCONTEXT_MACHINE
, NULL
);
4122 MsiCloseHandle(hpkg
);
4125 DeleteFileA("FileName1");
4126 DeleteFileA("FileName2");
4127 DeleteFileA("FileName3");
4128 DeleteFileA("FileName4");
4129 DeleteFileA("FileName5");
4130 DeleteFileA("FileName6");
4131 DeleteFileA("FileName7");
4132 DeleteFileA("FileName8.dll");
4133 DeleteFileA("FileName9.dll");
4134 DeleteFileA("FileName10.dll");
4135 DeleteFileA(msifile
);
4139 static void test_appsearch_reglocator(void)
4141 MSIHANDLE hpkg
, hdb
;
4142 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4143 DWORD binary
[2], size
, val
;
4144 BOOL space
, version
, is_64bit
= sizeof(void *) > sizeof(int);
4145 HKEY hklm
, classes
, hkcu
, users
;
4146 LPSTR pathdata
, pathvar
, ptr
;
4153 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4156 DeleteFileA("test.dll");
4158 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, "Software\\Wine", &classes
);
4159 if (res
== ERROR_ACCESS_DENIED
)
4161 skip("Not enough rights to perform tests\n");
4164 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4166 res
= RegSetValueExA(classes
, "Value1", 0, REG_SZ
,
4167 (const BYTE
*)"regszdata", 10);
4168 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4170 res
= RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine", &hkcu
);
4171 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4173 res
= RegSetValueExA(hkcu
, "Value1", 0, REG_SZ
,
4174 (const BYTE
*)"regszdata", 10);
4175 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4178 res
= RegCreateKeyA(HKEY_USERS
, "S-1-5-18\\Software\\Wine", &users
);
4179 ok(res
== ERROR_SUCCESS
||
4180 broken(res
== ERROR_INVALID_PARAMETER
),
4181 "Expected ERROR_SUCCESS, got %d\n", res
);
4183 if (res
== ERROR_SUCCESS
)
4185 res
= RegSetValueExA(users
, "Value1", 0, REG_SZ
,
4186 (const BYTE
*)"regszdata", 10);
4187 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4190 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, "Software\\Wine", &hklm
);
4191 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4193 res
= RegSetValueA(hklm
, NULL
, REG_SZ
, "defvalue", 8);
4194 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4196 res
= RegSetValueExA(hklm
, "Value1", 0, REG_SZ
,
4197 (const BYTE
*)"regszdata", 10);
4198 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4201 res
= RegSetValueExA(hklm
, "Value2", 0, REG_DWORD
,
4202 (const BYTE
*)&val
, sizeof(DWORD
));
4203 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4206 res
= RegSetValueExA(hklm
, "Value3", 0, REG_DWORD
,
4207 (const BYTE
*)&val
, sizeof(DWORD
));
4208 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4210 res
= RegSetValueExA(hklm
, "Value4", 0, REG_EXPAND_SZ
,
4211 (const BYTE
*)"%PATH%", 7);
4212 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4214 res
= RegSetValueExA(hklm
, "Value5", 0, REG_EXPAND_SZ
,
4215 (const BYTE
*)"my%NOVAR%", 10);
4216 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4218 res
= RegSetValueExA(hklm
, "Value6", 0, REG_MULTI_SZ
,
4219 (const BYTE
*)"one\0two\0", 9);
4220 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4222 binary
[0] = 0x1234abcd;
4223 binary
[1] = 0x567890ef;
4224 res
= RegSetValueExA(hklm
, "Value7", 0, REG_BINARY
,
4225 (const BYTE
*)binary
, sizeof(binary
));
4226 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4228 res
= RegSetValueExA(hklm
, "Value8", 0, REG_SZ
,
4229 (const BYTE
*)"#regszdata", 11);
4230 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4232 strcpy(expected
, CURR_DIR
);
4233 if (is_root(CURR_DIR
)) expected
[2] = 0;
4235 create_test_file("FileName1");
4236 sprintf(path
, "%s\\FileName1", expected
);
4237 res
= RegSetValueExA(hklm
, "Value9", 0, REG_SZ
,
4238 (const BYTE
*)path
, lstrlenA(path
) + 1);
4239 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4241 sprintf(path
, "%s\\FileName2", expected
);
4242 res
= RegSetValueExA(hklm
, "Value10", 0, REG_SZ
,
4243 (const BYTE
*)path
, lstrlenA(path
) + 1);
4244 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4246 lstrcpyA(path
, expected
);
4247 res
= RegSetValueExA(hklm
, "Value11", 0, REG_SZ
,
4248 (const BYTE
*)path
, lstrlenA(path
) + 1);
4249 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4251 res
= RegSetValueExA(hklm
, "Value12", 0, REG_SZ
,
4252 (const BYTE
*)"", 1);
4253 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4255 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4256 sprintf(path
, "%s\\FileName3.dll", expected
);
4257 res
= RegSetValueExA(hklm
, "Value13", 0, REG_SZ
,
4258 (const BYTE
*)path
, lstrlenA(path
) + 1);
4259 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4261 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4262 sprintf(path
, "%s\\FileName4.dll", expected
);
4263 res
= RegSetValueExA(hklm
, "Value14", 0, REG_SZ
,
4264 (const BYTE
*)path
, lstrlenA(path
) + 1);
4265 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4267 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4268 sprintf(path
, "%s\\FileName5.dll", expected
);
4269 res
= RegSetValueExA(hklm
, "Value15", 0, REG_SZ
,
4270 (const BYTE
*)path
, lstrlenA(path
) + 1);
4271 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4273 sprintf(path
, "\"%s\\FileName1\" -option", expected
);
4274 res
= RegSetValueExA(hklm
, "value16", 0, REG_SZ
,
4275 (const BYTE
*)path
, lstrlenA(path
) + 1);
4276 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4278 space
= strchr(expected
, ' ') != NULL
;
4279 sprintf(path
, "%s\\FileName1 -option", expected
);
4280 res
= RegSetValueExA(hklm
, "value17", 0, REG_SZ
,
4281 (const BYTE
*)path
, lstrlenA(path
) + 1);
4282 ok( res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
4284 hdb
= create_package_db();
4285 ok(hdb
, "Expected a valid database handle\n");
4287 r
= create_appsearch_table(hdb
);
4288 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4290 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4291 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4293 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4294 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4296 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4297 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4299 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4300 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4302 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4303 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4305 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4308 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4309 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4311 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4312 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4314 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4315 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4317 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4318 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4320 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4321 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4323 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4324 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4326 r
= add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
4327 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4329 r
= add_appsearch_entry(hdb
, "'SIGPROP14', 'NewSignature14'");
4330 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4332 r
= add_appsearch_entry(hdb
, "'SIGPROP15', 'NewSignature15'");
4333 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4335 r
= add_appsearch_entry(hdb
, "'SIGPROP16', 'NewSignature16'");
4336 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4338 r
= add_appsearch_entry(hdb
, "'SIGPROP17', 'NewSignature17'");
4339 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4341 r
= add_appsearch_entry(hdb
, "'SIGPROP18', 'NewSignature18'");
4342 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4344 r
= add_appsearch_entry(hdb
, "'SIGPROP19', 'NewSignature19'");
4345 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4347 r
= add_appsearch_entry(hdb
, "'SIGPROP20', 'NewSignature20'");
4348 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4350 r
= add_appsearch_entry(hdb
, "'SIGPROP21', 'NewSignature21'");
4351 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4353 r
= add_appsearch_entry(hdb
, "'SIGPROP22', 'NewSignature22'");
4354 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4356 r
= add_appsearch_entry(hdb
, "'SIGPROP23', 'NewSignature23'");
4357 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4359 r
= add_appsearch_entry(hdb
, "'SIGPROP24', 'NewSignature24'");
4360 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4362 r
= add_appsearch_entry(hdb
, "'SIGPROP25', 'NewSignature25'");
4363 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4365 r
= add_appsearch_entry(hdb
, "'SIGPROP26', 'NewSignature26'");
4366 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4368 r
= add_appsearch_entry(hdb
, "'SIGPROP27', 'NewSignature27'");
4369 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4371 r
= add_appsearch_entry(hdb
, "'SIGPROP28', 'NewSignature28'");
4372 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4374 r
= add_appsearch_entry(hdb
, "'SIGPROP29', 'NewSignature29'");
4375 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4377 r
= add_appsearch_entry(hdb
, "'SIGPROP30', 'NewSignature30'");
4378 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4380 r
= create_reglocator_table(hdb
);
4381 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4383 type
= msidbLocatorTypeRawValue
;
4385 type
|= msidbLocatorType64bit
;
4387 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4388 r
= add_reglocator_entry(hdb
, "NewSignature1", 2, "Software\\Wine", "Value1", type
);
4389 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4391 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4392 r
= add_reglocator_entry(hdb
, "NewSignature2", 2, "Software\\Wine", "Value2", type
);
4393 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4395 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4396 r
= add_reglocator_entry(hdb
, "NewSignature3", 2, "Software\\Wine", "Value3", type
);
4397 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4399 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4400 r
= add_reglocator_entry(hdb
, "NewSignature4", 2, "Software\\Wine", "Value4", type
);
4401 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4403 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4404 r
= add_reglocator_entry(hdb
, "NewSignature5", 2, "Software\\Wine", "Value5", type
);
4405 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4407 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4408 r
= add_reglocator_entry(hdb
, "NewSignature6", 2, "Software\\Wine", "Value6", type
);
4409 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4411 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4412 r
= add_reglocator_entry(hdb
, "NewSignature7", 2, "Software\\Wine", "Value7", type
);
4413 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4415 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4416 r
= add_reglocator_entry(hdb
, "NewSignature8", 2, "Software\\Wine", "Value8", type
);
4417 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4419 type
= msidbLocatorTypeFileName
;
4421 type
|= msidbLocatorType64bit
;
4423 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4424 r
= add_reglocator_entry(hdb
, "NewSignature9", 2, "Software\\Wine", "Value9", type
);
4425 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4427 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4428 r
= add_reglocator_entry(hdb
, "NewSignature10", 2, "Software\\Wine", "Value10", type
);
4429 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4431 /* HKLM, msidbLocatorTypeFileName, no signature */
4432 r
= add_reglocator_entry(hdb
, "NewSignature11", 2, "Software\\Wine", "Value9", type
);
4433 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4435 type
= msidbLocatorTypeDirectory
;
4437 type
|= msidbLocatorType64bit
;
4439 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4440 r
= add_reglocator_entry(hdb
, "NewSignature12", 2, "Software\\Wine", "Value9", type
);
4441 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4443 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4444 r
= add_reglocator_entry(hdb
, "NewSignature13", 2, "Software\\Wine", "Value11", type
);
4445 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4447 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4448 r
= add_reglocator_entry(hdb
, "NewSignature14", 2, "Software\\Wine", "Value9", type
);
4449 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4451 type
= msidbLocatorTypeRawValue
;
4453 type
|= msidbLocatorType64bit
;
4455 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4456 r
= add_reglocator_entry(hdb
, "NewSignature15", 0, "Software\\Wine", "Value1", type
);
4457 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4459 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4460 r
= add_reglocator_entry(hdb
, "NewSignature16", 1, "Software\\Wine", "Value1", type
);
4461 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4463 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4464 r
= add_reglocator_entry(hdb
, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type
);
4465 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4467 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4468 r
= add_reglocator_entry(hdb
, "NewSignature18", 2, "Software\\Wine", "", type
);
4469 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4471 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4472 r
= add_reglocator_entry(hdb
, "NewSignature19", 2, "Software\\IDontExist", "", type
);
4473 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4475 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4476 r
= add_reglocator_entry(hdb
, "NewSignature20", 2, "Software\\Wine", "Value12", type
);
4477 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4479 type
= msidbLocatorTypeFileName
;
4481 type
|= msidbLocatorType64bit
;
4483 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4484 r
= add_reglocator_entry(hdb
, "NewSignature21", 2, "Software\\Wine", "Value13", type
);
4485 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4487 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4488 r
= add_reglocator_entry(hdb
, "NewSignature22", 2, "Software\\Wine", "Value14", type
);
4489 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4491 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4492 r
= add_reglocator_entry(hdb
, "NewSignature23", 2, "Software\\Wine", "Value15", type
);
4493 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4495 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4496 r
= add_reglocator_entry(hdb
, "NewSignature24", 2, "Software\\Wine", "Value11", type
);
4497 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4499 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4500 r
= add_reglocator_entry(hdb
, "NewSignature25", 2, "Software\\Wine", "Value10", type
);
4501 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4503 type
= msidbLocatorTypeDirectory
;
4505 type
|= msidbLocatorType64bit
;
4507 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4508 r
= add_reglocator_entry(hdb
, "NewSignature26", 2, "Software\\Wine", "Value11", type
);
4509 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4511 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4512 r
= add_reglocator_entry(hdb
, "NewSignature27", 2, "Software\\Wine", "Value10", type
);
4513 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4515 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4516 r
= add_reglocator_entry(hdb
, "NewSignature28", 2, "Software\\Wine", "Value10", type
);
4517 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4519 type
= msidbLocatorTypeFileName
;
4521 type
|= msidbLocatorType64bit
;
4523 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4524 r
= add_reglocator_entry(hdb
, "NewSignature29", 2, "Software\\Wine", "Value16", type
);
4525 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4527 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4528 r
= add_reglocator_entry(hdb
, "NewSignature30", 2, "Software\\Wine", "Value17", type
);
4529 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4531 r
= create_signature_table(hdb
);
4532 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4534 str
= "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4535 r
= add_signature_entry(hdb
, str
);
4536 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4538 str
= "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4539 r
= add_signature_entry(hdb
, str
);
4540 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4542 str
= "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4543 r
= add_signature_entry(hdb
, str
);
4544 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4546 str
= "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4547 r
= add_signature_entry(hdb
, str
);
4548 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4550 str
= "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4551 r
= add_signature_entry(hdb
, str
);
4552 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4554 str
= "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4555 r
= add_signature_entry(hdb
, str
);
4556 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4558 if (!is_root(CURR_DIR
))
4560 ptr
= strrchr(expected
, '\\') + 1;
4561 sprintf(path
, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr
);
4562 r
= add_signature_entry(hdb
, path
);
4563 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4565 str
= "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4566 r
= add_signature_entry(hdb
, str
);
4567 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4569 str
= "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4570 r
= add_signature_entry(hdb
, str
);
4571 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4573 str
= "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4574 r
= add_signature_entry(hdb
, str
);
4575 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4577 r
= package_from_db(hdb
, &hpkg
);
4578 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
4580 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
4582 r
= MsiDoActionA(hpkg
, "AppSearch");
4583 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4586 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
4587 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4588 ok(!lstrcmpA(prop
, "regszdata"),
4589 "Expected \"regszdata\", got \"%s\"\n", prop
);
4592 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
4593 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4594 ok(!lstrcmpA(prop
, "#42"), "Expected \"#42\", got \"%s\"\n", prop
);
4597 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
4598 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4599 ok(!lstrcmpA(prop
, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop
);
4601 memset(&si
, 0, sizeof(si
));
4602 if (pGetNativeSystemInfo
) pGetNativeSystemInfo(&si
);
4604 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
4606 size
= ExpandEnvironmentStringsA("%PATH%", NULL
, 0);
4607 pathvar
= HeapAlloc(GetProcessHeap(), 0, size
);
4608 ExpandEnvironmentStringsA("%PATH%", pathvar
, size
);
4611 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", NULL
, &size
);
4612 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4614 pathdata
= HeapAlloc(GetProcessHeap(), 0, ++size
);
4615 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", pathdata
, &size
);
4616 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4617 ok(!lstrcmpA(pathdata
, pathvar
),
4618 "Expected \"%s\", got \"%s\"\n", pathvar
, pathdata
);
4620 HeapFree(GetProcessHeap(), 0, pathvar
);
4621 HeapFree(GetProcessHeap(), 0, pathdata
);
4625 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
4626 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4628 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop
);
4631 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
4632 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4635 ok(!memcmp(prop
, "\0one\0two\0\0", 10),
4636 "Expected \"\\0one\\0two\\0\\0\"\n");
4640 lstrcpyA(path
, "#xCDAB3412EF907856");
4641 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
4642 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4643 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4646 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
4647 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4648 ok(!lstrcmpA(prop
, "##regszdata"),
4649 "Expected \"##regszdata\", got \"%s\"\n", prop
);
4652 sprintf(path
, "%s\\FileName1", expected
);
4653 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
4654 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4655 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4658 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
4659 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4660 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4663 sprintf(path
, "%s\\", expected
);
4664 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
4665 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4666 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4669 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
4670 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4671 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4674 sprintf(path
, "%s\\", expected
);
4675 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
4676 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4677 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4680 r
= MsiGetPropertyA(hpkg
, "SIGPROP14", prop
, &size
);
4681 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4682 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4685 r
= MsiGetPropertyA(hpkg
, "SIGPROP15", prop
, &size
);
4686 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4687 ok(!lstrcmpA(prop
, "regszdata"),
4688 "Expected \"regszdata\", got \"%s\"\n", prop
);
4691 r
= MsiGetPropertyA(hpkg
, "SIGPROP16", prop
, &size
);
4692 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4693 ok(!lstrcmpA(prop
, "regszdata"),
4694 "Expected \"regszdata\", got \"%s\"\n", prop
);
4699 r
= MsiGetPropertyA(hpkg
, "SIGPROP17", prop
, &size
);
4700 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4701 ok(!lstrcmpA(prop
, "regszdata"),
4702 "Expected \"regszdata\", got \"%s\"\n", prop
);
4706 r
= MsiGetPropertyA(hpkg
, "SIGPROP18", prop
, &size
);
4707 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4708 ok(!lstrcmpA(prop
, "defvalue"),
4709 "Expected \"defvalue\", got \"%s\"\n", prop
);
4712 r
= MsiGetPropertyA(hpkg
, "SIGPROP19", prop
, &size
);
4713 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4714 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4717 r
= MsiGetPropertyA(hpkg
, "SIGPROP20", prop
, &size
);
4718 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4719 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4724 sprintf(path
, "%s\\FileName3.dll", expected
);
4725 r
= MsiGetPropertyA(hpkg
, "SIGPROP21", prop
, &size
);
4726 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4727 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4730 r
= MsiGetPropertyA(hpkg
, "SIGPROP22", prop
, &size
);
4731 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4732 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4735 sprintf(path
, "%s\\FileName5.dll", expected
);
4736 r
= MsiGetPropertyA(hpkg
, "SIGPROP23", prop
, &size
);
4737 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4738 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4741 if (!is_root(CURR_DIR
))
4744 lstrcpyA(path
, expected
);
4745 ptr
= strrchr(path
, '\\') + 1;
4747 r
= MsiGetPropertyA(hpkg
, "SIGPROP24", prop
, &size
);
4748 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4749 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4752 sprintf(path
, "%s\\", expected
);
4753 r
= MsiGetPropertyA(hpkg
, "SIGPROP25", prop
, &size
);
4754 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4755 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4758 r
= MsiGetPropertyA(hpkg
, "SIGPROP26", prop
, &size
);
4759 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4760 if (is_root(CURR_DIR
))
4761 ok(!lstrcmpA(prop
, CURR_DIR
), "Expected \"%s\", got \"%s\"\n", CURR_DIR
, prop
);
4763 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4766 r
= MsiGetPropertyA(hpkg
, "SIGPROP27", prop
, &size
);
4767 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4768 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4771 r
= MsiGetPropertyA(hpkg
, "SIGPROP28", prop
, &size
);
4772 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4773 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4776 sprintf(path
, "%s\\FileName1", expected
);
4777 r
= MsiGetPropertyA(hpkg
, "SIGPROP29", prop
, &size
);
4778 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4779 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4782 sprintf(path
, "%s\\FileName1", expected
);
4783 r
= MsiGetPropertyA(hpkg
, "SIGPROP30", prop
, &size
);
4784 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4786 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
4788 todo_wine
ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
4790 RegSetValueA(hklm
, NULL
, REG_SZ
, "", 0);
4791 RegDeleteValueA(hklm
, "Value1");
4792 RegDeleteValueA(hklm
, "Value2");
4793 RegDeleteValueA(hklm
, "Value3");
4794 RegDeleteValueA(hklm
, "Value4");
4795 RegDeleteValueA(hklm
, "Value5");
4796 RegDeleteValueA(hklm
, "Value6");
4797 RegDeleteValueA(hklm
, "Value7");
4798 RegDeleteValueA(hklm
, "Value8");
4799 RegDeleteValueA(hklm
, "Value9");
4800 RegDeleteValueA(hklm
, "Value10");
4801 RegDeleteValueA(hklm
, "Value11");
4802 RegDeleteValueA(hklm
, "Value12");
4803 RegDeleteValueA(hklm
, "Value13");
4804 RegDeleteValueA(hklm
, "Value14");
4805 RegDeleteValueA(hklm
, "Value15");
4806 RegDeleteValueA(hklm
, "Value16");
4807 RegDeleteValueA(hklm
, "Value17");
4808 RegDeleteKeyA(hklm
, "");
4811 RegDeleteValueA(classes
, "Value1");
4812 RegDeleteKeyA(classes
, "");
4813 RegCloseKey(classes
);
4815 RegDeleteValueA(hkcu
, "Value1");
4816 RegDeleteKeyA(hkcu
, "");
4819 RegDeleteValueA(users
, "Value1");
4820 RegDeleteKeyA(users
, "");
4823 DeleteFileA("FileName1");
4824 DeleteFileA("FileName3.dll");
4825 DeleteFileA("FileName4.dll");
4826 DeleteFileA("FileName5.dll");
4827 MsiCloseHandle(hpkg
);
4828 DeleteFileA(msifile
);
4831 static void delete_win_ini(LPCSTR file
)
4833 CHAR path
[MAX_PATH
];
4835 GetWindowsDirectoryA(path
, MAX_PATH
);
4836 lstrcatA(path
, "\\");
4837 lstrcatA(path
, file
);
4842 static void test_appsearch_inilocator(void)
4844 MSIHANDLE hpkg
, hdb
;
4845 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
4853 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4856 DeleteFileA("test.dll");
4858 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4860 strcpy(expected
, CURR_DIR
);
4861 if (is_root(CURR_DIR
)) expected
[2] = 0;
4863 create_test_file("FileName1");
4864 sprintf(path
, "%s\\FileName1", expected
);
4865 WritePrivateProfileStringA("Section", "Key2", path
, "IniFile.ini");
4867 WritePrivateProfileStringA("Section", "Key3", expected
, "IniFile.ini");
4869 sprintf(path
, "%s\\IDontExist", expected
);
4870 WritePrivateProfileStringA("Section", "Key4", path
, "IniFile.ini");
4872 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4873 sprintf(path
, "%s\\FileName2.dll", expected
);
4874 WritePrivateProfileStringA("Section", "Key5", path
, "IniFile.ini");
4876 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4877 sprintf(path
, "%s\\FileName3.dll", expected
);
4878 WritePrivateProfileStringA("Section", "Key6", path
, "IniFile.ini");
4880 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4881 sprintf(path
, "%s\\FileName4.dll", expected
);
4882 WritePrivateProfileStringA("Section", "Key7", path
, "IniFile.ini");
4884 hdb
= create_package_db();
4885 ok(hdb
, "Expected a valid database handle\n");
4887 r
= create_appsearch_table(hdb
);
4888 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4890 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
4891 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4893 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
4894 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4896 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
4897 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4899 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
4900 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4902 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
4903 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4905 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
4906 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4908 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
4909 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4911 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
4912 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4914 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
4915 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4917 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
4918 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4920 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
4921 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4923 r
= add_appsearch_entry(hdb
, "'SIGPROP12', 'NewSignature12'");
4924 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4926 r
= create_inilocator_table(hdb
);
4927 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4929 /* msidbLocatorTypeRawValue, field 1 */
4930 str
= "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
4931 r
= add_inilocator_entry(hdb
, str
);
4932 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4934 /* msidbLocatorTypeRawValue, field 2 */
4935 str
= "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
4936 r
= add_inilocator_entry(hdb
, str
);
4937 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4939 /* msidbLocatorTypeRawValue, entire field */
4940 str
= "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
4941 r
= add_inilocator_entry(hdb
, str
);
4942 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4944 /* msidbLocatorTypeFile */
4945 str
= "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4946 r
= add_inilocator_entry(hdb
, str
);
4947 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4949 /* msidbLocatorTypeDirectory, file */
4950 str
= "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
4951 r
= add_inilocator_entry(hdb
, str
);
4952 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4954 /* msidbLocatorTypeDirectory, directory */
4955 str
= "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
4956 r
= add_inilocator_entry(hdb
, str
);
4957 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4959 /* msidbLocatorTypeFile, file, no signature */
4960 str
= "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4961 r
= add_inilocator_entry(hdb
, str
);
4962 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4964 /* msidbLocatorTypeFile, dir, no signature */
4965 str
= "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
4966 r
= add_inilocator_entry(hdb
, str
);
4967 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4969 /* msidbLocatorTypeFile, file does not exist */
4970 str
= "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
4971 r
= add_inilocator_entry(hdb
, str
);
4972 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4974 /* msidbLocatorTypeFile, signature with version */
4975 str
= "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
4976 r
= add_inilocator_entry(hdb
, str
);
4977 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4979 /* msidbLocatorTypeFile, signature with version, ver > max */
4980 str
= "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
4981 r
= add_inilocator_entry(hdb
, str
);
4982 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4984 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4985 str
= "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
4986 r
= add_inilocator_entry(hdb
, str
);
4987 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4989 r
= create_signature_table(hdb
);
4990 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4992 r
= add_signature_entry(hdb
, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4993 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4995 r
= add_signature_entry(hdb
, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4996 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4998 r
= add_signature_entry(hdb
, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4999 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5001 r
= add_signature_entry(hdb
, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5002 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5004 r
= add_signature_entry(hdb
, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5005 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5007 r
= package_from_db(hdb
, &hpkg
);
5008 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5010 skip("Not enough rights to perform tests\n");
5013 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5015 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5017 r
= MsiDoActionA(hpkg
, "AppSearch");
5018 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5021 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5023 ok(!lstrcmpA(prop
, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop
);
5026 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5027 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5028 ok(!lstrcmpA(prop
, "field2"), "Expected \"field2\", got \"%s\"\n", prop
);
5031 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5032 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5033 ok(!lstrcmpA(prop
, "keydata,field2"),
5034 "Expected \"keydata,field2\", got \"%s\"\n", prop
);
5037 sprintf(path
, "%s\\FileName1", expected
);
5038 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5039 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5040 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5043 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5044 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5045 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5048 sprintf(path
, "%s\\", expected
);
5049 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5050 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5051 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5054 sprintf(path
, "%s\\", expected
);
5055 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5056 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5057 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5059 if (!is_root(CURR_DIR
))
5062 lstrcpyA(path
, expected
);
5063 ptr
= strrchr(path
, '\\');
5065 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5066 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5067 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5070 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5071 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5072 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5077 sprintf(path
, "%s\\FileName2.dll", expected
);
5078 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5079 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5080 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5083 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5084 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5085 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5088 sprintf(path
, "%s\\FileName4.dll", expected
);
5089 r
= MsiGetPropertyA(hpkg
, "SIGPROP12", prop
, &size
);
5090 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5091 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5094 MsiCloseHandle(hpkg
);
5097 delete_win_ini("IniFile.ini");
5098 DeleteFileA("FileName1");
5099 DeleteFileA("FileName2.dll");
5100 DeleteFileA("FileName3.dll");
5101 DeleteFileA("FileName4.dll");
5102 DeleteFileA(msifile
);
5106 * MSI AppSearch action on DrLocator table always returns absolute paths.
5107 * If a relative path was set, it returns the first absolute path that
5108 * matches or an empty string if it didn't find anything.
5109 * This helper function replicates this behaviour.
5111 static void search_absolute_directory(LPSTR absolute
, LPCSTR relative
)
5116 size
= lstrlenA(relative
);
5117 drives
= GetLogicalDrives();
5118 lstrcpyA(absolute
, "A:\\");
5119 for (i
= 0; i
< 26; absolute
[0] = '\0', i
++)
5121 if (!(drives
& (1 << i
)))
5124 absolute
[0] = 'A' + i
;
5125 if (GetDriveTypeA(absolute
) != DRIVE_FIXED
)
5128 lstrcpynA(absolute
+ 3, relative
, size
+ 1);
5129 attr
= GetFileAttributesA(absolute
);
5130 if (attr
!= INVALID_FILE_ATTRIBUTES
&&
5131 (attr
& FILE_ATTRIBUTE_DIRECTORY
))
5133 if (absolute
[3 + size
- 1] != '\\')
5134 lstrcatA(absolute
, "\\");
5141 static void test_appsearch_drlocator(void)
5143 MSIHANDLE hpkg
, hdb
;
5144 char path
[MAX_PATH
], expected
[MAX_PATH
], prop
[MAX_PATH
];
5151 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5154 DeleteFileA("test.dll");
5156 create_test_file("FileName1");
5157 CreateDirectoryA("one", NULL
);
5158 CreateDirectoryA("one\\two", NULL
);
5159 CreateDirectoryA("one\\two\\three", NULL
);
5160 create_test_file("one\\two\\three\\FileName2");
5161 CreateDirectoryA("another", NULL
);
5162 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5163 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5164 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5166 hdb
= create_package_db();
5167 ok(hdb
, "Expected a valid database handle\n");
5169 r
= create_appsearch_table(hdb
);
5170 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5172 r
= add_appsearch_entry(hdb
, "'SIGPROP1', 'NewSignature1'");
5173 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5175 r
= add_appsearch_entry(hdb
, "'SIGPROP2', 'NewSignature2'");
5176 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5178 r
= add_appsearch_entry(hdb
, "'SIGPROP3', 'NewSignature3'");
5179 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5181 r
= add_appsearch_entry(hdb
, "'SIGPROP4', 'NewSignature4'");
5182 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5184 r
= add_appsearch_entry(hdb
, "'SIGPROP5', 'NewSignature5'");
5185 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5187 r
= add_appsearch_entry(hdb
, "'SIGPROP6', 'NewSignature6'");
5188 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5190 r
= add_appsearch_entry(hdb
, "'SIGPROP7', 'NewSignature7'");
5191 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5193 r
= add_appsearch_entry(hdb
, "'SIGPROP8', 'NewSignature8'");
5194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5196 r
= add_appsearch_entry(hdb
, "'SIGPROP9', 'NewSignature9'");
5197 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5199 r
= add_appsearch_entry(hdb
, "'SIGPROP10', 'NewSignature10'");
5200 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5202 r
= add_appsearch_entry(hdb
, "'SIGPROP11', 'NewSignature11'");
5203 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5205 r
= add_appsearch_entry(hdb
, "'SIGPROP13', 'NewSignature13'");
5206 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5208 r
= create_drlocator_table(hdb
);
5209 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5211 strcpy(expected
, CURR_DIR
);
5212 if (is_root(CURR_DIR
)) expected
[2] = 0;
5214 /* no parent, full path, depth 0, signature */
5215 sprintf(path
, "'NewSignature1', '', '%s', 0", expected
);
5216 r
= add_drlocator_entry(hdb
, path
);
5217 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5219 /* no parent, full path, depth 0, no signature */
5220 sprintf(path
, "'NewSignature2', '', '%s', 0", expected
);
5221 r
= add_drlocator_entry(hdb
, path
);
5222 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5224 /* no parent, relative path, depth 0, no signature */
5225 sprintf(path
, "'NewSignature3', '', '%s', 0", expected
+ 3);
5226 r
= add_drlocator_entry(hdb
, path
);
5227 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5229 /* no parent, full path, depth 2, signature */
5230 sprintf(path
, "'NewSignature4', '', '%s', 2", expected
);
5231 r
= add_drlocator_entry(hdb
, path
);
5232 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5234 /* no parent, full path, depth 3, signature */
5235 sprintf(path
, "'NewSignature5', '', '%s', 3", expected
);
5236 r
= add_drlocator_entry(hdb
, path
);
5237 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5239 /* no parent, full path, depth 1, signature is dir */
5240 sprintf(path
, "'NewSignature6', '', '%s', 1", expected
);
5241 r
= add_drlocator_entry(hdb
, path
);
5242 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5244 /* parent is in DrLocator, relative path, depth 0, signature */
5245 sprintf(path
, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5246 r
= add_drlocator_entry(hdb
, path
);
5247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5249 /* no parent, full path, depth 0, signature w/ version */
5250 sprintf(path
, "'NewSignature8', '', '%s', 0", expected
);
5251 r
= add_drlocator_entry(hdb
, path
);
5252 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5254 /* no parent, full path, depth 0, signature w/ version, ver > max */
5255 sprintf(path
, "'NewSignature9', '', '%s', 0", expected
);
5256 r
= add_drlocator_entry(hdb
, path
);
5257 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5259 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5260 sprintf(path
, "'NewSignature10', '', '%s', 0", expected
);
5261 r
= add_drlocator_entry(hdb
, path
);
5262 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5264 /* no parent, relative empty path, depth 0, no signature */
5265 sprintf(path
, "'NewSignature11', '', '', 0");
5266 r
= add_drlocator_entry(hdb
, path
);
5267 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5269 r
= create_reglocator_table(hdb
);
5270 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5273 r
= add_reglocator_entry(hdb
, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5274 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5276 /* parent is in RegLocator, no path, depth 0, no signature */
5277 sprintf(path
, "'NewSignature13', 'NewSignature12', '', 0");
5278 r
= add_drlocator_entry(hdb
, path
);
5279 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5281 r
= create_signature_table(hdb
);
5282 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5284 str
= "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5285 r
= add_signature_entry(hdb
, str
);
5286 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5288 str
= "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5289 r
= add_signature_entry(hdb
, str
);
5290 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5292 str
= "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5293 r
= add_signature_entry(hdb
, str
);
5294 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5296 str
= "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5297 r
= add_signature_entry(hdb
, str
);
5298 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5300 str
= "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5301 r
= add_signature_entry(hdb
, str
);
5302 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5304 str
= "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5305 r
= add_signature_entry(hdb
, str
);
5306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5308 str
= "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5309 r
= add_signature_entry(hdb
, str
);
5310 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5312 str
= "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5313 r
= add_signature_entry(hdb
, str
);
5314 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5316 r
= package_from_db(hdb
, &hpkg
);
5317 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5319 skip("Not enough rights to perform tests\n");
5322 ok(r
== ERROR_SUCCESS
, "Expected a valid package handle %u\n", r
);
5324 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5326 r
= MsiDoActionA(hpkg
, "AppSearch");
5327 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5330 sprintf(path
, "%s\\FileName1", expected
);
5331 r
= MsiGetPropertyA(hpkg
, "SIGPROP1", prop
, &size
);
5332 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5333 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5336 sprintf(path
, "%s\\", expected
);
5337 r
= MsiGetPropertyA(hpkg
, "SIGPROP2", prop
, &size
);
5338 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5339 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5342 search_absolute_directory(path
, expected
+ 3);
5343 r
= MsiGetPropertyA(hpkg
, "SIGPROP3", prop
, &size
);
5344 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5345 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5348 r
= MsiGetPropertyA(hpkg
, "SIGPROP4", prop
, &size
);
5349 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5350 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5353 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5354 r
= MsiGetPropertyA(hpkg
, "SIGPROP5", prop
, &size
);
5355 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5356 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5359 r
= MsiGetPropertyA(hpkg
, "SIGPROP6", prop
, &size
);
5360 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5361 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5364 sprintf(path
, "%s\\one\\two\\three\\FileName2", expected
);
5365 r
= MsiGetPropertyA(hpkg
, "SIGPROP7", prop
, &size
);
5366 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5367 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5372 sprintf(path
, "%s\\FileName3.dll", expected
);
5373 r
= MsiGetPropertyA(hpkg
, "SIGPROP8", prop
, &size
);
5374 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5375 ok(!lstrcmpA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5378 r
= MsiGetPropertyA(hpkg
, "SIGPROP9", prop
, &size
);
5379 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5380 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5383 r
= MsiGetPropertyA(hpkg
, "SIGPROP10", prop
, &size
);
5384 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5385 ok(!lstrcmpA(prop
, ""), "Expected \"\", got \"%s\"\n", prop
);
5389 search_absolute_directory(path
, "");
5390 r
= MsiGetPropertyA(hpkg
, "SIGPROP11", prop
, &size
);
5391 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5392 ok(!lstrcmpiA(prop
, path
), "Expected \"%s\", got \"%s\"\n", path
, prop
);
5395 strcpy(path
, "c:\\");
5396 r
= MsiGetPropertyA(hpkg
, "SIGPROP13", prop
, &size
);
5397 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5398 ok(!prop
[0], "Expected \"\", got \"%s\"\n", prop
);
5400 MsiCloseHandle(hpkg
);
5403 DeleteFileA("FileName1");
5404 DeleteFileA("FileName3.dll");
5405 DeleteFileA("FileName4.dll");
5406 DeleteFileA("FileName5.dll");
5407 DeleteFileA("one\\two\\three\\FileName2");
5408 RemoveDirectoryA("one\\two\\three");
5409 RemoveDirectoryA("one\\two");
5410 RemoveDirectoryA("one");
5411 RemoveDirectoryA("another");
5412 DeleteFileA(msifile
);
5415 static void test_featureparents(void)
5421 hdb
= create_package_db();
5422 ok ( hdb
, "failed to create package database\n" );
5424 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'");
5425 ok( r
== ERROR_SUCCESS
, "cannot add directory: %d\n", r
);
5427 r
= create_feature_table( hdb
);
5428 ok( r
== ERROR_SUCCESS
, "cannot create Feature table: %d\n", r
);
5430 r
= create_component_table( hdb
);
5431 ok( r
== ERROR_SUCCESS
, "cannot create Component table: %d\n", r
);
5433 r
= create_feature_components_table( hdb
);
5434 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table: %d\n", r
);
5436 r
= create_file_table( hdb
);
5437 ok( r
== ERROR_SUCCESS
, "cannot create File table: %d\n", r
);
5439 /* msidbFeatureAttributesFavorLocal */
5440 r
= add_feature_entry( hdb
, "'zodiac', '', '', '', 2, 1, '', 0" );
5441 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5443 /* msidbFeatureAttributesFavorSource */
5444 r
= add_feature_entry( hdb
, "'perseus', '', '', '', 2, 1, '', 1" );
5445 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5447 /* msidbFeatureAttributesFavorLocal */
5448 r
= add_feature_entry( hdb
, "'orion', '', '', '', 2, 1, '', 0" );
5449 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5451 /* msidbFeatureAttributesUIDisallowAbsent */
5452 r
= add_feature_entry( hdb
, "'lyra', '', '', '', 2, 1, '', 16" );
5453 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5455 /* disabled because of install level */
5456 r
= add_feature_entry( hdb
, "'waters', '', '', '', 15, 101, '', 9" );
5457 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5459 /* child feature of disabled feature */
5460 r
= add_feature_entry( hdb
, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5461 ok( r
== ERROR_SUCCESS
, "cannot add feature: %d\n", r
);
5463 /* component of disabled feature (install level) */
5464 r
= add_component_entry( hdb
, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5465 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5467 /* component of disabled child feature (install level) */
5468 r
= add_component_entry( hdb
, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5469 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5471 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5472 r
= add_component_entry( hdb
, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5473 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5475 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5476 r
= add_component_entry( hdb
, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5477 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5479 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5480 r
= add_component_entry( hdb
, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5481 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5483 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5484 r
= add_component_entry( hdb
, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5485 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5487 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5488 r
= add_component_entry( hdb
, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5489 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5491 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5492 r
= add_component_entry( hdb
, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5493 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5495 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5496 r
= add_component_entry( hdb
, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5497 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5499 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5500 r
= add_component_entry( hdb
, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5501 ok( r
== ERROR_SUCCESS
, "cannot add component: %d\n", r
);
5503 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5504 r
= add_component_entry( hdb
, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5505 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5507 r
= add_feature_components_entry( hdb
, "'zodiac', 'leo'" );
5508 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5510 r
= add_feature_components_entry( hdb
, "'zodiac', 'virgo'" );
5511 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5513 r
= add_feature_components_entry( hdb
, "'zodiac', 'libra'" );
5514 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5516 r
= add_feature_components_entry( hdb
, "'perseus', 'cassiopeia'" );
5517 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5519 r
= add_feature_components_entry( hdb
, "'perseus', 'cepheus'" );
5520 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5522 r
= add_feature_components_entry( hdb
, "'perseus', 'andromeda'" );
5523 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5525 r
= add_feature_components_entry( hdb
, "'orion', 'leo'" );
5526 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5528 r
= add_feature_components_entry( hdb
, "'orion', 'virgo'" );
5529 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5531 r
= add_feature_components_entry( hdb
, "'orion', 'libra'" );
5532 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5534 r
= add_feature_components_entry( hdb
, "'orion', 'cassiopeia'" );
5535 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5537 r
= add_feature_components_entry( hdb
, "'orion', 'cepheus'" );
5538 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5540 r
= add_feature_components_entry( hdb
, "'orion', 'andromeda'" );
5541 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5543 r
= add_feature_components_entry( hdb
, "'orion', 'canis'" );
5544 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5546 r
= add_feature_components_entry( hdb
, "'orion', 'monoceros'" );
5547 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5549 r
= add_feature_components_entry( hdb
, "'orion', 'lepus'" );
5550 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5552 r
= add_feature_components_entry( hdb
, "'waters', 'delphinus'" );
5553 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5555 r
= add_feature_components_entry( hdb
, "'bayer', 'hydrus'" );
5556 ok( r
== ERROR_SUCCESS
, "cannot add feature components: %d\n", r
);
5558 r
= add_file_entry( hdb
, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5559 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5561 r
= add_file_entry( hdb
, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5562 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5564 r
= add_file_entry( hdb
, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5565 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5567 r
= add_file_entry( hdb
, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5568 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5570 r
= add_file_entry( hdb
, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5571 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5573 r
= add_file_entry( hdb
, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5574 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5576 r
= add_file_entry( hdb
, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5577 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5579 r
= add_file_entry( hdb
, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5580 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5582 r
= add_file_entry( hdb
, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5583 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5585 r
= add_file_entry( hdb
, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5586 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5588 r
= add_file_entry( hdb
, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5589 ok( r
== ERROR_SUCCESS
, "cannot add file: %d\n", r
);
5591 r
= package_from_db( hdb
, &hpkg
);
5592 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5594 skip("Not enough rights to perform tests\n");
5595 DeleteFileA(msifile
);
5598 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5600 MsiCloseHandle( hdb
);
5602 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5604 r
= MsiDoActionA( hpkg
, "CostInitialize");
5605 ok( r
== ERROR_SUCCESS
, "cost init failed\n");
5607 r
= MsiDoActionA( hpkg
, "FileCost");
5608 ok( r
== ERROR_SUCCESS
, "file cost failed\n");
5610 r
= MsiDoActionA( hpkg
, "CostFinalize");
5611 ok( r
== ERROR_SUCCESS
, "cost finalize failed\n");
5613 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5614 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5615 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5616 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5617 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5618 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5620 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5621 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5622 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5623 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5624 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5625 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5626 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5627 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5628 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5629 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5630 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5632 r
= MsiSetFeatureStateA(hpkg
, "orion", INSTALLSTATE_ABSENT
);
5633 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5635 r
= MsiSetFeatureStateA(hpkg
, "lyra", INSTALLSTATE_ABSENT
);
5636 ok( r
== ERROR_SUCCESS
, "failed to set feature state: %d\n", r
);
5638 r
= MsiSetFeatureStateA(hpkg
, "nosuchfeature", INSTALLSTATE_ABSENT
);
5639 ok( r
== ERROR_UNKNOWN_FEATURE
, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
5641 test_feature_states( __LINE__
, hpkg
, "zodiac", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_LOCAL
, FALSE
);
5642 test_feature_states( __LINE__
, hpkg
, "perseus", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_SOURCE
, FALSE
);
5643 test_feature_states( __LINE__
, hpkg
, "orion", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5644 test_feature_states( __LINE__
, hpkg
, "lyra", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_ABSENT
, FALSE
);
5645 test_feature_states( __LINE__
, hpkg
, "waters", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5646 test_feature_states( __LINE__
, hpkg
, "bayer", ERROR_SUCCESS
, INSTALLSTATE_ABSENT
, INSTALLSTATE_UNKNOWN
, FALSE
);
5648 test_component_states( __LINE__
, hpkg
, "leo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5649 test_component_states( __LINE__
, hpkg
, "virgo", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5650 test_component_states( __LINE__
, hpkg
, "libra", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5651 test_component_states( __LINE__
, hpkg
, "cassiopeia", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_LOCAL
, FALSE
);
5652 test_component_states( __LINE__
, hpkg
, "cepheus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5653 test_component_states( __LINE__
, hpkg
, "andromeda", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_SOURCE
, FALSE
);
5654 test_component_states( __LINE__
, hpkg
, "canis", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5655 test_component_states( __LINE__
, hpkg
, "monoceros", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5656 test_component_states( __LINE__
, hpkg
, "lepus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5657 test_component_states( __LINE__
, hpkg
, "delphinus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5658 test_component_states( __LINE__
, hpkg
, "hydrus", ERROR_SUCCESS
, INSTALLSTATE_UNKNOWN
, INSTALLSTATE_UNKNOWN
, FALSE
);
5660 MsiCloseHandle(hpkg
);
5661 DeleteFileA(msifile
);
5664 static void test_installprops(void)
5666 MSIHANDLE hpkg
, hdb
;
5667 CHAR path
[MAX_PATH
], buf
[MAX_PATH
];
5673 REGSAM access
= KEY_ALL_ACCESS
;
5675 INSTALLUILEVEL uilevel
;
5678 access
|= KEY_WOW64_64KEY
;
5680 lstrcpyA(path
, CURR_DIR
);
5681 if (!is_root(CURR_DIR
)) lstrcatA(path
, "\\");
5682 lstrcatA(path
, msifile
);
5684 uilevel
= MsiSetInternalUI(INSTALLUILEVEL_BASIC
|INSTALLUILEVEL_SOURCERESONLY
, NULL
);
5686 hdb
= create_package_db();
5687 ok( hdb
, "failed to create database\n");
5689 r
= package_from_db(hdb
, &hpkg
);
5690 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
5692 skip("Not enough rights to perform tests\n");
5693 MsiSetInternalUI(uilevel
, NULL
);
5694 DeleteFileA(msifile
);
5697 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
5699 MsiCloseHandle(hdb
);
5703 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5704 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5705 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5707 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
5711 r
= MsiGetPropertyA(hpkg
, "UILevel", buf
, &size
);
5712 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5713 ok( !lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5717 r
= MsiGetPropertyA(hpkg
, "DATABASE", buf
, &size
);
5718 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5719 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5721 RegOpenKeyA(HKEY_CURRENT_USER
, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1
);
5722 RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access
, &hkey2
);
5727 if (RegQueryValueExA(hkey1
, "DefName", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5731 RegQueryValueExA(hkey2
, "RegisteredOwner", NULL
, &type
, (LPBYTE
)path
, &size
);
5736 r
= MsiGetPropertyA(hpkg
, "USERNAME", buf
, &size
);
5737 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5738 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5743 if (RegQueryValueExA(hkey1
, "DefCompany", NULL
, &type
, (LPBYTE
)path
, &size
) != ERROR_SUCCESS
)
5747 RegQueryValueExA(hkey2
, "RegisteredOrganization", NULL
, &type
, (LPBYTE
)path
, &size
);
5754 r
= MsiGetPropertyA(hpkg
, "COMPANYNAME", buf
, &size
);
5755 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5756 ok( !lstrcmpA(buf
, path
), "Expected %s, got %s\n", path
, buf
);
5761 r
= MsiGetPropertyA(hpkg
, "VersionDatabase", buf
, &size
);
5762 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5763 trace("VersionDatabase = %s\n", buf
);
5767 r
= MsiGetPropertyA(hpkg
, "VersionMsi", buf
, &size
);
5768 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5769 trace("VersionMsi = %s\n", buf
);
5773 r
= MsiGetPropertyA(hpkg
, "Date", buf
, &size
);
5774 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5775 trace("Date = %s\n", buf
);
5779 r
= MsiGetPropertyA(hpkg
, "Time", buf
, &size
);
5780 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5781 trace("Time = %s\n", buf
);
5785 r
= MsiGetPropertyA(hpkg
, "PackageCode", buf
, &size
);
5786 ok( r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5787 trace("PackageCode = %s\n", buf
);
5791 r
= MsiGetPropertyA(hpkg
, "ComputerName", buf
, &size
);
5792 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5793 trace("ComputerName = %s\n", buf
);
5795 langid
= GetUserDefaultLangID();
5796 sprintf(path
, "%d", langid
);
5800 r
= MsiGetPropertyA(hpkg
, "UserLanguageID", buf
, &size
);
5801 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5802 ok( !lstrcmpA(buf
, path
), "Expected \"%s\", got \"%s\"\n", path
, buf
);
5804 res
= GetSystemMetrics(SM_CXSCREEN
);
5807 r
= MsiGetPropertyA(hpkg
, "ScreenX", buf
, &size
);
5808 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5809 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5811 res
= GetSystemMetrics(SM_CYSCREEN
);
5814 r
= MsiGetPropertyA(hpkg
, "ScreenY", buf
, &size
);
5815 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", r
);
5816 ok(atol(buf
) == res
, "Expected %d, got %ld\n", res
, atol(buf
));
5818 if (pGetSystemInfo
&& pSHGetFolderPathA
)
5820 pGetSystemInfo(&si
);
5821 if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
5825 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5826 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5827 ok(buf
[0], "property not set\n");
5831 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5832 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5833 ok(buf
[0], "property not set\n");
5837 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5838 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5839 ok(buf
[0], "property not set\n");
5843 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5844 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5845 GetSystemDirectoryA(path
, MAX_PATH
);
5846 if (size
) buf
[size
- 1] = 0;
5847 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5851 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5852 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5853 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5854 if (size
) buf
[size
- 1] = 0;
5855 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5859 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
5860 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5861 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
5862 if (size
) buf
[size
- 1] = 0;
5863 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5867 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5868 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5869 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
5870 if (size
) buf
[size
- 1] = 0;
5871 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5875 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
5876 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5877 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
5878 if (size
) buf
[size
- 1] = 0;
5879 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5883 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5884 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5885 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
5886 if (size
) buf
[size
- 1] = 0;
5887 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5891 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5892 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5893 ok(buf
[0], "property not set\n");
5895 else if (S(U(si
)).wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_INTEL
)
5901 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5902 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5903 ok(buf
[0], "property not set\n");
5907 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5908 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5909 ok(!buf
[0], "property set\n");
5913 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5914 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5915 ok(!buf
[0], "property set\n");
5919 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5920 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5921 ok(!buf
[0], "property set\n");
5925 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5926 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5927 GetSystemDirectoryA(path
, MAX_PATH
);
5928 if (size
) buf
[size
- 1] = 0;
5929 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5933 r
= MsiGetPropertyA(hpkg
, "ProgramFiles64Folder", buf
, &size
);
5934 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5935 ok(!buf
[0], "property set\n");
5939 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
5940 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5941 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES
, NULL
, 0, path
);
5942 if (size
) buf
[size
- 1] = 0;
5943 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5947 r
= MsiGetPropertyA(hpkg
, "CommonFiles64Folder", buf
, &size
);
5948 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5949 ok(!buf
[0], "property set\n");
5953 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
5954 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5955 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMON
, NULL
, 0, path
);
5956 if (size
) buf
[size
- 1] = 0;
5957 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5961 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
5962 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5963 ok(!buf
[0], "property set\n");
5969 r
= MsiGetPropertyA(hpkg
, "Intel", buf
, &size
);
5970 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5971 ok(buf
[0], "property not set\n");
5975 r
= MsiGetPropertyA(hpkg
, "MsiAMD64", buf
, &size
);
5976 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5977 ok(buf
[0], "property not set\n");
5981 r
= MsiGetPropertyA(hpkg
, "Msix64", buf
, &size
);
5982 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5983 ok(buf
[0], "property not set\n");
5987 r
= MsiGetPropertyA(hpkg
, "System64Folder", buf
, &size
);
5988 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5989 GetSystemDirectoryA(path
, MAX_PATH
);
5990 if (size
) buf
[size
- 1] = 0;
5991 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
5995 r
= MsiGetPropertyA(hpkg
, "SystemFolder", buf
, &size
);
5996 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
5997 pGetSystemWow64DirectoryA(path
, MAX_PATH
);
5998 if (size
) buf
[size
- 1] = 0;
5999 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6003 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder64", buf
, &size
);
6004 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6005 ok(!buf
[0], "property set\n");
6009 r
= MsiGetPropertyA(hpkg
, "ProgramFilesFolder", buf
, &size
);
6010 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6011 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILESX86
, NULL
, 0, path
);
6012 if (size
) buf
[size
- 1] = 0;
6013 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6017 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder64", buf
, &size
);
6018 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6019 ok(!buf
[0], "property set\n");
6023 r
= MsiGetPropertyA(hpkg
, "CommonFilesFolder", buf
, &size
);
6024 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6025 pSHGetFolderPathA(NULL
, CSIDL_PROGRAM_FILES_COMMONX86
, NULL
, 0, path
);
6026 if (size
) buf
[size
- 1] = 0;
6027 ok(!lstrcmpiA(path
, buf
), "expected \"%s\", got \"%s\"\n", path
, buf
);
6031 r
= MsiGetPropertyA(hpkg
, "VersionNT64", buf
, &size
);
6032 ok(r
== ERROR_SUCCESS
, "failed to get property: %d\n", r
);
6033 ok(buf
[0], "property not set\n");
6040 MsiCloseHandle(hpkg
);
6041 DeleteFileA(msifile
);
6042 MsiSetInternalUI(uilevel
, NULL
);
6045 static void test_launchconditions(void)
6051 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6053 hdb
= create_package_db();
6054 ok( hdb
, "failed to create package database\n" );
6056 r
= create_launchcondition_table( hdb
);
6057 ok( r
== ERROR_SUCCESS
, "cannot create LaunchCondition table: %d\n", r
);
6059 r
= add_launchcondition_entry( hdb
, "'X = \"1\"', 'one'" );
6060 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
6062 /* invalid condition */
6063 r
= add_launchcondition_entry( hdb
, "'X != \"1\"', 'one'" );
6064 ok( r
== ERROR_SUCCESS
, "cannot add launch condition: %d\n", r
);
6066 r
= package_from_db( hdb
, &hpkg
);
6067 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6069 skip("Not enough rights to perform tests\n");
6070 DeleteFileA(msifile
);
6073 ok( r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6075 MsiCloseHandle( hdb
);
6077 r
= MsiSetPropertyA( hpkg
, "X", "1" );
6078 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
6080 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6082 /* invalid conditions are ignored */
6083 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
6084 ok( r
== ERROR_SUCCESS
, "cost init failed\n" );
6086 /* verify LaunchConditions still does some verification */
6087 r
= MsiSetPropertyA( hpkg
, "X", "2" );
6088 ok( r
== ERROR_SUCCESS
, "failed to set property\n" );
6090 r
= MsiDoActionA( hpkg
, "LaunchConditions" );
6091 ok( r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %d\n", r
);
6093 MsiCloseHandle( hpkg
);
6094 DeleteFileA( msifile
);
6097 static void test_ccpsearch(void)
6099 MSIHANDLE hdb
, hpkg
;
6100 CHAR prop
[MAX_PATH
];
6101 DWORD size
= MAX_PATH
;
6104 hdb
= create_package_db();
6105 ok(hdb
, "failed to create package database\n");
6107 r
= create_ccpsearch_table(hdb
);
6108 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6110 r
= add_ccpsearch_entry(hdb
, "'CCP_random'");
6111 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6113 r
= add_ccpsearch_entry(hdb
, "'RMCCP_random'");
6114 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6116 r
= create_reglocator_table(hdb
);
6117 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6119 r
= add_reglocator_entry(hdb
, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
6120 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6122 r
= create_drlocator_table(hdb
);
6123 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6125 r
= add_drlocator_entry(hdb
, "'RMCCP_random', '', 'C:\\', '0'");
6126 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6128 r
= create_signature_table(hdb
);
6129 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6131 r
= package_from_db(hdb
, &hpkg
);
6132 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6134 skip("Not enough rights to perform tests\n");
6135 DeleteFileA(msifile
);
6138 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6140 MsiCloseHandle(hdb
);
6142 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6144 r
= MsiDoActionA(hpkg
, "CCPSearch");
6145 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6147 r
= MsiGetPropertyA(hpkg
, "CCP_Success", prop
, &size
);
6148 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6149 ok(!lstrcmpA(prop
, "1"), "Expected 1, got %s\n", prop
);
6151 MsiCloseHandle(hpkg
);
6152 DeleteFileA(msifile
);
6155 static void test_complocator(void)
6157 MSIHANDLE hdb
, hpkg
;
6159 CHAR prop
[MAX_PATH
];
6160 CHAR expected
[MAX_PATH
];
6161 DWORD size
= MAX_PATH
;
6163 hdb
= create_package_db();
6164 ok(hdb
, "failed to create package database\n");
6166 r
= create_appsearch_table(hdb
);
6167 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6169 r
= add_appsearch_entry(hdb
, "'ABELISAURUS', 'abelisaurus'");
6170 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6172 r
= add_appsearch_entry(hdb
, "'BACTROSAURUS', 'bactrosaurus'");
6173 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6175 r
= add_appsearch_entry(hdb
, "'CAMELOTIA', 'camelotia'");
6176 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6178 r
= add_appsearch_entry(hdb
, "'DICLONIUS', 'diclonius'");
6179 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6181 r
= add_appsearch_entry(hdb
, "'ECHINODON', 'echinodon'");
6182 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6184 r
= add_appsearch_entry(hdb
, "'FALCARIUS', 'falcarius'");
6185 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6187 r
= add_appsearch_entry(hdb
, "'GALLIMIMUS', 'gallimimus'");
6188 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6190 r
= add_appsearch_entry(hdb
, "'HAGRYPHUS', 'hagryphus'");
6191 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6193 r
= add_appsearch_entry(hdb
, "'IGUANODON', 'iguanodon'");
6194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6196 r
= add_appsearch_entry(hdb
, "'JOBARIA', 'jobaria'");
6197 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6199 r
= add_appsearch_entry(hdb
, "'KAKURU', 'kakuru'");
6200 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6202 r
= add_appsearch_entry(hdb
, "'LABOCANIA', 'labocania'");
6203 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6205 r
= add_appsearch_entry(hdb
, "'MEGARAPTOR', 'megaraptor'");
6206 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6208 r
= add_appsearch_entry(hdb
, "'NEOSODON', 'neosodon'");
6209 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6211 r
= add_appsearch_entry(hdb
, "'OLOROTITAN', 'olorotitan'");
6212 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6214 r
= add_appsearch_entry(hdb
, "'PANTYDRACO', 'pantydraco'");
6215 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6217 r
= create_complocator_table(hdb
);
6218 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6220 r
= add_complocator_entry(hdb
, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6221 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6223 r
= add_complocator_entry(hdb
, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6224 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6226 r
= add_complocator_entry(hdb
, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6227 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6229 r
= add_complocator_entry(hdb
, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6230 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6232 r
= add_complocator_entry(hdb
, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6233 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6235 r
= add_complocator_entry(hdb
, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6236 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6238 r
= add_complocator_entry(hdb
, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6239 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6241 r
= add_complocator_entry(hdb
, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6242 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6244 r
= add_complocator_entry(hdb
, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6245 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6247 r
= add_complocator_entry(hdb
, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6248 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6250 r
= add_complocator_entry(hdb
, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6251 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6253 r
= add_complocator_entry(hdb
, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6254 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6256 r
= add_complocator_entry(hdb
, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6257 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6259 r
= add_complocator_entry(hdb
, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6260 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6262 r
= add_complocator_entry(hdb
, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6263 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6265 r
= add_complocator_entry(hdb
, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6266 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6268 r
= create_signature_table(hdb
);
6269 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6271 r
= add_signature_entry(hdb
, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6272 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6274 r
= add_signature_entry(hdb
, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6275 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6277 r
= add_signature_entry(hdb
, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6278 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6280 r
= add_signature_entry(hdb
, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6281 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6283 r
= add_signature_entry(hdb
, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6284 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6286 r
= add_signature_entry(hdb
, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6287 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6289 r
= add_signature_entry(hdb
, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6290 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6292 r
= add_signature_entry(hdb
, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6293 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6295 r
= package_from_db(hdb
, &hpkg
);
6296 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6298 skip("Not enough rights to perform tests\n");
6299 DeleteFileA(msifile
);
6302 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6304 MsiCloseHandle(hdb
);
6306 create_test_file("abelisaurus");
6307 create_test_file("bactrosaurus");
6308 create_test_file("camelotia");
6309 create_test_file("diclonius");
6310 create_test_file("echinodon");
6311 create_test_file("falcarius");
6312 create_test_file("gallimimus");
6313 create_test_file("hagryphus");
6314 CreateDirectoryA("iguanodon", NULL
);
6315 CreateDirectoryA("jobaria", NULL
);
6316 CreateDirectoryA("kakuru", NULL
);
6317 CreateDirectoryA("labocania", NULL
);
6318 CreateDirectoryA("megaraptor", NULL
);
6319 CreateDirectoryA("neosodon", NULL
);
6320 CreateDirectoryA("olorotitan", NULL
);
6321 CreateDirectoryA("pantydraco", NULL
);
6323 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE
,
6324 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL
, FALSE
);
6325 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE
,
6326 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL
, FALSE
);
6327 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE
,
6328 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL
, FALSE
);
6329 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE
,
6330 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL
, FALSE
);
6331 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE
,
6332 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL
, FALSE
);
6333 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE
,
6334 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL
, FALSE
);
6335 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE
,
6336 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL
, FALSE
);
6337 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE
,
6338 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL
, FALSE
);
6340 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6342 r
= MsiDoActionA(hpkg
, "AppSearch");
6343 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6346 r
= MsiGetPropertyA(hpkg
, "ABELISAURUS", prop
, &size
);
6347 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6349 lstrcpyA(expected
, CURR_DIR
);
6350 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6351 lstrcatA(expected
, "abelisaurus");
6352 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6353 "Expected %s or empty string, got %s\n", expected
, prop
);
6356 r
= MsiGetPropertyA(hpkg
, "BACTROSAURUS", prop
, &size
);
6357 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6358 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6361 r
= MsiGetPropertyA(hpkg
, "CAMELOTIA", prop
, &size
);
6362 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6363 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6366 r
= MsiGetPropertyA(hpkg
, "DICLONIUS", prop
, &size
);
6367 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6368 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6371 r
= MsiGetPropertyA(hpkg
, "ECHINODON", prop
, &size
);
6372 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6374 lstrcpyA(expected
, CURR_DIR
);
6375 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6376 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6377 "Expected %s or empty string, got %s\n", expected
, prop
);
6380 r
= MsiGetPropertyA(hpkg
, "FALCARIUS", prop
, &size
);
6381 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6382 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6385 r
= MsiGetPropertyA(hpkg
, "GALLIMIMUS", prop
, &size
);
6386 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6387 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6390 r
= MsiGetPropertyA(hpkg
, "HAGRYPHUS", prop
, &size
);
6391 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6392 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6395 r
= MsiGetPropertyA(hpkg
, "IGUANODON", prop
, &size
);
6396 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6397 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6400 r
= MsiGetPropertyA(hpkg
, "JOBARIA", prop
, &size
);
6401 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6402 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6405 r
= MsiGetPropertyA(hpkg
, "KAKURU", prop
, &size
);
6406 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6407 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6410 r
= MsiGetPropertyA(hpkg
, "LABOCANIA", prop
, &size
);
6411 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6412 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6415 r
= MsiGetPropertyA(hpkg
, "MEGARAPTOR", prop
, &size
);
6416 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6418 lstrcpyA(expected
, CURR_DIR
);
6419 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6420 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6421 "Expected %s or empty string, got %s\n", expected
, prop
);
6424 r
= MsiGetPropertyA(hpkg
, "NEOSODON", prop
, &size
);
6425 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6427 lstrcpyA(expected
, CURR_DIR
);
6428 if (!is_root(CURR_DIR
)) lstrcatA(expected
, "\\");
6429 lstrcatA(expected
, "neosodon\\");
6430 ok(!lstrcmpA(prop
, expected
) || !lstrcmpA(prop
, ""),
6431 "Expected %s or empty string, got %s\n", expected
, prop
);
6434 r
= MsiGetPropertyA(hpkg
, "OLOROTITAN", prop
, &size
);
6435 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6436 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6439 r
= MsiGetPropertyA(hpkg
, "PANTYDRACO", prop
, &size
);
6440 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6441 ok(!lstrcmpA(prop
, ""), "Expected , got %s\n", prop
);
6443 MsiCloseHandle(hpkg
);
6444 DeleteFileA("abelisaurus");
6445 DeleteFileA("bactrosaurus");
6446 DeleteFileA("camelotia");
6447 DeleteFileA("diclonius");
6448 DeleteFileA("echinodon");
6449 DeleteFileA("falcarius");
6450 DeleteFileA("gallimimus");
6451 DeleteFileA("hagryphus");
6452 RemoveDirectoryA("iguanodon");
6453 RemoveDirectoryA("jobaria");
6454 RemoveDirectoryA("kakuru");
6455 RemoveDirectoryA("labocania");
6456 RemoveDirectoryA("megaraptor");
6457 RemoveDirectoryA("neosodon");
6458 RemoveDirectoryA("olorotitan");
6459 RemoveDirectoryA("pantydraco");
6460 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6461 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6462 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6463 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6464 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6465 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6466 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6467 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6468 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6469 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6470 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6471 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6472 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6473 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6474 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6475 MSIINSTALLCONTEXT_MACHINE
, NULL
);
6476 DeleteFileA(msifile
);
6479 static void set_suminfo_prop(MSIHANDLE db
, DWORD prop
, DWORD val
)
6484 r
= MsiGetSummaryInformationA(db
, NULL
, 1, &summary
);
6485 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6487 r
= MsiSummaryInfoSetPropertyA(summary
, prop
, VT_I4
, val
, NULL
, NULL
);
6488 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6490 r
= MsiSummaryInfoPersist(summary
);
6491 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
6493 MsiCloseHandle(summary
);
6496 static void test_MsiGetSourcePath(void)
6498 MSIHANDLE hdb
, hpkg
;
6499 CHAR path
[MAX_PATH
];
6501 CHAR subsrc
[MAX_PATH
];
6502 CHAR sub2
[MAX_PATH
];
6506 lstrcpyA(cwd
, CURR_DIR
);
6507 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
6509 lstrcpyA(subsrc
, cwd
);
6510 lstrcatA(subsrc
, "subsource");
6511 lstrcatA(subsrc
, "\\");
6513 lstrcpyA(sub2
, subsrc
);
6514 lstrcatA(sub2
, "sub2");
6515 lstrcatA(sub2
, "\\");
6517 /* uncompressed source */
6519 hdb
= create_package_db();
6520 ok( hdb
, "failed to create database\n");
6522 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
6524 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
6525 ok(r
== S_OK
, "failed\n");
6527 r
= add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6528 ok(r
== S_OK
, "failed\n");
6530 r
= add_directory_entry(hdb
, "'SubDir2', 'SubDir', 'sub2'");
6531 ok(r
== S_OK
, "failed\n");
6533 r
= MsiDatabaseCommit(hdb
);
6534 ok(r
== ERROR_SUCCESS
, "Failed to commit database\n");
6536 r
= package_from_db(hdb
, &hpkg
);
6537 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
6539 skip("Not enough rights to perform tests\n");
6540 DeleteFileA(msifile
);
6543 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6545 MsiCloseHandle(hdb
);
6547 /* invalid database handle */
6549 lstrcpyA(path
, "kiwi");
6550 r
= MsiGetSourcePathA(-1, "TARGETDIR", path
, &size
);
6551 ok(r
== ERROR_INVALID_HANDLE
,
6552 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
6553 ok(!lstrcmpA(path
, "kiwi"),
6554 "Expected path to be unchanged, got \"%s\"\n", path
);
6555 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6559 lstrcpyA(path
, "kiwi");
6560 r
= MsiGetSourcePathA(hpkg
, NULL
, path
, &size
);
6561 ok(r
== ERROR_INVALID_PARAMETER
,
6562 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6563 ok(!lstrcmpA(path
, "kiwi"),
6564 "Expected path to be unchanged, got \"%s\"\n", path
);
6565 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6567 /* empty szFolder */
6569 lstrcpyA(path
, "kiwi");
6570 r
= MsiGetSourcePathA(hpkg
, "", path
, &size
);
6571 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6572 ok(!lstrcmpA(path
, "kiwi"),
6573 "Expected path to be unchanged, got \"%s\"\n", path
);
6574 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6578 lstrcpyA(path
, "kiwi");
6579 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6580 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6581 ok(!lstrcmpA(path
, "kiwi"),
6582 "Expected path to be unchanged, got \"%s\"\n", path
);
6583 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6586 lstrcpyA(path
, "kiwi");
6587 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6588 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6589 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6590 ok(size
== 0, "Expected 0, got %d\n", size
);
6593 lstrcpyA(path
, "kiwi");
6594 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6595 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6596 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6597 ok(size
== 0, "Expected 0, got %d\n", size
);
6601 lstrcpyA(path
, "kiwi");
6602 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6603 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6604 ok(!lstrcmpA(path
, "kiwi"),
6605 "Expected path to be unchanged, got \"%s\"\n", path
);
6606 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6610 lstrcpyA(path
, "kiwi");
6611 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6612 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6613 ok(!lstrcmpA(path
, "kiwi"),
6614 "Expected path to be unchanged, got \"%s\"\n", path
);
6615 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6617 /* source path does not exist, but the property exists */
6619 lstrcpyA(path
, "kiwi");
6620 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6621 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6622 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6623 ok(size
== 0, "Expected 0, got %d\n", size
);
6626 lstrcpyA(path
, "kiwi");
6627 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6628 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6629 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
6630 ok(size
== 0, "Expected 0, got %d\n", size
);
6634 lstrcpyA(path
, "kiwi");
6635 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6636 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6637 ok(!lstrcmpA(path
, "kiwi"),
6638 "Expected path to be unchanged, got \"%s\"\n", path
);
6639 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6643 lstrcpyA(path
, "kiwi");
6644 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6645 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6646 ok(!lstrcmpA(path
, "kiwi"),
6647 "Expected path to be unchanged, got \"%s\"\n", path
);
6648 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6650 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
6652 r
= MsiDoActionA(hpkg
, "CostInitialize");
6653 ok(r
== ERROR_SUCCESS
, "cost init failed\n");
6655 /* try TARGETDIR after CostInitialize */
6657 lstrcpyA(path
, "kiwi");
6658 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6659 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6660 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6661 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6663 /* try SourceDir after CostInitialize */
6665 lstrcpyA(path
, "kiwi");
6666 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6667 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6668 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6669 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6671 /* try SOURCEDIR after CostInitialize */
6673 lstrcpyA(path
, "kiwi");
6674 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6675 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6676 ok(!lstrcmpA(path
, "kiwi"),
6677 "Expected path to be unchanged, got \"%s\"\n", path
);
6678 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6680 /* source path does not exist, but the property exists */
6682 lstrcpyA(path
, "kiwi");
6683 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6684 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6685 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6686 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6689 lstrcpyA(path
, "kiwi");
6690 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6691 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6692 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6693 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6695 /* try SubDir after CostInitialize */
6697 lstrcpyA(path
, "kiwi");
6698 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6699 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6700 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6701 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6703 /* try SubDir2 after CostInitialize */
6705 lstrcpyA(path
, "kiwi");
6706 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6707 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6708 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6709 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6711 r
= MsiDoActionA(hpkg
, "ResolveSource");
6712 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6714 /* try TARGETDIR after ResolveSource */
6716 lstrcpyA(path
, "kiwi");
6717 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6718 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6719 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6720 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6722 /* try SourceDir after ResolveSource */
6724 lstrcpyA(path
, "kiwi");
6725 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6726 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6727 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6728 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6730 /* try SOURCEDIR after ResolveSource */
6732 lstrcpyA(path
, "kiwi");
6733 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6734 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6735 ok(!lstrcmpA(path
, "kiwi"),
6736 "Expected path to be unchanged, got \"%s\"\n", path
);
6737 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6739 /* source path does not exist, but the property exists */
6741 lstrcpyA(path
, "kiwi");
6742 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6743 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6744 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6745 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6748 lstrcpyA(path
, "kiwi");
6749 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6750 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6751 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6752 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6754 /* try SubDir after ResolveSource */
6756 lstrcpyA(path
, "kiwi");
6757 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6758 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6759 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6760 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6762 /* try SubDir2 after ResolveSource */
6764 lstrcpyA(path
, "kiwi");
6765 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6766 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6767 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6768 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6770 r
= MsiDoActionA(hpkg
, "FileCost");
6771 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6773 /* try TARGETDIR after FileCost */
6775 lstrcpyA(path
, "kiwi");
6776 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6777 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6778 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6779 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6781 /* try SourceDir after FileCost */
6783 lstrcpyA(path
, "kiwi");
6784 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6785 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6786 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6787 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6789 /* try SOURCEDIR after FileCost */
6791 lstrcpyA(path
, "kiwi");
6792 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6793 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6794 ok(!lstrcmpA(path
, "kiwi"),
6795 "Expected path to be unchanged, got \"%s\"\n", path
);
6796 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6798 /* source path does not exist, but the property exists */
6800 lstrcpyA(path
, "kiwi");
6801 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6802 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6803 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6804 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6807 lstrcpyA(path
, "kiwi");
6808 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6809 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6810 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6811 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6813 /* try SubDir after FileCost */
6815 lstrcpyA(path
, "kiwi");
6816 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6817 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6818 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6819 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6821 /* try SubDir2 after FileCost */
6823 lstrcpyA(path
, "kiwi");
6824 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6825 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6826 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6827 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6829 r
= MsiDoActionA(hpkg
, "CostFinalize");
6830 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
6832 /* try TARGETDIR after CostFinalize */
6834 lstrcpyA(path
, "kiwi");
6835 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6836 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6837 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6838 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6840 /* try SourceDir after CostFinalize */
6842 lstrcpyA(path
, "kiwi");
6843 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6844 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6845 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6846 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6848 /* try SOURCEDIR after CostFinalize */
6850 lstrcpyA(path
, "kiwi");
6851 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6852 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6853 ok(!lstrcmpA(path
, "kiwi"),
6854 "Expected path to be unchanged, got \"%s\"\n", path
);
6855 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6857 /* source path does not exist, but the property exists */
6859 lstrcpyA(path
, "kiwi");
6860 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
6861 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6862 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6863 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6866 lstrcpyA(path
, "kiwi");
6867 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
6868 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6869 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6870 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6872 /* try SubDir after CostFinalize */
6874 lstrcpyA(path
, "kiwi");
6875 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
6876 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6877 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
6878 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
6880 /* try SubDir2 after CostFinalize */
6882 lstrcpyA(path
, "kiwi");
6883 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
6884 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6885 ok(!lstrcmpA(path
, sub2
), "Expected \"%s\", got \"%s\"\n", sub2
, path
);
6886 ok(size
== lstrlenA(sub2
), "Expected %d, got %d\n", lstrlenA(sub2
), size
);
6888 /* nonexistent directory */
6890 lstrcpyA(path
, "kiwi");
6891 r
= MsiGetSourcePathA(hpkg
, "IDontExist", path
, &size
);
6892 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6893 ok(!lstrcmpA(path
, "kiwi"),
6894 "Expected path to be unchanged, got \"%s\"\n", path
);
6895 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6897 /* NULL szPathBuf */
6899 r
= MsiGetSourcePathA(hpkg
, "SourceDir", NULL
, &size
);
6900 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6901 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6903 /* NULL pcchPathBuf */
6904 lstrcpyA(path
, "kiwi");
6905 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, NULL
);
6906 ok(r
== ERROR_INVALID_PARAMETER
,
6907 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
6908 ok(!lstrcmpA(path
, "kiwi"),
6909 "Expected path to be unchanged, got \"%s\"\n", path
);
6911 /* pcchPathBuf is 0 */
6913 lstrcpyA(path
, "kiwi");
6914 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6915 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6916 ok(!lstrcmpA(path
, "kiwi"),
6917 "Expected path to be unchanged, got \"%s\"\n", path
);
6918 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6920 /* pcchPathBuf does not have room for NULL terminator */
6921 size
= lstrlenA(cwd
);
6922 lstrcpyA(path
, "kiwi");
6923 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6924 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
6925 ok(!strncmp(path
, cwd
, lstrlenA(cwd
) - 1),
6926 "Expected path with no backslash, got \"%s\"\n", path
);
6927 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6929 /* pcchPathBuf has room for NULL terminator */
6930 size
= lstrlenA(cwd
) + 1;
6931 lstrcpyA(path
, "kiwi");
6932 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6933 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6934 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
6935 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
6937 /* remove property */
6938 r
= MsiSetPropertyA(hpkg
, "SourceDir", NULL
);
6939 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6941 /* try SourceDir again */
6943 lstrcpyA(path
, "kiwi");
6944 r
= MsiGetSourcePathA(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
);
6949 /* set property to a valid directory */
6950 r
= MsiSetPropertyA(hpkg
, "SOURCEDIR", cwd
);
6951 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6953 /* try SOURCEDIR again */
6955 lstrcpyA(path
, "kiwi");
6956 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6957 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6958 ok(!lstrcmpA(path
, "kiwi"),
6959 "Expected path to be unchanged, got \"%s\"\n", path
);
6960 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6962 MsiCloseHandle(hpkg
);
6964 /* compressed source */
6966 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
6967 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6969 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeCompressed
);
6971 r
= package_from_db(hdb
, &hpkg
);
6972 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
6976 lstrcpyA(path
, "kiwi");
6977 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
6978 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6979 ok(!lstrcmpA(path
, "kiwi"),
6980 "Expected path to be unchanged, got \"%s\"\n", path
);
6981 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6985 lstrcpyA(path
, "kiwi");
6986 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
6987 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6988 ok(!lstrcmpA(path
, "kiwi"),
6989 "Expected path to be unchanged, got \"%s\"\n", path
);
6990 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
6994 lstrcpyA(path
, "kiwi");
6995 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
6996 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
6997 ok(!lstrcmpA(path
, "kiwi"),
6998 "Expected path to be unchanged, got \"%s\"\n", path
);
6999 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7001 /* source path nor the property exist */
7003 lstrcpyA(path
, "kiwi");
7004 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7005 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7006 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7007 ok(size
== 0, "Expected 0, got %d\n", size
);
7010 lstrcpyA(path
, "kiwi");
7011 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7012 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7013 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7014 ok(size
== 0, "Expected 0, got %d\n", size
);
7018 lstrcpyA(path
, "kiwi");
7019 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7020 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7021 ok(!lstrcmpA(path
, "kiwi"),
7022 "Expected path to be unchanged, got \"%s\"\n", path
);
7023 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7027 lstrcpyA(path
, "kiwi");
7028 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7029 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7030 ok(!lstrcmpA(path
, "kiwi"),
7031 "Expected path to be unchanged, got \"%s\"\n", path
);
7032 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7034 r
= MsiDoActionA(hpkg
, "CostInitialize");
7035 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7037 /* try TARGETDIR after CostInitialize */
7039 lstrcpyA(path
, "kiwi");
7040 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7041 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7042 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7043 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7045 /* try SourceDir after CostInitialize */
7047 lstrcpyA(path
, "kiwi");
7048 r
= MsiGetSourcePathA(hpkg
, "SourceDir", 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 CostInitialize */
7055 lstrcpyA(path
, "kiwi");
7056 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7059 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7060 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7061 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7064 /* source path does not exist, but the property exists */
7066 lstrcpyA(path
, "kiwi");
7067 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7068 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7069 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7070 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7073 lstrcpyA(path
, "kiwi");
7074 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7075 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7076 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7077 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7079 /* try SubDir after CostInitialize */
7081 lstrcpyA(path
, "kiwi");
7082 r
= MsiGetSourcePathA(hpkg
, "SubDir", 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 SubDir2 after CostInitialize */
7089 lstrcpyA(path
, "kiwi");
7090 r
= MsiGetSourcePathA(hpkg
, "SubDir2", 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 r
= MsiDoActionA(hpkg
, "ResolveSource");
7096 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7098 /* try TARGETDIR after ResolveSource */
7100 lstrcpyA(path
, "kiwi");
7101 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7102 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7103 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7104 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7106 /* try SourceDir after ResolveSource */
7108 lstrcpyA(path
, "kiwi");
7109 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7111 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7112 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7114 /* try SOURCEDIR after ResolveSource */
7116 lstrcpyA(path
, "kiwi");
7117 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7120 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7121 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7122 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7125 /* source path and the property exist */
7127 lstrcpyA(path
, "kiwi");
7128 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7129 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7130 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7131 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7134 lstrcpyA(path
, "kiwi");
7135 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7136 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7137 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7138 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7140 /* try SubDir after ResolveSource */
7142 lstrcpyA(path
, "kiwi");
7143 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7144 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7145 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7146 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7148 /* try SubDir2 after ResolveSource */
7150 lstrcpyA(path
, "kiwi");
7151 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7152 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7153 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7154 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7156 r
= MsiDoActionA(hpkg
, "FileCost");
7157 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7159 /* try TARGETDIR after CostFinalize */
7161 lstrcpyA(path
, "kiwi");
7162 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7163 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7164 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7165 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7167 /* try SourceDir after CostFinalize */
7169 lstrcpyA(path
, "kiwi");
7170 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7171 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7172 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7173 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7175 /* try SOURCEDIR after CostFinalize */
7177 lstrcpyA(path
, "kiwi");
7178 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7181 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7182 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7183 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7186 /* source path and the property exist */
7188 lstrcpyA(path
, "kiwi");
7189 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7190 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7191 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7192 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7195 lstrcpyA(path
, "kiwi");
7196 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7197 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7198 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7199 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7201 /* try SubDir after CostFinalize */
7203 lstrcpyA(path
, "kiwi");
7204 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7205 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7206 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7207 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7209 /* try SubDir2 after CostFinalize */
7211 lstrcpyA(path
, "kiwi");
7212 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7213 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7214 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7215 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7217 r
= MsiDoActionA(hpkg
, "CostFinalize");
7218 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7220 /* try TARGETDIR after CostFinalize */
7222 lstrcpyA(path
, "kiwi");
7223 r
= MsiGetSourcePathA(hpkg
, "TARGETDIR", path
, &size
);
7224 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7225 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7226 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7228 /* try SourceDir after CostFinalize */
7230 lstrcpyA(path
, "kiwi");
7231 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7232 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7233 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7234 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7236 /* try SOURCEDIR after CostFinalize */
7238 lstrcpyA(path
, "kiwi");
7239 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7242 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7243 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7244 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7247 /* source path and the property exist */
7249 lstrcpyA(path
, "kiwi");
7250 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7251 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7252 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7253 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7256 lstrcpyA(path
, "kiwi");
7257 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7258 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7259 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7260 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7262 /* try SubDir after CostFinalize */
7264 lstrcpyA(path
, "kiwi");
7265 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7266 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7267 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7268 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7270 /* try SubDir2 after CostFinalize */
7272 lstrcpyA(path
, "kiwi");
7273 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7274 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7275 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7276 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7278 MsiCloseHandle(hpkg
);
7279 DeleteFileA(msifile
);
7282 static void test_shortlongsource(void)
7284 MSIHANDLE hdb
, hpkg
;
7285 CHAR path
[MAX_PATH
];
7287 CHAR subsrc
[MAX_PATH
];
7291 lstrcpyA(cwd
, CURR_DIR
);
7292 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
7294 lstrcpyA(subsrc
, cwd
);
7295 lstrcatA(subsrc
, "long");
7296 lstrcatA(subsrc
, "\\");
7298 /* long file names */
7300 hdb
= create_package_db();
7301 ok( hdb
, "failed to create database\n");
7303 set_suminfo_prop(hdb
, PID_WORDCOUNT
, 0);
7305 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7306 ok(r
== S_OK
, "failed\n");
7308 r
= add_directory_entry(hdb
, "'SubDir', 'TARGETDIR', 'short|long'");
7309 ok(r
== S_OK
, "failed\n");
7311 /* CostInitialize:short */
7312 r
= add_directory_entry(hdb
, "'SubDir2', 'TARGETDIR', 'one|two'");
7313 ok(r
== S_OK
, "failed\n");
7315 /* CostInitialize:long */
7316 r
= add_directory_entry(hdb
, "'SubDir3', 'TARGETDIR', 'three|four'");
7317 ok(r
== S_OK
, "failed\n");
7319 /* FileCost:short */
7320 r
= add_directory_entry(hdb
, "'SubDir4', 'TARGETDIR', 'five|six'");
7321 ok(r
== S_OK
, "failed\n");
7324 r
= add_directory_entry(hdb
, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7325 ok(r
== S_OK
, "failed\n");
7327 /* CostFinalize:short */
7328 r
= add_directory_entry(hdb
, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7329 ok(r
== S_OK
, "failed\n");
7331 /* CostFinalize:long */
7332 r
= add_directory_entry(hdb
, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7333 ok(r
== S_OK
, "failed\n");
7335 MsiDatabaseCommit(hdb
);
7337 r
= package_from_db(hdb
, &hpkg
);
7338 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7340 skip("Not enough rights to perform tests\n");
7341 DeleteFileA(msifile
);
7344 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7346 MsiCloseHandle(hdb
);
7348 CreateDirectoryA("one", NULL
);
7349 CreateDirectoryA("four", NULL
);
7351 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7353 r
= MsiDoActionA(hpkg
, "CostInitialize");
7354 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7356 CreateDirectoryA("five", NULL
);
7357 CreateDirectoryA("eight", NULL
);
7359 r
= MsiDoActionA(hpkg
, "FileCost");
7360 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7362 CreateDirectoryA("nine", NULL
);
7363 CreateDirectoryA("twelve", NULL
);
7365 r
= MsiDoActionA(hpkg
, "CostFinalize");
7366 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7368 /* neither short nor long source directories exist */
7370 lstrcpyA(path
, "kiwi");
7371 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7372 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7373 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7374 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7376 CreateDirectoryA("short", NULL
);
7378 /* short source directory exists */
7380 lstrcpyA(path
, "kiwi");
7381 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7382 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7383 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7384 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7386 CreateDirectoryA("long", NULL
);
7388 /* both short and long source directories exist */
7390 lstrcpyA(path
, "kiwi");
7391 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7392 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7393 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7394 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7396 lstrcpyA(subsrc
, cwd
);
7397 lstrcatA(subsrc
, "two");
7398 lstrcatA(subsrc
, "\\");
7400 /* short dir exists before CostInitialize */
7402 lstrcpyA(path
, "kiwi");
7403 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7404 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7405 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7406 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7408 lstrcpyA(subsrc
, cwd
);
7409 lstrcatA(subsrc
, "four");
7410 lstrcatA(subsrc
, "\\");
7412 /* long dir exists before CostInitialize */
7414 lstrcpyA(path
, "kiwi");
7415 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7416 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7417 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7418 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7420 lstrcpyA(subsrc
, cwd
);
7421 lstrcatA(subsrc
, "six");
7422 lstrcatA(subsrc
, "\\");
7424 /* short dir exists before FileCost */
7426 lstrcpyA(path
, "kiwi");
7427 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7428 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7429 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7430 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7432 lstrcpyA(subsrc
, cwd
);
7433 lstrcatA(subsrc
, "eight");
7434 lstrcatA(subsrc
, "\\");
7436 /* long dir exists before FileCost */
7438 lstrcpyA(path
, "kiwi");
7439 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7440 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7441 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7442 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7444 lstrcpyA(subsrc
, cwd
);
7445 lstrcatA(subsrc
, "ten");
7446 lstrcatA(subsrc
, "\\");
7448 /* short dir exists before CostFinalize */
7450 lstrcpyA(path
, "kiwi");
7451 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7452 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7453 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7454 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7456 lstrcpyA(subsrc
, cwd
);
7457 lstrcatA(subsrc
, "twelve");
7458 lstrcatA(subsrc
, "\\");
7460 /* long dir exists before CostFinalize */
7462 lstrcpyA(path
, "kiwi");
7463 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7464 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7465 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7466 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7468 MsiCloseHandle(hpkg
);
7469 RemoveDirectoryA("short");
7470 RemoveDirectoryA("long");
7471 RemoveDirectoryA("one");
7472 RemoveDirectoryA("four");
7473 RemoveDirectoryA("five");
7474 RemoveDirectoryA("eight");
7475 RemoveDirectoryA("nine");
7476 RemoveDirectoryA("twelve");
7478 /* short file names */
7480 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_DIRECT
, &hdb
);
7481 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7483 set_suminfo_prop(hdb
, PID_WORDCOUNT
, msidbSumInfoSourceTypeSFN
);
7485 r
= package_from_db(hdb
, &hpkg
);
7486 ok(r
== ERROR_SUCCESS
, "failed to create package %u\n", r
);
7488 MsiCloseHandle(hdb
);
7490 CreateDirectoryA("one", NULL
);
7491 CreateDirectoryA("four", NULL
);
7493 r
= MsiDoActionA(hpkg
, "CostInitialize");
7494 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7496 CreateDirectoryA("five", NULL
);
7497 CreateDirectoryA("eight", NULL
);
7499 r
= MsiDoActionA(hpkg
, "FileCost");
7500 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7502 CreateDirectoryA("nine", NULL
);
7503 CreateDirectoryA("twelve", NULL
);
7505 r
= MsiDoActionA(hpkg
, "CostFinalize");
7506 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7508 lstrcpyA(subsrc
, cwd
);
7509 lstrcatA(subsrc
, "short");
7510 lstrcatA(subsrc
, "\\");
7512 /* neither short nor long source directories exist */
7514 lstrcpyA(path
, "kiwi");
7515 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7516 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7517 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7518 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7520 CreateDirectoryA("short", NULL
);
7522 /* short source directory exists */
7524 lstrcpyA(path
, "kiwi");
7525 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7526 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7527 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7528 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7530 CreateDirectoryA("long", NULL
);
7532 /* both short and long source directories exist */
7534 lstrcpyA(path
, "kiwi");
7535 r
= MsiGetSourcePathA(hpkg
, "SubDir", path
, &size
);
7536 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7537 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7538 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7540 lstrcpyA(subsrc
, cwd
);
7541 lstrcatA(subsrc
, "one");
7542 lstrcatA(subsrc
, "\\");
7544 /* short dir exists before CostInitialize */
7546 lstrcpyA(path
, "kiwi");
7547 r
= MsiGetSourcePathA(hpkg
, "SubDir2", path
, &size
);
7548 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7549 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7550 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7552 lstrcpyA(subsrc
, cwd
);
7553 lstrcatA(subsrc
, "three");
7554 lstrcatA(subsrc
, "\\");
7556 /* long dir exists before CostInitialize */
7558 lstrcpyA(path
, "kiwi");
7559 r
= MsiGetSourcePathA(hpkg
, "SubDir3", path
, &size
);
7560 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7561 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7562 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7564 lstrcpyA(subsrc
, cwd
);
7565 lstrcatA(subsrc
, "five");
7566 lstrcatA(subsrc
, "\\");
7568 /* short dir exists before FileCost */
7570 lstrcpyA(path
, "kiwi");
7571 r
= MsiGetSourcePathA(hpkg
, "SubDir4", path
, &size
);
7572 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7573 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7574 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7576 lstrcpyA(subsrc
, cwd
);
7577 lstrcatA(subsrc
, "seven");
7578 lstrcatA(subsrc
, "\\");
7580 /* long dir exists before FileCost */
7582 lstrcpyA(path
, "kiwi");
7583 r
= MsiGetSourcePathA(hpkg
, "SubDir5", path
, &size
);
7584 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7585 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7586 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7588 lstrcpyA(subsrc
, cwd
);
7589 lstrcatA(subsrc
, "nine");
7590 lstrcatA(subsrc
, "\\");
7592 /* short dir exists before CostFinalize */
7594 lstrcpyA(path
, "kiwi");
7595 r
= MsiGetSourcePathA(hpkg
, "SubDir6", path
, &size
);
7596 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7597 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7598 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7600 lstrcpyA(subsrc
, cwd
);
7601 lstrcatA(subsrc
, "eleven");
7602 lstrcatA(subsrc
, "\\");
7604 /* long dir exists before CostFinalize */
7606 lstrcpyA(path
, "kiwi");
7607 r
= MsiGetSourcePathA(hpkg
, "SubDir7", path
, &size
);
7608 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7609 ok(!lstrcmpA(path
, subsrc
), "Expected \"%s\", got \"%s\"\n", subsrc
, path
);
7610 ok(size
== lstrlenA(subsrc
), "Expected %d, got %d\n", lstrlenA(subsrc
), size
);
7612 MsiCloseHandle(hpkg
);
7613 RemoveDirectoryA("short");
7614 RemoveDirectoryA("long");
7615 RemoveDirectoryA("one");
7616 RemoveDirectoryA("four");
7617 RemoveDirectoryA("five");
7618 RemoveDirectoryA("eight");
7619 RemoveDirectoryA("nine");
7620 RemoveDirectoryA("twelve");
7621 DeleteFileA(msifile
);
7624 static void test_sourcedir(void)
7626 MSIHANDLE hdb
, hpkg
;
7628 CHAR path
[MAX_PATH
];
7630 CHAR subsrc
[MAX_PATH
];
7634 lstrcpyA(cwd
, CURR_DIR
);
7635 if (!is_root(CURR_DIR
)) lstrcatA(cwd
, "\\");
7637 lstrcpyA(subsrc
, cwd
);
7638 lstrcatA(subsrc
, "long");
7639 lstrcatA(subsrc
, "\\");
7641 hdb
= create_package_db();
7642 ok( hdb
, "failed to create database\n");
7644 r
= add_directory_entry(hdb
, "'TARGETDIR', '', 'SourceDir'");
7645 ok(r
== S_OK
, "failed\n");
7647 sprintf(package
, "#%u", hdb
);
7648 r
= MsiOpenPackageA(package
, &hpkg
);
7649 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
7651 skip("Not enough rights to perform tests\n");
7654 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7656 /* properties only */
7658 /* SourceDir prop */
7660 lstrcpyA(path
, "kiwi");
7661 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7662 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7663 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7664 ok(size
== 0, "Expected 0, got %d\n", size
);
7666 /* SOURCEDIR prop */
7668 lstrcpyA(path
, "kiwi");
7669 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7670 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7671 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7672 ok(size
== 0, "Expected 0, got %d\n", size
);
7674 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
7676 r
= MsiDoActionA(hpkg
, "CostInitialize");
7677 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7679 /* SourceDir after CostInitialize */
7681 lstrcpyA(path
, "kiwi");
7682 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7683 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7684 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7685 ok(size
== 0, "Expected 0, got %d\n", size
);
7687 /* SOURCEDIR after CostInitialize */
7689 lstrcpyA(path
, "kiwi");
7690 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7691 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7692 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7693 ok(size
== 0, "Expected 0, got %d\n", size
);
7695 r
= MsiDoActionA(hpkg
, "FileCost");
7696 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7698 /* SourceDir after FileCost */
7700 lstrcpyA(path
, "kiwi");
7701 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7702 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7703 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7704 ok(size
== 0, "Expected 0, got %d\n", size
);
7706 /* SOURCEDIR after FileCost */
7708 lstrcpyA(path
, "kiwi");
7709 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7710 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7711 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7712 ok(size
== 0, "Expected 0, got %d\n", size
);
7714 r
= MsiDoActionA(hpkg
, "CostFinalize");
7715 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7717 /* SourceDir after CostFinalize */
7719 lstrcpyA(path
, "kiwi");
7720 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7721 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7722 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7723 ok(size
== 0, "Expected 0, got %d\n", size
);
7725 /* SOURCEDIR after CostFinalize */
7727 lstrcpyA(path
, "kiwi");
7728 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7729 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7730 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7731 ok(size
== 0, "Expected 0, got %d\n", size
);
7734 lstrcpyA(path
, "kiwi");
7735 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7736 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7737 ok(!lstrcmpA(path
, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path
);
7738 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
7740 /* SOURCEDIR after calling MsiGetSourcePath */
7742 lstrcpyA(path
, "kiwi");
7743 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7744 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7746 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7747 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7750 r
= MsiDoActionA(hpkg
, "ResolveSource");
7751 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7753 /* SourceDir after ResolveSource */
7755 lstrcpyA(path
, "kiwi");
7756 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7757 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7758 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7759 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7761 /* SOURCEDIR after ResolveSource */
7763 lstrcpyA(path
, "kiwi");
7764 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7765 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7766 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7767 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7771 lstrcpyA(path
, "kiwi");
7772 r
= MsiGetPropertyA(hpkg
, "SoUrCeDiR", path
, &size
);
7773 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7774 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7775 ok(size
== 0, "Expected 0, got %d\n", size
);
7777 MsiCloseHandle(hpkg
);
7779 /* reset the package state */
7780 sprintf(package
, "#%i", hdb
);
7781 r
= MsiOpenPackageA(package
, &hpkg
);
7782 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7784 /* test how MsiGetSourcePath affects the properties */
7786 /* SourceDir prop */
7788 lstrcpyA(path
, "kiwi");
7789 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7790 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7793 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7794 ok(size
== 0, "Expected 0, got %d\n", size
);
7798 lstrcpyA(path
, "kiwi");
7799 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7800 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7801 ok(!lstrcmpA(path
, "kiwi"),
7802 "Expected path to be unchanged, got \"%s\"\n", path
);
7803 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7805 /* SourceDir after MsiGetSourcePath */
7807 lstrcpyA(path
, "kiwi");
7808 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7809 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7812 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7813 ok(size
== 0, "Expected 0, got %d\n", size
);
7816 /* SOURCEDIR prop */
7818 lstrcpyA(path
, "kiwi");
7819 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7820 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7823 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7824 ok(size
== 0, "Expected 0, got %d\n", size
);
7828 lstrcpyA(path
, "kiwi");
7829 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7830 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7831 ok(!lstrcmpA(path
, "kiwi"),
7832 "Expected path to be unchanged, got \"%s\"\n", path
);
7833 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7835 /* SOURCEDIR prop after MsiGetSourcePath */
7837 lstrcpyA(path
, "kiwi");
7838 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7839 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7842 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7843 ok(size
== 0, "Expected 0, got %d\n", size
);
7846 r
= MsiDoActionA(hpkg
, "CostInitialize");
7847 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7849 /* SourceDir after CostInitialize */
7851 lstrcpyA(path
, "kiwi");
7852 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7853 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7856 ok(!lstrcmpA(path
, ""), "Expected \"\", got \"%s\"\n", path
);
7857 ok(size
== 0, "Expected 0, got %d\n", size
);
7861 lstrcpyA(path
, "kiwi");
7862 r
= MsiGetSourcePathA(hpkg
, "SourceDir", path
, &size
);
7863 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7864 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7865 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7867 /* SourceDir after MsiGetSourcePath */
7869 lstrcpyA(path
, "kiwi");
7870 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7871 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7872 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7873 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7875 /* SOURCEDIR after CostInitialize */
7877 lstrcpyA(path
, "kiwi");
7878 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7879 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7880 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7881 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7883 /* SOURCEDIR source path still does not exist */
7885 lstrcpyA(path
, "kiwi");
7886 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7887 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7888 ok(!lstrcmpA(path
, "kiwi"),
7889 "Expected path to be unchanged, got \"%s\"\n", path
);
7890 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7892 r
= MsiDoActionA(hpkg
, "FileCost");
7893 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7895 /* SourceDir after FileCost */
7897 lstrcpyA(path
, "kiwi");
7898 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7899 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7900 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7901 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7903 /* SOURCEDIR after FileCost */
7905 lstrcpyA(path
, "kiwi");
7906 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7907 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7908 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7909 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7911 /* SOURCEDIR source path still does not exist */
7913 lstrcpyA(path
, "kiwi");
7914 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7915 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7916 ok(!lstrcmpA(path
, "kiwi"),
7917 "Expected path to be unchanged, got \"%s\"\n", path
);
7918 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7920 r
= MsiDoActionA(hpkg
, "CostFinalize");
7921 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7923 /* SourceDir after CostFinalize */
7925 lstrcpyA(path
, "kiwi");
7926 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7927 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7928 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7929 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7931 /* SOURCEDIR after CostFinalize */
7933 lstrcpyA(path
, "kiwi");
7934 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7935 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7936 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7937 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7939 /* SOURCEDIR source path still does not exist */
7941 lstrcpyA(path
, "kiwi");
7942 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7943 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7944 ok(!lstrcmpA(path
, "kiwi"),
7945 "Expected path to be unchanged, got \"%s\"\n", path
);
7946 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7948 r
= MsiDoActionA(hpkg
, "ResolveSource");
7949 ok(r
== ERROR_SUCCESS
, "file cost failed\n");
7951 /* SourceDir after ResolveSource */
7953 lstrcpyA(path
, "kiwi");
7954 r
= MsiGetPropertyA(hpkg
, "SourceDir", path
, &size
);
7955 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7956 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7957 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7959 /* SOURCEDIR after ResolveSource */
7961 lstrcpyA(path
, "kiwi");
7962 r
= MsiGetPropertyA(hpkg
, "SOURCEDIR", path
, &size
);
7963 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7964 ok(!lstrcmpA(path
, cwd
), "Expected \"%s\", got \"%s\"\n", cwd
, path
);
7965 ok(size
== lstrlenA(cwd
), "Expected %d, got %d\n", lstrlenA(cwd
), size
);
7967 /* SOURCEDIR source path still does not exist */
7969 lstrcpyA(path
, "kiwi");
7970 r
= MsiGetSourcePathA(hpkg
, "SOURCEDIR", path
, &size
);
7971 ok(r
== ERROR_DIRECTORY
, "Expected ERROR_DIRECTORY, got %d\n", r
);
7972 ok(!lstrcmpA(path
, "kiwi"),
7973 "Expected path to be unchanged, got \"%s\"\n", path
);
7974 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
7976 MsiCloseHandle(hpkg
);
7979 MsiCloseHandle(hdb
);
7980 DeleteFileA(msifile
);
7990 static const struct access_res create
[16] =
7992 { TRUE
, ERROR_SUCCESS
, TRUE
},
7993 { TRUE
, ERROR_SUCCESS
, TRUE
},
7994 { TRUE
, ERROR_SUCCESS
, FALSE
},
7995 { TRUE
, ERROR_SUCCESS
, FALSE
},
7996 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7997 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7998 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
7999 { TRUE
, ERROR_SUCCESS
, FALSE
},
8000 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8001 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8002 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8003 { TRUE
, ERROR_SUCCESS
, TRUE
},
8004 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8005 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8006 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8007 { TRUE
, ERROR_SUCCESS
, TRUE
}
8010 static const struct access_res create_commit
[16] =
8012 { TRUE
, ERROR_SUCCESS
, TRUE
},
8013 { TRUE
, ERROR_SUCCESS
, TRUE
},
8014 { TRUE
, ERROR_SUCCESS
, FALSE
},
8015 { TRUE
, ERROR_SUCCESS
, FALSE
},
8016 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8017 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8018 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8019 { TRUE
, ERROR_SUCCESS
, FALSE
},
8020 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8021 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8022 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8023 { TRUE
, ERROR_SUCCESS
, TRUE
},
8024 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8025 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8026 { FALSE
, ERROR_SHARING_VIOLATION
, FALSE
},
8027 { TRUE
, ERROR_SUCCESS
, TRUE
}
8030 static const struct access_res create_close
[16] =
8032 { TRUE
, ERROR_SUCCESS
, FALSE
},
8033 { TRUE
, ERROR_SUCCESS
, FALSE
},
8034 { TRUE
, ERROR_SUCCESS
, FALSE
},
8035 { TRUE
, ERROR_SUCCESS
, FALSE
},
8036 { TRUE
, ERROR_SUCCESS
, FALSE
},
8037 { TRUE
, ERROR_SUCCESS
, FALSE
},
8038 { TRUE
, ERROR_SUCCESS
, FALSE
},
8039 { TRUE
, ERROR_SUCCESS
, FALSE
},
8040 { TRUE
, ERROR_SUCCESS
, FALSE
},
8041 { TRUE
, ERROR_SUCCESS
, FALSE
},
8042 { TRUE
, ERROR_SUCCESS
, FALSE
},
8043 { TRUE
, ERROR_SUCCESS
, FALSE
},
8044 { TRUE
, ERROR_SUCCESS
, FALSE
},
8045 { TRUE
, ERROR_SUCCESS
, FALSE
},
8046 { TRUE
, ERROR_SUCCESS
, FALSE
},
8047 { TRUE
, ERROR_SUCCESS
}
8050 static void _test_file_access(LPCSTR file
, const struct access_res
*ares
, DWORD line
)
8052 DWORD access
= 0, share
= 0;
8057 for (i
= 0; i
< 4; i
++)
8059 if (i
== 0) access
= 0;
8060 if (i
== 1) access
= GENERIC_READ
;
8061 if (i
== 2) access
= GENERIC_WRITE
;
8062 if (i
== 3) access
= GENERIC_READ
| GENERIC_WRITE
;
8064 for (j
= 0; j
< 4; j
++)
8066 if (ares
[idx
].ignore
)
8069 if (j
== 0) share
= 0;
8070 if (j
== 1) share
= FILE_SHARE_READ
;
8071 if (j
== 2) share
= FILE_SHARE_WRITE
;
8072 if (j
== 3) share
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
8074 SetLastError(0xdeadbeef);
8075 hfile
= CreateFileA(file
, access
, share
, NULL
, OPEN_EXISTING
,
8076 FILE_ATTRIBUTE_NORMAL
, 0);
8077 lasterr
= GetLastError();
8079 ok((hfile
!= INVALID_HANDLE_VALUE
) == ares
[idx
].gothandle
,
8080 "(%d, handle, %d): Expected %d, got %d\n",
8081 line
, idx
, ares
[idx
].gothandle
,
8082 (hfile
!= INVALID_HANDLE_VALUE
));
8084 ok(lasterr
== ares
[idx
].lasterr
, "(%d, lasterr, %d): Expected %d, got %d\n",
8085 line
, idx
, ares
[idx
].lasterr
, lasterr
);
8093 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
8095 static void test_access(void)
8100 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
8101 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8103 test_file_access(msifile
, create
);
8105 r
= MsiDatabaseCommit(hdb
);
8106 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8108 test_file_access(msifile
, create_commit
);
8109 MsiCloseHandle(hdb
);
8111 test_file_access(msifile
, create_close
);
8112 DeleteFileA(msifile
);
8114 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATEDIRECT
, &hdb
);
8115 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8117 test_file_access(msifile
, create
);
8119 r
= MsiDatabaseCommit(hdb
);
8120 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8122 test_file_access(msifile
, create_commit
);
8123 MsiCloseHandle(hdb
);
8125 test_file_access(msifile
, create_close
);
8126 DeleteFileA(msifile
);
8129 static void test_emptypackage(void)
8131 MSIHANDLE hpkg
= 0, hdb
= 0, hsuminfo
= 0;
8132 MSIHANDLE hview
= 0, hrec
= 0;
8133 MSICONDITION condition
;
8134 CHAR buffer
[MAX_PATH
];
8138 r
= MsiOpenPackageA("", &hpkg
);
8139 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8141 skip("Not enough rights to perform tests\n");
8146 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8149 hdb
= MsiGetActiveDatabase(hpkg
);
8152 ok(hdb
!= 0, "Expected a valid database handle\n");
8155 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Tables`", &hview
);
8158 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8160 r
= MsiViewExecute(hview
, 0);
8163 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8166 r
= MsiViewFetch(hview
, &hrec
);
8169 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8174 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
8177 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8178 ok(!lstrcmpA(buffer
, "_Property"),
8179 "Expected \"_Property\", got \"%s\"\n", buffer
);
8182 MsiCloseHandle(hrec
);
8184 r
= MsiViewFetch(hview
, &hrec
);
8187 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8191 r
= MsiRecordGetStringA(hrec
, 1, buffer
, &size
);
8194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8195 ok(!lstrcmpA(buffer
, "#_FolderCache"),
8196 "Expected \"_Property\", got \"%s\"\n", buffer
);
8199 MsiCloseHandle(hrec
);
8200 MsiViewClose(hview
);
8201 MsiCloseHandle(hview
);
8203 condition
= MsiDatabaseIsTablePersistentA(hdb
, "_Property");
8206 ok(condition
== MSICONDITION_FALSE
,
8207 "Expected MSICONDITION_FALSE, got %d\n", condition
);
8210 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Property`", &hview
);
8213 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8215 r
= MsiViewExecute(hview
, 0);
8218 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8221 /* _Property table is not empty */
8222 r
= MsiViewFetch(hview
, &hrec
);
8225 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8228 MsiCloseHandle(hrec
);
8229 MsiViewClose(hview
);
8230 MsiCloseHandle(hview
);
8232 condition
= MsiDatabaseIsTablePersistentA(hdb
, "#_FolderCache");
8235 ok(condition
== MSICONDITION_FALSE
,
8236 "Expected MSICONDITION_FALSE, got %d\n", condition
);
8239 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `#_FolderCache`", &hview
);
8242 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8244 r
= MsiViewExecute(hview
, 0);
8247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8250 /* #_FolderCache is not empty */
8251 r
= MsiViewFetch(hview
, &hrec
);
8254 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8257 MsiCloseHandle(hrec
);
8258 MsiViewClose(hview
);
8259 MsiCloseHandle(hview
);
8261 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Streams`", &hview
);
8264 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8265 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8268 r
= MsiDatabaseOpenViewA(hdb
, "SELECT * FROM `_Storages`", &hview
);
8271 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8272 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8275 r
= MsiGetSummaryInformationA(hdb
, NULL
, 0, &hsuminfo
);
8278 ok(r
== ERROR_INSTALL_PACKAGE_INVALID
,
8279 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r
);
8282 MsiCloseHandle(hsuminfo
);
8284 r
= MsiDatabaseCommit(hdb
);
8287 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8290 MsiCloseHandle(hdb
);
8291 MsiCloseHandle(hpkg
);
8294 static void test_MsiGetProductProperty(void)
8296 MSIHANDLE hprod
, hdb
;
8298 CHAR path
[MAX_PATH
];
8299 CHAR query
[MAX_PATH
];
8300 CHAR keypath
[MAX_PATH
*2];
8301 CHAR prodcode
[MAX_PATH
];
8302 CHAR prod_squashed
[MAX_PATH
];
8303 HKEY prodkey
, userkey
, props
;
8307 REGSAM access
= KEY_ALL_ACCESS
;
8309 GetCurrentDirectoryA(MAX_PATH
, path
);
8310 lstrcatA(path
, "\\");
8312 create_test_guid(prodcode
, prod_squashed
);
8315 access
|= KEY_WOW64_64KEY
;
8317 r
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
8318 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8320 r
= MsiDatabaseCommit(hdb
);
8321 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8323 r
= set_summary_info(hdb
);
8324 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8327 "CREATE TABLE `Directory` ( "
8328 "`Directory` CHAR(255) NOT NULL, "
8329 "`Directory_Parent` CHAR(255), "
8330 "`DefaultDir` CHAR(255) NOT NULL "
8331 "PRIMARY KEY `Directory`)");
8332 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8335 "CREATE TABLE `Property` ( "
8336 "`Property` CHAR(72) NOT NULL, "
8337 "`Value` CHAR(255) "
8338 "PRIMARY KEY `Property`)");
8339 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8341 sprintf(query
, "INSERT INTO `Property` "
8342 "(`Property`, `Value`) "
8343 "VALUES( 'ProductCode', '%s' )", prodcode
);
8344 r
= run_query(hdb
, query
);
8345 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8347 r
= MsiDatabaseCommit(hdb
);
8348 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8350 MsiCloseHandle(hdb
);
8352 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
8353 lstrcatA(keypath
, prod_squashed
);
8355 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8356 if (res
== ERROR_ACCESS_DENIED
)
8358 skip("Not enough rights to perform tests\n");
8359 DeleteFileA(msifile
);
8362 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8364 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8365 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
8366 lstrcatA(keypath
, prod_squashed
);
8368 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8369 if (res
== ERROR_ACCESS_DENIED
)
8371 skip("Not enough rights to perform tests\n");
8372 RegDeleteKeyA(prodkey
, "");
8373 RegCloseKey(prodkey
);
8376 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8378 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8379 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8381 lstrcpyA(val
, path
);
8382 lstrcatA(val
, "\\");
8383 lstrcatA(val
, msifile
);
8384 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
8385 (const BYTE
*)val
, lstrlenA(val
) + 1);
8386 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8389 r
= MsiOpenProductA(prodcode
, &hprod
);
8390 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8391 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8393 /* hProduct is invalid */
8395 lstrcpyA(val
, "apple");
8396 r
= MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val
, &size
);
8397 ok(r
== ERROR_INVALID_HANDLE
,
8398 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8399 ok(!lstrcmpA(val
, "apple"),
8400 "Expected val to be unchanged, got \"%s\"\n", val
);
8401 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8403 /* szProperty is NULL */
8405 lstrcpyA(val
, "apple");
8406 r
= MsiGetProductPropertyA(hprod
, NULL
, val
, &size
);
8407 ok(r
== ERROR_INVALID_PARAMETER
,
8408 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8409 ok(!lstrcmpA(val
, "apple"),
8410 "Expected val to be unchanged, got \"%s\"\n", val
);
8411 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
8413 /* szProperty is empty */
8415 lstrcpyA(val
, "apple");
8416 r
= MsiGetProductPropertyA(hprod
, "", val
, &size
);
8417 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8418 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8419 ok(size
== 0, "Expected 0, got %d\n", size
);
8421 /* get the property */
8423 lstrcpyA(val
, "apple");
8424 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8425 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8426 ok(!lstrcmpA(val
, prodcode
),
8427 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8428 ok(size
== lstrlenA(prodcode
),
8429 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8431 /* lpValueBuf is NULL */
8433 r
= MsiGetProductPropertyA(hprod
, "ProductCode", NULL
, &size
);
8434 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8435 ok(size
== lstrlenA(prodcode
),
8436 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8438 /* pcchValueBuf is NULL */
8439 lstrcpyA(val
, "apple");
8440 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, NULL
);
8441 ok(r
== ERROR_INVALID_PARAMETER
,
8442 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8443 ok(!lstrcmpA(val
, "apple"),
8444 "Expected val to be unchanged, got \"%s\"\n", val
);
8445 ok(size
== lstrlenA(prodcode
),
8446 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8448 /* pcchValueBuf is too small */
8450 lstrcpyA(val
, "apple");
8451 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8452 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8453 ok(!strncmp(val
, prodcode
, 3),
8454 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8455 ok(size
== lstrlenA(prodcode
),
8456 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8458 /* pcchValueBuf does not leave room for NULL terminator */
8459 size
= lstrlenA(prodcode
);
8460 lstrcpyA(val
, "apple");
8461 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8462 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
8463 ok(!strncmp(val
, prodcode
, lstrlenA(prodcode
) - 1),
8464 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode
, val
);
8465 ok(size
== lstrlenA(prodcode
),
8466 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8468 /* pcchValueBuf has enough room for NULL terminator */
8469 size
= lstrlenA(prodcode
) + 1;
8470 lstrcpyA(val
, "apple");
8471 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8472 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8473 ok(!lstrcmpA(val
, prodcode
),
8474 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8475 ok(size
== lstrlenA(prodcode
),
8476 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8478 /* nonexistent property */
8480 lstrcpyA(val
, "apple");
8481 r
= MsiGetProductPropertyA(hprod
, "IDontExist", val
, &size
);
8482 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8483 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8484 ok(size
== 0, "Expected 0, got %d\n", size
);
8486 r
= MsiSetPropertyA(hprod
, "NewProperty", "value");
8487 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8489 /* non-product property set */
8491 lstrcpyA(val
, "apple");
8492 r
= MsiGetProductPropertyA(hprod
, "NewProperty", val
, &size
);
8493 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8494 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
8495 ok(size
== 0, "Expected 0, got %d\n", size
);
8497 r
= MsiSetPropertyA(hprod
, "ProductCode", "value");
8498 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8500 /* non-product property that is also a product property set */
8502 lstrcpyA(val
, "apple");
8503 r
= MsiGetProductPropertyA(hprod
, "ProductCode", val
, &size
);
8504 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8505 ok(!lstrcmpA(val
, prodcode
),
8506 "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8507 ok(size
== lstrlenA(prodcode
),
8508 "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8510 MsiCloseHandle(hprod
);
8512 RegDeleteValueA(props
, "LocalPackage");
8513 delete_key(props
, "", access
);
8515 delete_key(userkey
, "", access
);
8516 RegCloseKey(userkey
);
8517 delete_key(prodkey
, "", access
);
8518 RegCloseKey(prodkey
);
8519 DeleteFileA(msifile
);
8522 static void test_MsiSetProperty(void)
8524 MSIHANDLE hpkg
, hdb
, hrec
;
8530 r
= package_from_db(create_package_db(), &hpkg
);
8531 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8533 skip("Not enough rights to perform tests\n");
8534 DeleteFileA(msifile
);
8537 ok(r
== ERROR_SUCCESS
, "Expected a valid package %u\n", r
);
8539 /* invalid hInstall */
8540 r
= MsiSetPropertyA(0, "Prop", "Val");
8541 ok(r
== ERROR_INVALID_HANDLE
,
8542 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8544 /* invalid hInstall */
8545 r
= MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8546 ok(r
== ERROR_INVALID_HANDLE
,
8547 "Expected ERROR_INVALID_HANDLE, got %d\n", r
);
8549 /* szName is NULL */
8550 r
= MsiSetPropertyA(hpkg
, NULL
, "Val");
8551 ok(r
== ERROR_INVALID_PARAMETER
,
8552 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8554 /* both szName and szValue are NULL */
8555 r
= MsiSetPropertyA(hpkg
, NULL
, NULL
);
8556 ok(r
== ERROR_INVALID_PARAMETER
,
8557 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8559 /* szName is empty */
8560 r
= MsiSetPropertyA(hpkg
, "", "Val");
8561 ok(r
== ERROR_FUNCTION_FAILED
,
8562 "Expected ERROR_FUNCTION_FAILED, got %d\n", r
);
8564 /* szName is empty and szValue is NULL */
8565 r
= MsiSetPropertyA(hpkg
, "", NULL
);
8566 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8568 /* set a property */
8569 r
= MsiSetPropertyA(hpkg
, "Prop", "Val");
8570 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8572 /* get the property */
8574 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8575 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8576 ok(!lstrcmpA(buf
, "Val"), "Expected \"Val\", got \"%s\"\n", buf
);
8577 ok(size
== 3, "Expected 3, got %d\n", size
);
8579 /* update the property */
8580 r
= MsiSetPropertyA(hpkg
, "Prop", "Nuvo");
8581 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8583 /* get the property */
8585 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8586 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8587 ok(!lstrcmpA(buf
, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf
);
8588 ok(size
== 4, "Expected 4, got %d\n", size
);
8590 hdb
= MsiGetActiveDatabase(hpkg
);
8591 ok(hdb
!= 0, "Expected a valid database handle\n");
8593 /* set prop is not in the _Property table */
8594 query
= "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8595 r
= do_query(hdb
, query
, &hrec
);
8596 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8597 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8599 /* set prop is not in the Property table */
8600 query
= "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8601 r
= do_query(hdb
, query
, &hrec
);
8602 ok(r
== ERROR_BAD_QUERY_SYNTAX
,
8603 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r
);
8605 MsiCloseHandle(hdb
);
8607 /* szValue is an empty string */
8608 r
= MsiSetPropertyA(hpkg
, "Prop", "");
8609 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8611 /* try to get the property */
8613 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8614 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8615 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8616 ok(size
== 0, "Expected 0, got %d\n", size
);
8618 /* reset the property */
8619 r
= MsiSetPropertyA(hpkg
, "Prop", "BlueTap");
8620 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8622 /* delete the property */
8623 r
= MsiSetPropertyA(hpkg
, "Prop", NULL
);
8624 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8626 /* try to get the property */
8628 r
= MsiGetPropertyA(hpkg
, "Prop", buf
, &size
);
8629 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8630 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8631 ok(size
== 0, "Expected 0, got %d\n", size
);
8633 MsiCloseHandle(hpkg
);
8634 DeleteFileA(msifile
);
8637 static void test_MsiApplyMultiplePatches(void)
8639 UINT r
, type
= GetDriveTypeW(NULL
);
8641 if (!pMsiApplyMultiplePatchesA
) {
8642 win_skip("MsiApplyMultiplePatchesA not found\n");
8646 r
= pMsiApplyMultiplePatchesA(NULL
, NULL
, NULL
);
8647 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8649 r
= pMsiApplyMultiplePatchesA("", NULL
, NULL
);
8650 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8652 r
= pMsiApplyMultiplePatchesA(";", NULL
, NULL
);
8653 if (type
== DRIVE_FIXED
)
8654 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8656 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8658 r
= pMsiApplyMultiplePatchesA(" ;", NULL
, NULL
);
8659 if (type
== DRIVE_FIXED
)
8660 todo_wine
ok(r
== ERROR_PATCH_PACKAGE_OPEN_FAILED
, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r
);
8662 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8664 r
= pMsiApplyMultiplePatchesA(";;", NULL
, NULL
);
8665 if (type
== DRIVE_FIXED
)
8666 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8668 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8670 r
= pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL
, NULL
);
8671 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8673 r
= pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL
, NULL
);
8674 if (type
== DRIVE_FIXED
)
8675 todo_wine
ok(r
== ERROR_PATH_NOT_FOUND
, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r
);
8677 ok(r
== ERROR_INVALID_NAME
, "Expected ERROR_INVALID_NAME, got %u\n", r
);
8679 r
= pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL
, NULL
);
8680 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8682 r
= pMsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL
, NULL
);
8683 todo_wine
ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r
);
8686 static void test_MsiApplyPatch(void)
8690 r
= MsiApplyPatchA(NULL
, NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8691 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8693 r
= MsiApplyPatchA("", NULL
, INSTALLTYPE_DEFAULT
, NULL
);
8694 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8697 static void test_MsiEnumComponentCosts(void)
8699 MSIHANDLE hdb
, hpkg
;
8700 char package
[12], drive
[3];
8705 hdb
= create_package_db();
8706 ok( hdb
, "failed to create database\n" );
8708 r
= create_property_table( hdb
);
8709 ok( r
== ERROR_SUCCESS
, "cannot create Property table %u\n", r
);
8711 r
= add_property_entry( hdb
, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8712 ok( r
== ERROR_SUCCESS
, "cannot add property entry %u\n", r
);
8714 r
= add_property_entry( hdb
, "'MSIFASTINSTALL', '1'" );
8715 ok( r
== ERROR_SUCCESS
, "cannot add property entry %u\n", r
);
8717 r
= add_directory_entry( hdb
, "'TARGETDIR', '', 'SourceDir'" );
8718 ok( r
== ERROR_SUCCESS
, "failed to add directory entry %u\n" , r
);
8720 r
= create_media_table( hdb
);
8721 ok( r
== ERROR_SUCCESS
, "cannot create Media table %u\n", r
);
8723 r
= add_media_entry( hdb
, "'1', '2', 'cabinet', '', '', ''");
8724 ok( r
== ERROR_SUCCESS
, "cannot add media entry %u\n", r
);
8726 r
= create_file_table( hdb
);
8727 ok( r
== ERROR_SUCCESS
, "cannot create File table %u\n", r
);
8729 r
= add_file_entry( hdb
, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8730 ok( r
== ERROR_SUCCESS
, "cannot add file %u\n", r
);
8732 r
= create_component_table( hdb
);
8733 ok( r
== ERROR_SUCCESS
, "cannot create Component table %u\n", r
);
8735 r
= add_component_entry( hdb
, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8736 ok( r
== ERROR_SUCCESS
, "cannot add component %u\n", r
);
8738 r
= add_component_entry( hdb
, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8739 ok( r
== ERROR_SUCCESS
, "cannot add component %u\n", r
);
8741 r
= create_feature_table( hdb
);
8742 ok( r
== ERROR_SUCCESS
, "cannot create Feature table %u\n", r
);
8744 r
= add_feature_entry( hdb
, "'one', '', '', '', 0, 1, '', 0" );
8745 ok( r
== ERROR_SUCCESS
, "cannot add feature %u\n", r
);
8747 r
= add_feature_entry( hdb
, "'two', '', '', '', 0, 1, '', 0" );
8748 ok( r
== ERROR_SUCCESS
, "cannot add feature %u\n", r
);
8750 r
= create_feature_components_table( hdb
);
8751 ok( r
== ERROR_SUCCESS
, "cannot create FeatureComponents table %u\n", r
);
8753 r
= add_feature_components_entry( hdb
, "'one', 'one'" );
8754 ok( r
== ERROR_SUCCESS
, "cannot add feature/component pair %u\n", r
);
8756 r
= add_feature_components_entry( hdb
, "'two', 'two'" );
8757 ok( r
== ERROR_SUCCESS
, "cannot add feature/component pair %u\n", r
);
8759 r
= create_install_execute_sequence_table( hdb
);
8760 ok( r
== ERROR_SUCCESS
, "cannot create InstallExecuteSequence table %u\n", r
);
8762 r
= add_install_execute_sequence_entry( hdb
, "'CostInitialize', '', '800'" );
8763 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8765 r
= add_install_execute_sequence_entry( hdb
, "'FileCost', '', '900'" );
8766 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8768 r
= add_install_execute_sequence_entry( hdb
, "'CostFinalize', '', '1000'" );
8769 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8771 r
= add_install_execute_sequence_entry( hdb
, "'InstallValidate', '', '1100'" );
8772 ok( r
== ERROR_SUCCESS
, "cannot add install execute sequence entry %u\n", r
);
8774 MsiDatabaseCommit( hdb
);
8776 sprintf( package
, "#%u", hdb
);
8777 r
= MsiOpenPackageA( package
, &hpkg
);
8778 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8780 skip("Not enough rights to perform tests\n");
8783 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8785 r
= MsiEnumComponentCostsA( 0, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8786 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8788 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8789 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8791 r
= MsiEnumComponentCostsA( hpkg
, NULL
, 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8792 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8794 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8795 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8797 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, NULL
, NULL
, NULL
, NULL
);
8798 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8800 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, NULL
, NULL
, NULL
);
8801 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8803 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, NULL
, NULL
, NULL
);
8804 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8806 len
= sizeof(drive
);
8807 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, NULL
, NULL
);
8808 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8810 len
= sizeof(drive
);
8811 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, NULL
);
8812 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8814 len
= sizeof(drive
);
8815 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8816 todo_wine
ok( r
== ERROR_INVALID_HANDLE_STATE
, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r
);
8818 len
= sizeof(drive
);
8819 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, NULL
, &len
, &cost
, &temp
);
8820 ok( r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
8822 MsiSetInternalUI( INSTALLUILEVEL_NONE
, NULL
);
8824 r
= MsiDoActionA( hpkg
, "CostInitialize" );
8825 ok( r
== ERROR_SUCCESS
, "CostInitialize failed %u\n", r
);
8827 r
= MsiDoActionA( hpkg
, "FileCost" );
8828 ok( r
== ERROR_SUCCESS
, "FileCost failed %u\n", r
);
8830 len
= sizeof(drive
);
8831 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8832 ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8834 r
= MsiDoActionA( hpkg
, "CostFinalize" );
8835 ok( r
== ERROR_SUCCESS
, "CostFinalize failed %u\n", r
);
8837 /* contrary to what msdn says InstallValidate must be called too */
8838 len
= sizeof(drive
);
8839 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8840 todo_wine
ok( r
== ERROR_FUNCTION_NOT_CALLED
, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r
);
8842 r
= MsiDoActionA( hpkg
, "InstallValidate" );
8843 ok( r
== ERROR_SUCCESS
, "InstallValidate failed %u\n", r
);
8846 r
= MsiEnumComponentCostsA( hpkg
, "three", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8847 ok( r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r
);
8850 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8851 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8852 ok( len
== 2, "expected len == 2, got %u\n", len
);
8855 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8856 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8857 ok( len
== 2, "expected len == 2, got %u\n", len
);
8860 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8861 ok( r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %u\n", r
);
8862 ok( len
== 2, "expected len == 2, got %u\n", len
);
8864 /* install state doesn't seem to matter */
8865 len
= sizeof(drive
);
8866 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8867 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8869 len
= sizeof(drive
);
8870 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_ABSENT
, drive
, &len
, &cost
, &temp
);
8871 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8873 len
= sizeof(drive
);
8874 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_SOURCE
, drive
, &len
, &cost
, &temp
);
8875 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8877 len
= sizeof(drive
);
8879 cost
= temp
= 0xdead;
8880 r
= MsiEnumComponentCostsA( hpkg
, "one", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8881 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8882 ok( len
== 2, "expected len == 2, got %u\n", len
);
8883 ok( drive
[0], "expected a drive\n" );
8884 ok( cost
&& cost
!= 0xdead, "expected cost > 0, got %d\n", cost
);
8885 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8887 len
= sizeof(drive
);
8889 cost
= temp
= 0xdead;
8890 r
= MsiEnumComponentCostsA( hpkg
, "two", 0, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8891 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8892 ok( len
== 2, "expected len == 2, got %u\n", len
);
8893 ok( drive
[0], "expected a drive\n" );
8894 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8895 ok( !temp
, "expected temp == 0, got %d\n", temp
);
8897 len
= sizeof(drive
);
8899 cost
= temp
= 0xdead;
8900 r
= MsiEnumComponentCostsA( hpkg
, "", 0, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8901 ok( r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
8902 ok( len
== 2, "expected len == 2, got %u\n", len
);
8903 ok( drive
[0], "expected a drive\n" );
8904 ok( !cost
, "expected cost == 0, got %d\n", cost
);
8905 ok( temp
&& temp
!= 0xdead, "expected temp > 0, got %d\n", temp
);
8907 /* increased index */
8908 len
= sizeof(drive
);
8909 r
= MsiEnumComponentCostsA( hpkg
, "one", 1, INSTALLSTATE_LOCAL
, drive
, &len
, &cost
, &temp
);
8910 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8912 len
= sizeof(drive
);
8913 r
= MsiEnumComponentCostsA( hpkg
, "", 1, INSTALLSTATE_UNKNOWN
, drive
, &len
, &cost
, &temp
);
8914 ok( r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
8916 MsiCloseHandle( hpkg
);
8918 MsiCloseHandle( hdb
);
8919 DeleteFileA( msifile
);
8922 static void test_MsiDatabaseCommit(void)
8925 MSIHANDLE hdb
, hpkg
= 0;
8926 char buf
[32], package
[12];
8929 hdb
= create_package_db();
8930 ok( hdb
, "failed to create database\n" );
8932 r
= create_property_table( hdb
);
8933 ok( r
== ERROR_SUCCESS
, "can't create Property table %u\n", r
);
8935 sprintf( package
, "#%u", hdb
);
8936 r
= MsiOpenPackageA( package
, &hpkg
);
8937 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
8939 skip("Not enough rights to perform tests\n");
8942 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8944 r
= MsiSetPropertyA( hpkg
, "PROP", "value" );
8945 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
8949 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8950 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8951 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8953 r
= MsiDatabaseCommit( hdb
);
8954 ok( r
== ERROR_SUCCESS
, "MsiDatabaseCommit returned %u\n", r
);
8958 r
= MsiGetPropertyA( hpkg
, "PROP", buf
, &sz
);
8959 ok( r
== ERROR_SUCCESS
, "MsiGetPropertyA returned %u\n", r
);
8960 ok( !lstrcmpA( buf
, "value" ), "got \"%s\"\n", buf
);
8962 MsiCloseHandle( hpkg
);
8964 MsiCloseHandle( hdb
);
8965 DeleteFileA( msifile
);
8970 STATEMGRSTATUS status
;
8973 init_functionpointers();
8975 if (pIsWow64Process
)
8976 pIsWow64Process(GetCurrentProcess(), &is_wow64
);
8978 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
8980 /* Create a restore point ourselves so we circumvent the multitude of restore points
8981 * that would have been created by all the installation and removal tests.
8983 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
8984 * creation of restore points.
8986 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
)
8988 memset(&status
, 0, sizeof(status
));
8989 ret
= notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE
, &status
);
8992 test_createpackage();
8994 test_gettargetpath_bad();
8995 test_settargetpath();
8997 test_property_table();
9000 test_formatrecord2();
9005 test_appsearch_complocator();
9006 test_appsearch_reglocator();
9007 test_appsearch_inilocator();
9008 test_appsearch_drlocator();
9009 test_featureparents();
9010 test_installprops();
9011 test_launchconditions();
9014 test_MsiGetSourcePath();
9015 test_shortlongsource();
9018 test_emptypackage();
9019 test_MsiGetProductProperty();
9020 test_MsiSetProperty();
9021 test_MsiApplyMultiplePatches();
9022 test_MsiApplyPatch();
9023 test_MsiEnumComponentCosts();
9024 test_MsiDatabaseCommit();
9026 if (pSRSetRestorePointA
&& !pMsiGetComponentPathExA
&& ret
)
9028 ret
= notify_system_change(END_NESTED_SYSTEM_CHANGE
, &status
);
9030 remove_restore_point(status
.llSequenceNumber
);