msi: Don't free cached tables in MsiDatabaseCommit.
[wine/multimedia.git] / dlls / msi / tests / package.c
blob8cf8f27a09654c0d4193daeb43b12b8c28b7a26d
1 /*
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
22 #define COBJMACROS
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msidefs.h>
27 #include <msi.h>
28 #include <msiquery.h>
29 #include <srrestoreptapi.h>
30 #include <shlobj.h>
32 #include "wine/test.h"
34 static BOOL is_wow64;
35 static const char msifile[] = "winetest-package.msi";
36 static char CURR_DIR[MAX_PATH];
38 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
39 static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
40 static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
42 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
43 static BOOL (WINAPI *pGetTokenInformation)( HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD );
44 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
45 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
46 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
47 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
48 static void (WINAPI *pGetSystemInfo)(LPSYSTEM_INFO);
49 static void (WINAPI *pGetNativeSystemInfo)(LPSYSTEM_INFO);
50 static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR, UINT);
52 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
53 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
55 static void init_functionpointers(void)
57 HMODULE hmsi = GetModuleHandleA("msi.dll");
58 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
59 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
60 HMODULE hshell32 = GetModuleHandleA("shell32.dll");
61 HMODULE hsrclient;
63 #define GET_PROC(mod, func) \
64 p ## func = (void*)GetProcAddress(mod, #func);
66 GET_PROC(hmsi, MsiApplyMultiplePatchesA);
67 GET_PROC(hmsi, MsiGetComponentPathExA);
68 GET_PROC(hshell32, SHGetFolderPathA);
70 GET_PROC(hadvapi32, ConvertSidToStringSidA);
71 GET_PROC(hadvapi32, GetTokenInformation);
72 GET_PROC(hadvapi32, OpenProcessToken);
73 GET_PROC(hadvapi32, RegDeleteKeyExA)
74 GET_PROC(hadvapi32, RegDeleteKeyExW)
75 GET_PROC(hkernel32, IsWow64Process)
76 GET_PROC(hkernel32, GetNativeSystemInfo)
77 GET_PROC(hkernel32, GetSystemInfo)
78 GET_PROC(hkernel32, GetSystemWow64DirectoryA)
80 hsrclient = LoadLibraryA("srclient.dll");
81 GET_PROC(hsrclient, SRRemoveRestorePoint);
82 GET_PROC(hsrclient, SRSetRestorePointA);
83 #undef GET_PROC
86 static BOOL is_process_limited(void)
88 HANDLE token;
90 if (!pOpenProcessToken || !pGetTokenInformation) return FALSE;
92 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
94 BOOL ret;
95 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
96 DWORD size;
98 ret = pGetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
99 CloseHandle(token);
100 return (ret && type == TokenElevationTypeLimited);
102 return FALSE;
105 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
107 if (pRegDeleteKeyExA)
108 return pRegDeleteKeyExA( key, subkey, access, 0 );
109 return RegDeleteKeyA( key, subkey );
112 static char *get_user_sid(void)
114 HANDLE token;
115 DWORD size = 0;
116 TOKEN_USER *user;
117 char *usersid = NULL;
119 if (!pConvertSidToStringSidA)
121 win_skip("ConvertSidToStringSidA is not available\n");
122 return NULL;
124 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
125 GetTokenInformation(token, TokenUser, NULL, size, &size);
127 user = HeapAlloc(GetProcessHeap(), 0, size);
128 GetTokenInformation(token, TokenUser, user, size, &size);
129 pConvertSidToStringSidA(user->User.Sid, &usersid);
130 HeapFree(GetProcessHeap(), 0, user);
132 CloseHandle(token);
133 return usersid;
136 /* RegDeleteTreeW from dlls/advapi32/registry.c */
137 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
139 LONG ret;
140 DWORD dwMaxSubkeyLen, dwMaxValueLen;
141 DWORD dwMaxLen, dwSize;
142 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
143 HKEY hSubKey = hKey;
145 if(lpszSubKey)
147 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
148 if (ret) return ret;
151 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
152 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
153 if (ret) goto cleanup;
155 dwMaxSubkeyLen++;
156 dwMaxValueLen++;
157 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
158 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
160 /* Name too big: alloc a buffer for it */
161 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
163 ret = ERROR_NOT_ENOUGH_MEMORY;
164 goto cleanup;
168 /* Recursively delete all the subkeys */
169 while (TRUE)
171 dwSize = dwMaxLen;
172 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
173 NULL, NULL, NULL)) break;
175 ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
176 if (ret) goto cleanup;
179 if (lpszSubKey)
181 if (pRegDeleteKeyExW)
182 ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
183 else
184 ret = RegDeleteKeyW(hKey, lpszSubKey);
186 else
187 while (TRUE)
189 dwSize = dwMaxLen;
190 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
191 NULL, NULL, NULL, NULL)) break;
193 ret = RegDeleteValueW(hKey, lpszName);
194 if (ret) goto cleanup;
197 cleanup:
198 if (lpszName != szNameBuf)
199 HeapFree(GetProcessHeap(), 0, lpszName);
200 if(lpszSubKey)
201 RegCloseKey(hSubKey);
202 return ret;
205 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
207 DWORD i,n=1;
208 GUID guid;
210 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
211 return FALSE;
213 for(i=0; i<8; i++)
214 out[7-i] = in[n++];
215 n++;
216 for(i=0; i<4; i++)
217 out[11-i] = in[n++];
218 n++;
219 for(i=0; i<4; i++)
220 out[15-i] = in[n++];
221 n++;
222 for(i=0; i<2; i++)
224 out[17+i*2] = in[n++];
225 out[16+i*2] = in[n++];
227 n++;
228 for( ; i<8; i++)
230 out[17+i*2] = in[n++];
231 out[16+i*2] = in[n++];
233 out[32]=0;
234 return TRUE;
237 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
239 WCHAR guidW[MAX_PATH];
240 WCHAR squashedW[MAX_PATH];
241 GUID guid;
242 HRESULT hr;
243 int size;
245 hr = CoCreateGuid(&guid);
246 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
248 size = StringFromGUID2(&guid, guidW, MAX_PATH);
249 ok(size == 39, "Expected 39, got %d\n", hr);
251 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
252 squash_guid(guidW, squashedW);
253 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
256 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
257 LPCSTR guid, LPSTR usersid, BOOL dir)
259 WCHAR guidW[MAX_PATH];
260 WCHAR squashedW[MAX_PATH];
261 CHAR squashed[MAX_PATH];
262 CHAR comppath[MAX_PATH];
263 CHAR prodpath[MAX_PATH];
264 CHAR path[MAX_PATH];
265 LPCSTR prod = NULL;
266 HKEY hkey;
267 REGSAM access = KEY_ALL_ACCESS;
269 if (is_wow64)
270 access |= KEY_WOW64_64KEY;
272 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
273 squash_guid(guidW, squashedW);
274 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
276 if (context == MSIINSTALLCONTEXT_MACHINE)
278 prod = "3D0DAE300FACA1300AD792060BCDAA92";
279 sprintf(comppath,
280 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
281 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
282 lstrcpyA(prodpath,
283 "SOFTWARE\\Classes\\Installer\\"
284 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
286 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
288 prod = "7D2F387510109040002000060BECB6AB";
289 sprintf(comppath,
290 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
291 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
292 sprintf(prodpath,
293 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
294 "Installer\\%s\\Installer\\Products\\"
295 "7D2F387510109040002000060BECB6AB", usersid);
297 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
299 prod = "7D2F387510109040002000060BECB6AB";
300 sprintf(comppath,
301 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
302 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
303 sprintf(prodpath,
304 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
305 "Installer\\Managed\\%s\\Installer\\Products\\"
306 "7D2F387510109040002000060BECB6AB", usersid);
309 RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
311 lstrcpyA(path, CURR_DIR);
312 lstrcatA(path, "\\");
313 if (!dir) lstrcatA(path, filename);
315 RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
316 RegCloseKey(hkey);
318 RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
319 RegCloseKey(hkey);
322 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
324 WCHAR guidW[MAX_PATH];
325 WCHAR squashedW[MAX_PATH];
326 WCHAR substrW[MAX_PATH];
327 CHAR squashed[MAX_PATH];
328 CHAR comppath[MAX_PATH];
329 CHAR prodpath[MAX_PATH];
330 REGSAM access = KEY_ALL_ACCESS;
332 if (is_wow64)
333 access |= KEY_WOW64_64KEY;
335 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
336 squash_guid(guidW, squashedW);
337 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
339 if (context == MSIINSTALLCONTEXT_MACHINE)
341 sprintf(comppath,
342 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
343 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
344 lstrcpyA(prodpath,
345 "SOFTWARE\\Classes\\Installer\\"
346 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
348 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
350 sprintf(comppath,
351 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
352 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
353 sprintf(prodpath,
354 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
355 "Installer\\%s\\Installer\\Products\\"
356 "7D2F387510109040002000060BECB6AB", usersid);
358 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
360 sprintf(comppath,
361 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
362 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
363 sprintf(prodpath,
364 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
365 "Installer\\Managed\\%s\\Installer\\Products\\"
366 "7D2F387510109040002000060BECB6AB", usersid);
369 MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
370 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
372 MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
373 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
376 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
378 MSIHANDLE hview = 0;
379 UINT r, ret;
381 /* open a select query */
382 r = MsiDatabaseOpenView(hdb, query, &hview);
383 if (r != ERROR_SUCCESS)
384 return r;
385 r = MsiViewExecute(hview, 0);
386 if (r != ERROR_SUCCESS)
387 return r;
388 ret = MsiViewFetch(hview, phrec);
389 r = MsiViewClose(hview);
390 if (r != ERROR_SUCCESS)
391 return r;
392 r = MsiCloseHandle(hview);
393 if (r != ERROR_SUCCESS)
394 return r;
395 return ret;
398 static UINT run_query( MSIHANDLE hdb, const char *query )
400 MSIHANDLE hview = 0;
401 UINT r;
403 r = MsiDatabaseOpenView(hdb, query, &hview);
404 if( r != ERROR_SUCCESS )
405 return r;
407 r = MsiViewExecute(hview, 0);
408 if( r == ERROR_SUCCESS )
409 r = MsiViewClose(hview);
410 MsiCloseHandle(hview);
411 return r;
414 static UINT create_component_table( MSIHANDLE hdb )
416 return run_query( hdb,
417 "CREATE TABLE `Component` ( "
418 "`Component` CHAR(72) NOT NULL, "
419 "`ComponentId` CHAR(38), "
420 "`Directory_` CHAR(72) NOT NULL, "
421 "`Attributes` SHORT NOT NULL, "
422 "`Condition` CHAR(255), "
423 "`KeyPath` CHAR(72) "
424 "PRIMARY KEY `Component`)" );
427 static UINT create_feature_table( MSIHANDLE hdb )
429 return run_query( hdb,
430 "CREATE TABLE `Feature` ( "
431 "`Feature` CHAR(38) NOT NULL, "
432 "`Feature_Parent` CHAR(38), "
433 "`Title` CHAR(64), "
434 "`Description` CHAR(255), "
435 "`Display` SHORT NOT NULL, "
436 "`Level` SHORT NOT NULL, "
437 "`Directory_` CHAR(72), "
438 "`Attributes` SHORT NOT NULL "
439 "PRIMARY KEY `Feature`)" );
442 static UINT create_feature_components_table( MSIHANDLE hdb )
444 return run_query( hdb,
445 "CREATE TABLE `FeatureComponents` ( "
446 "`Feature_` CHAR(38) NOT NULL, "
447 "`Component_` CHAR(72) NOT NULL "
448 "PRIMARY KEY `Feature_`, `Component_` )" );
451 static UINT create_file_table( MSIHANDLE hdb )
453 return run_query( hdb,
454 "CREATE TABLE `File` ("
455 "`File` CHAR(72) NOT NULL, "
456 "`Component_` CHAR(72) NOT NULL, "
457 "`FileName` CHAR(255) NOT NULL, "
458 "`FileSize` LONG NOT NULL, "
459 "`Version` CHAR(72), "
460 "`Language` CHAR(20), "
461 "`Attributes` SHORT, "
462 "`Sequence` SHORT NOT NULL "
463 "PRIMARY KEY `File`)" );
466 static UINT create_remove_file_table( MSIHANDLE hdb )
468 return run_query( hdb,
469 "CREATE TABLE `RemoveFile` ("
470 "`FileKey` CHAR(72) NOT NULL, "
471 "`Component_` CHAR(72) NOT NULL, "
472 "`FileName` CHAR(255) LOCALIZABLE, "
473 "`DirProperty` CHAR(72) NOT NULL, "
474 "`InstallMode` SHORT NOT NULL "
475 "PRIMARY KEY `FileKey`)" );
478 static UINT create_appsearch_table( MSIHANDLE hdb )
480 return run_query( hdb,
481 "CREATE TABLE `AppSearch` ("
482 "`Property` CHAR(72) NOT NULL, "
483 "`Signature_` CHAR(72) NOT NULL "
484 "PRIMARY KEY `Property`, `Signature_`)" );
487 static UINT create_reglocator_table( MSIHANDLE hdb )
489 return run_query( hdb,
490 "CREATE TABLE `RegLocator` ("
491 "`Signature_` CHAR(72) NOT NULL, "
492 "`Root` SHORT NOT NULL, "
493 "`Key` CHAR(255) NOT NULL, "
494 "`Name` CHAR(255), "
495 "`Type` SHORT "
496 "PRIMARY KEY `Signature_`)" );
499 static UINT create_signature_table( MSIHANDLE hdb )
501 return run_query( hdb,
502 "CREATE TABLE `Signature` ("
503 "`Signature` CHAR(72) NOT NULL, "
504 "`FileName` CHAR(255) NOT NULL, "
505 "`MinVersion` CHAR(20), "
506 "`MaxVersion` CHAR(20), "
507 "`MinSize` LONG, "
508 "`MaxSize` LONG, "
509 "`MinDate` LONG, "
510 "`MaxDate` LONG, "
511 "`Languages` CHAR(255) "
512 "PRIMARY KEY `Signature`)" );
515 static UINT create_launchcondition_table( MSIHANDLE hdb )
517 return run_query( hdb,
518 "CREATE TABLE `LaunchCondition` ("
519 "`Condition` CHAR(255) NOT NULL, "
520 "`Description` CHAR(255) NOT NULL "
521 "PRIMARY KEY `Condition`)" );
524 static UINT create_property_table( MSIHANDLE hdb )
526 return run_query( hdb,
527 "CREATE TABLE `Property` ("
528 "`Property` CHAR(72) NOT NULL, "
529 "`Value` CHAR(0) "
530 "PRIMARY KEY `Property`)" );
533 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
535 return run_query( hdb,
536 "CREATE TABLE `InstallExecuteSequence` ("
537 "`Action` CHAR(72) NOT NULL, "
538 "`Condition` CHAR(255), "
539 "`Sequence` SHORT "
540 "PRIMARY KEY `Action`)" );
543 static UINT create_media_table( MSIHANDLE hdb )
545 return run_query( hdb,
546 "CREATE TABLE `Media` ("
547 "`DiskId` SHORT NOT NULL, "
548 "`LastSequence` SHORT NOT NULL, "
549 "`DiskPrompt` CHAR(64), "
550 "`Cabinet` CHAR(255), "
551 "`VolumeLabel` CHAR(32), "
552 "`Source` CHAR(72) "
553 "PRIMARY KEY `DiskId`)" );
556 static UINT create_ccpsearch_table( MSIHANDLE hdb )
558 return run_query( hdb,
559 "CREATE TABLE `CCPSearch` ("
560 "`Signature_` CHAR(72) NOT NULL "
561 "PRIMARY KEY `Signature_`)" );
564 static UINT create_drlocator_table( MSIHANDLE hdb )
566 return run_query( hdb,
567 "CREATE TABLE `DrLocator` ("
568 "`Signature_` CHAR(72) NOT NULL, "
569 "`Parent` CHAR(72), "
570 "`Path` CHAR(255), "
571 "`Depth` SHORT "
572 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
575 static UINT create_complocator_table( MSIHANDLE hdb )
577 return run_query( hdb,
578 "CREATE TABLE `CompLocator` ("
579 "`Signature_` CHAR(72) NOT NULL, "
580 "`ComponentId` CHAR(38) NOT NULL, "
581 "`Type` SHORT "
582 "PRIMARY KEY `Signature_`)" );
585 static UINT create_inilocator_table( MSIHANDLE hdb )
587 return run_query( hdb,
588 "CREATE TABLE `IniLocator` ("
589 "`Signature_` CHAR(72) NOT NULL, "
590 "`FileName` CHAR(255) NOT NULL, "
591 "`Section` CHAR(96)NOT NULL, "
592 "`Key` CHAR(128)NOT NULL, "
593 "`Field` SHORT, "
594 "`Type` SHORT "
595 "PRIMARY KEY `Signature_`)" );
598 #define make_add_entry(type, qtext) \
599 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
601 char insert[] = qtext; \
602 char *query; \
603 UINT sz, r; \
604 sz = strlen(values) + sizeof insert; \
605 query = HeapAlloc(GetProcessHeap(),0,sz); \
606 sprintf(query,insert,values); \
607 r = run_query( hdb, query ); \
608 HeapFree(GetProcessHeap(), 0, query); \
609 return r; \
612 make_add_entry(component,
613 "INSERT INTO `Component` "
614 "(`Component`, `ComponentId`, `Directory_`, "
615 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
617 make_add_entry(directory,
618 "INSERT INTO `Directory` "
619 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
621 make_add_entry(feature,
622 "INSERT INTO `Feature` "
623 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
624 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
626 make_add_entry(feature_components,
627 "INSERT INTO `FeatureComponents` "
628 "(`Feature_`, `Component_`) VALUES( %s )")
630 make_add_entry(file,
631 "INSERT INTO `File` "
632 "(`File`, `Component_`, `FileName`, `FileSize`, "
633 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
635 make_add_entry(appsearch,
636 "INSERT INTO `AppSearch` "
637 "(`Property`, `Signature_`) VALUES( %s )")
639 make_add_entry(signature,
640 "INSERT INTO `Signature` "
641 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
642 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
643 "VALUES( %s )")
645 make_add_entry(launchcondition,
646 "INSERT INTO `LaunchCondition` "
647 "(`Condition`, `Description`) VALUES( %s )")
649 make_add_entry(property,
650 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
652 make_add_entry(install_execute_sequence,
653 "INSERT INTO `InstallExecuteSequence` "
654 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
656 make_add_entry(media,
657 "INSERT INTO `Media` "
658 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
659 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
661 make_add_entry(ccpsearch,
662 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
664 make_add_entry(drlocator,
665 "INSERT INTO `DrLocator` "
666 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
668 make_add_entry(complocator,
669 "INSERT INTO `CompLocator` "
670 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
672 make_add_entry(inilocator,
673 "INSERT INTO `IniLocator` "
674 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
675 "VALUES( %s )")
677 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
678 const char *name, UINT type )
680 const char insert[] =
681 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
682 "VALUES( '%s', %u, '%s', '%s', %u )";
683 char *query;
684 UINT sz, r;
686 sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
687 query = HeapAlloc( GetProcessHeap(), 0, sz );
688 sprintf( query, insert, sig, root, path, name, type );
689 r = run_query( hdb, query );
690 HeapFree( GetProcessHeap(), 0, query );
691 return r;
694 static UINT set_summary_info(MSIHANDLE hdb)
696 UINT res;
697 MSIHANDLE suminfo;
699 /* build summary info */
700 res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
701 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
703 res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
704 "Installation Database");
705 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
707 res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
708 "Installation Database");
709 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
711 res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
712 "Wine Hackers");
713 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
715 res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
716 ";1033");
717 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
719 res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
720 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
721 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
723 res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
724 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
726 res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
727 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
729 res = MsiSummaryInfoPersist(suminfo);
730 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
732 res = MsiCloseHandle( suminfo);
733 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
735 return res;
739 static MSIHANDLE create_package_db(void)
741 MSIHANDLE hdb = 0;
742 UINT res;
744 DeleteFile(msifile);
746 /* create an empty database */
747 res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
748 ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
749 if( res != ERROR_SUCCESS )
750 return hdb;
752 res = MsiDatabaseCommit( hdb );
753 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
755 res = set_summary_info(hdb);
756 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
758 res = run_query( hdb,
759 "CREATE TABLE `Directory` ( "
760 "`Directory` CHAR(255) NOT NULL, "
761 "`Directory_Parent` CHAR(255), "
762 "`DefaultDir` CHAR(255) NOT NULL "
763 "PRIMARY KEY `Directory`)" );
764 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
766 return hdb;
769 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
771 UINT res;
772 CHAR szPackage[12];
773 MSIHANDLE hPackage;
775 sprintf(szPackage, "#%u", hdb);
776 res = MsiOpenPackage(szPackage, &hPackage);
777 if (res != ERROR_SUCCESS)
779 MsiCloseHandle(hdb);
780 return res;
783 res = MsiCloseHandle(hdb);
784 if (res != ERROR_SUCCESS)
786 MsiCloseHandle(hPackage);
787 return res;
790 *handle = hPackage;
791 return ERROR_SUCCESS;
794 static void create_test_file(const CHAR *name)
796 HANDLE file;
797 DWORD written;
799 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
800 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
801 WriteFile(file, name, strlen(name), &written, NULL);
802 WriteFile(file, "\n", strlen("\n"), &written, NULL);
803 CloseHandle(file);
806 typedef struct _tagVS_VERSIONINFO
808 WORD wLength;
809 WORD wValueLength;
810 WORD wType;
811 WCHAR szKey[1];
812 WORD wPadding1[1];
813 VS_FIXEDFILEINFO Value;
814 WORD wPadding2[1];
815 WORD wChildren[1];
816 } VS_VERSIONINFO;
818 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
819 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
821 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
823 VS_VERSIONINFO *pVerInfo;
824 VS_FIXEDFILEINFO *pFixedInfo;
825 LPBYTE buffer, ofs;
826 CHAR path[MAX_PATH];
827 DWORD handle, size;
828 HANDLE resource;
829 BOOL ret = FALSE;
831 GetSystemDirectory(path, MAX_PATH);
832 /* Some dlls can't be updated on Vista/W2K8 */
833 lstrcatA(path, "\\version.dll");
835 CopyFileA(path, name, FALSE);
837 size = GetFileVersionInfoSize(path, &handle);
838 buffer = HeapAlloc(GetProcessHeap(), 0, size);
840 GetFileVersionInfoA(path, 0, size, buffer);
842 pVerInfo = (VS_VERSIONINFO *)buffer;
843 ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
844 pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
846 pFixedInfo->dwFileVersionMS = ms;
847 pFixedInfo->dwFileVersionLS = ls;
848 pFixedInfo->dwProductVersionMS = ms;
849 pFixedInfo->dwProductVersionLS = ls;
851 resource = BeginUpdateResource(name, FALSE);
852 if (!resource)
853 goto done;
855 if (!UpdateResource(resource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO),
856 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
857 goto done;
859 if (!EndUpdateResource(resource, FALSE))
860 goto done;
862 ret = TRUE;
864 done:
865 HeapFree(GetProcessHeap(), 0, buffer);
866 return ret;
869 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
871 RESTOREPOINTINFOA spec;
873 spec.dwEventType = event_type;
874 spec.dwRestorePtType = APPLICATION_INSTALL;
875 spec.llSequenceNumber = status->llSequenceNumber;
876 lstrcpyA(spec.szDescription, "msitest restore point");
878 return pSRSetRestorePointA(&spec, status);
881 static void remove_restore_point(DWORD seq_number)
883 DWORD res;
885 res = pSRRemoveRestorePoint(seq_number);
886 if (res != ERROR_SUCCESS)
887 trace("Failed to remove the restore point : %08x\n", res);
890 static void test_createpackage(void)
892 MSIHANDLE hPackage = 0;
893 UINT res;
895 res = package_from_db(create_package_db(), &hPackage);
896 if (res == ERROR_INSTALL_PACKAGE_REJECTED)
898 skip("Not enough rights to perform tests\n");
899 DeleteFile(msifile);
900 return;
902 ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
904 res = MsiCloseHandle( hPackage);
905 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
906 DeleteFile(msifile);
909 static void test_doaction( void )
911 MSIHANDLE hpkg;
912 UINT r;
914 r = MsiDoAction( -1, NULL );
915 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
917 r = package_from_db(create_package_db(), &hpkg);
918 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
920 skip("Not enough rights to perform tests\n");
921 DeleteFile(msifile);
922 return;
924 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
926 r = MsiDoAction(hpkg, NULL);
927 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
929 r = MsiDoAction(0, "boo");
930 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
932 r = MsiDoAction(hpkg, "boo");
933 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
935 MsiCloseHandle( hpkg );
936 DeleteFile(msifile);
939 static void test_gettargetpath_bad(void)
941 static const WCHAR boo[] = {'b','o','o',0};
942 static const WCHAR empty[] = {0};
943 char buffer[0x80];
944 WCHAR bufferW[0x80];
945 MSIHANDLE hpkg;
946 DWORD sz;
947 UINT r;
949 r = package_from_db(create_package_db(), &hpkg);
950 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
952 skip("Not enough rights to perform tests\n");
953 DeleteFile(msifile);
954 return;
956 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
958 r = MsiGetTargetPath( 0, NULL, NULL, NULL );
959 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
961 r = MsiGetTargetPath( 0, NULL, NULL, &sz );
962 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
964 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
965 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
967 r = MsiGetTargetPath( 0, "boo", NULL, NULL );
968 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
970 r = MsiGetTargetPath( hpkg, "boo", NULL, NULL );
971 ok( r == ERROR_DIRECTORY, "wrong return val\n");
973 r = MsiGetTargetPath( hpkg, "boo", buffer, NULL );
974 ok( r == ERROR_DIRECTORY, "wrong return val\n");
976 sz = 0;
977 r = MsiGetTargetPath( hpkg, "", buffer, &sz );
978 ok( r == ERROR_DIRECTORY, "wrong return val\n");
980 r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
981 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
983 r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
984 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
986 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
987 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
989 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
990 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
992 r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
993 ok( r == ERROR_DIRECTORY, "wrong return val\n");
995 r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
996 ok( r == ERROR_DIRECTORY, "wrong return val\n");
998 sz = 0;
999 r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
1000 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1002 MsiCloseHandle( hpkg );
1003 DeleteFile(msifile);
1006 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1008 UINT r;
1009 DWORD size;
1010 MSIHANDLE rec;
1012 rec = MsiCreateRecord( 1 );
1013 ok(rec, "MsiCreate record failed\n");
1015 r = MsiRecordSetString( rec, 0, file );
1016 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1018 size = MAX_PATH;
1019 r = MsiFormatRecord( hpkg, rec, buff, &size );
1020 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1022 MsiCloseHandle( rec );
1025 static void test_settargetpath(void)
1027 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1028 DWORD sz;
1029 MSIHANDLE hpkg;
1030 UINT r;
1031 MSIHANDLE hdb;
1033 hdb = create_package_db();
1034 ok ( hdb, "failed to create package database\n" );
1036 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1037 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1039 r = create_component_table( hdb );
1040 ok( r == S_OK, "cannot create Component table: %d\n", r );
1042 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1043 ok( r == S_OK, "cannot add dummy component: %d\n", r );
1045 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1046 ok( r == S_OK, "cannot add test component: %d\n", r );
1048 r = create_feature_table( hdb );
1049 ok( r == S_OK, "cannot create Feature table: %d\n", r );
1051 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1052 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1054 r = create_feature_components_table( hdb );
1055 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1057 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1058 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1060 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1061 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1063 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1064 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1066 r = create_file_table( hdb );
1067 ok( r == S_OK, "cannot create File table: %d\n", r );
1069 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1070 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1072 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1073 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1075 r = package_from_db( hdb, &hpkg );
1076 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1078 skip("Not enough rights to perform tests\n");
1079 DeleteFile(msifile);
1080 return;
1082 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1084 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1086 r = MsiDoAction( hpkg, "CostInitialize");
1087 ok( r == ERROR_SUCCESS, "cost init failed\n");
1089 r = MsiDoAction( hpkg, "FileCost");
1090 ok( r == ERROR_SUCCESS, "file cost failed\n");
1092 r = MsiDoAction( hpkg, "CostFinalize");
1093 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1095 r = MsiSetTargetPath( 0, NULL, NULL );
1096 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1098 r = MsiSetTargetPath( 0, "boo", "C:\\bogusx" );
1099 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1101 r = MsiSetTargetPath( hpkg, "boo", NULL );
1102 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1104 r = MsiSetTargetPath( hpkg, "boo", "c:\\bogusx" );
1105 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1107 sz = sizeof tempdir - 1;
1108 r = MsiGetTargetPath( hpkg, "TARGETDIR", tempdir, &sz );
1109 sprintf( file, "%srootfile.txt", tempdir );
1110 buffer[0] = 0;
1111 query_file_path( hpkg, "[#RootFile]", buffer );
1112 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1113 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer );
1115 GetTempFileName( tempdir, "_wt", 0, buffer );
1116 sprintf( tempdir, "%s\\subdir", buffer );
1118 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1119 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1120 "MsiSetTargetPath on file returned %d\n", r );
1122 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1123 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1124 "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1126 DeleteFile( buffer );
1128 r = MsiSetTargetPath( hpkg, "TARGETDIR", buffer );
1129 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1131 r = GetFileAttributes( buffer );
1132 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1134 r = MsiSetTargetPath( hpkg, "TARGETDIR", tempdir );
1135 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1137 buffer[0] = 0;
1138 sz = sizeof buffer - 1;
1139 lstrcat( tempdir, "\\" );
1140 r = MsiGetTargetPath( hpkg, "TARGETDIR", buffer, &sz );
1141 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1142 ok( !lstrcmp(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1144 sprintf( file, "%srootfile.txt", tempdir );
1145 query_file_path( hpkg, "[#RootFile]", buffer );
1146 ok( !lstrcmp(buffer, file), "Expected %s, got %s\n", file, buffer);
1148 buffer[0] = 0;
1149 sz = sizeof(buffer);
1150 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1151 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1152 lstrcatA( tempdir, "TestParent\\" );
1153 ok( !lstrcmpi(buffer, tempdir), "Expected \"%s\", got \"%s\"\n", tempdir, buffer );
1155 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two" );
1156 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1158 buffer[0] = 0;
1159 sz = sizeof(buffer);
1160 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1161 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1162 ok( lstrcmpi(buffer, "C:\\one\\two\\TestDir\\"),
1163 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer );
1165 buffer[0] = 0;
1166 query_file_path( hpkg, "[#TestFile]", buffer );
1167 ok( !lstrcmpi(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1168 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1170 buffer[0] = 0;
1171 sz = sizeof buffer - 1;
1172 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1173 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1174 ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1176 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\one\\two\\three" );
1177 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1179 buffer[0] = 0;
1180 sz = sizeof buffer - 1;
1181 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1182 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1183 ok( !lstrcmpi(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1185 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\\\one\\\\two " );
1186 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1188 buffer[0] = 0;
1189 sz = sizeof buffer - 1;
1190 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1191 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1192 ok( !lstrcmpi(buffer, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer);
1194 r = MsiSetTargetPath( hpkg, "TestParent", "C:\\\\ Program Files \\\\ " );
1195 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1197 buffer[0] = 0;
1198 sz = sizeof buffer - 1;
1199 r = MsiGetTargetPath( hpkg, "TestParent", buffer, &sz );
1200 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1201 ok( !lstrcmpi(buffer, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer);
1203 MsiCloseHandle( hpkg );
1206 static void test_condition(void)
1208 static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1209 static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1210 static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1211 static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1212 MSICONDITION r;
1213 MSIHANDLE hpkg;
1215 r = package_from_db(create_package_db(), &hpkg);
1216 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1218 skip("Not enough rights to perform tests\n");
1219 DeleteFile(msifile);
1220 return;
1222 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1224 r = MsiEvaluateCondition(0, NULL);
1225 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1227 r = MsiEvaluateCondition(hpkg, NULL);
1228 ok( r == MSICONDITION_NONE, "wrong return val\n");
1230 r = MsiEvaluateCondition(hpkg, "");
1231 ok( r == MSICONDITION_NONE, "wrong return val\n");
1233 r = MsiEvaluateCondition(hpkg, "1");
1234 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1236 r = MsiEvaluateCondition(hpkg, "0");
1237 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1239 r = MsiEvaluateCondition(hpkg, "-1");
1240 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1242 r = MsiEvaluateCondition(hpkg, "0 = 0");
1243 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1245 r = MsiEvaluateCondition(hpkg, "0 <> 0");
1246 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1248 r = MsiEvaluateCondition(hpkg, "0 = 1");
1249 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1251 r = MsiEvaluateCondition(hpkg, "0 > 1");
1252 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1254 r = MsiEvaluateCondition(hpkg, "0 ~> 1");
1255 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1257 r = MsiEvaluateCondition(hpkg, "1 > 1");
1258 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1260 r = MsiEvaluateCondition(hpkg, "1 ~> 1");
1261 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1263 r = MsiEvaluateCondition(hpkg, "0 >= 1");
1264 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1266 r = MsiEvaluateCondition(hpkg, "0 ~>= 1");
1267 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1269 r = MsiEvaluateCondition(hpkg, "1 >= 1");
1270 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1272 r = MsiEvaluateCondition(hpkg, "1 ~>= 1");
1273 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1275 r = MsiEvaluateCondition(hpkg, "0 < 1");
1276 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1278 r = MsiEvaluateCondition(hpkg, "0 ~< 1");
1279 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1281 r = MsiEvaluateCondition(hpkg, "1 < 1");
1282 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1284 r = MsiEvaluateCondition(hpkg, "1 ~< 1");
1285 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1287 r = MsiEvaluateCondition(hpkg, "0 <= 1");
1288 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1290 r = MsiEvaluateCondition(hpkg, "0 ~<= 1");
1291 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1293 r = MsiEvaluateCondition(hpkg, "1 <= 1");
1294 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1296 r = MsiEvaluateCondition(hpkg, "1 ~<= 1");
1297 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1299 r = MsiEvaluateCondition(hpkg, "0 >=");
1300 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1302 r = MsiEvaluateCondition(hpkg, " ");
1303 ok( r == MSICONDITION_NONE, "wrong return val\n");
1305 r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
1306 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1308 r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
1309 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1311 r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
1312 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1314 r = MsiEvaluateCondition(hpkg, "not 0");
1315 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1317 r = MsiEvaluateCondition(hpkg, "not LicView");
1318 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1320 r = MsiEvaluateCondition(hpkg, "\"Testing\" ~<< \"Testing\"");
1321 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1323 r = MsiEvaluateCondition(hpkg, "LicView ~<< \"Testing\"");
1324 ok (r == MSICONDITION_FALSE, "wrong return val\n");
1326 r = MsiEvaluateCondition(hpkg, "Not LicView ~<< \"Testing\"");
1327 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1329 r = MsiEvaluateCondition(hpkg, "not \"A\"");
1330 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1332 r = MsiEvaluateCondition(hpkg, "~not \"A\"");
1333 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1335 r = MsiEvaluateCondition(hpkg, "\"0\"");
1336 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1338 r = MsiEvaluateCondition(hpkg, "1 and 2");
1339 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1341 r = MsiEvaluateCondition(hpkg, "not 0 and 3");
1342 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1344 r = MsiEvaluateCondition(hpkg, "not 0 and 0");
1345 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1347 r = MsiEvaluateCondition(hpkg, "not 0 or 1");
1348 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1350 r = MsiEvaluateCondition(hpkg, "(0)");
1351 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1353 r = MsiEvaluateCondition(hpkg, "(((((1))))))");
1354 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1356 r = MsiEvaluateCondition(hpkg, "(((((1)))))");
1357 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1359 r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
1360 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1362 r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
1363 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1365 r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
1366 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1368 r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
1369 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1371 r = MsiEvaluateCondition(hpkg, "0 < > 0");
1372 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1374 r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
1375 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1377 r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
1378 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1380 r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
1381 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1383 r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
1384 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1386 r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
1387 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1389 r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
1390 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1392 r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
1393 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1395 r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
1396 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1398 r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
1399 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1401 r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
1402 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1404 r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
1405 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1407 r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
1408 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1410 r = MsiEvaluateCondition(hpkg, "1 XOR 1");
1411 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1413 r = MsiEvaluateCondition(hpkg, "1 IMP 1");
1414 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1416 r = MsiEvaluateCondition(hpkg, "1 IMP 0");
1417 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1419 r = MsiEvaluateCondition(hpkg, "0 IMP 0");
1420 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1422 r = MsiEvaluateCondition(hpkg, "0 EQV 0");
1423 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1425 r = MsiEvaluateCondition(hpkg, "0 EQV 1");
1426 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1428 r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
1429 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1431 r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
1432 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1434 r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
1435 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1437 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
1438 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1440 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
1441 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1443 r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
1444 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1446 MsiSetProperty(hpkg, "mm", "5" );
1448 r = MsiEvaluateCondition(hpkg, "mm = 5");
1449 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1451 r = MsiEvaluateCondition(hpkg, "mm < 6");
1452 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1454 r = MsiEvaluateCondition(hpkg, "mm <= 5");
1455 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1457 r = MsiEvaluateCondition(hpkg, "mm > 4");
1458 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1460 r = MsiEvaluateCondition(hpkg, "mm < 12");
1461 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1463 r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
1464 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1466 r = MsiEvaluateCondition(hpkg, "0 = \"\"");
1467 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1469 r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
1470 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1472 r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
1473 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1475 r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
1476 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1478 r = MsiEvaluateCondition(hpkg, "3 >< 1");
1479 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1481 r = MsiEvaluateCondition(hpkg, "3 >< 4");
1482 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1484 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
1485 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1487 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
1488 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1490 r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
1491 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1493 r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
1494 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1496 r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
1497 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1499 r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
1500 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1502 r = MsiEvaluateCondition(hpkg, "_1 = _1");
1503 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1505 r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
1506 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1508 r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
1509 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1511 r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1512 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1514 r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
1515 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1517 r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
1518 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1520 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1521 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1523 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1524 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1526 r = MsiEvaluateCondition(hpkg, "bandalmael<0");
1527 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1529 r = MsiEvaluateCondition(hpkg, "bandalmael>0");
1530 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1532 r = MsiEvaluateCondition(hpkg, "bandalmael>=0");
1533 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1535 r = MsiEvaluateCondition(hpkg, "bandalmael<=0");
1536 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1538 r = MsiEvaluateCondition(hpkg, "bandalmael~<>0");
1539 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1541 MsiSetProperty(hpkg, "bandalmael", "0" );
1542 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1543 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1545 MsiSetProperty(hpkg, "bandalmael", "" );
1546 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1547 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1549 MsiSetProperty(hpkg, "bandalmael", "asdf" );
1550 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1551 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1553 MsiSetProperty(hpkg, "bandalmael", "0asdf" );
1554 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1555 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1557 MsiSetProperty(hpkg, "bandalmael", "0 " );
1558 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1559 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1561 MsiSetProperty(hpkg, "bandalmael", "-0" );
1562 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1563 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1565 MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
1566 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1567 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1569 MsiSetProperty(hpkg, "bandalmael", "--0" );
1570 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1571 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1573 MsiSetProperty(hpkg, "bandalmael", "0x00" );
1574 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1575 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1577 MsiSetProperty(hpkg, "bandalmael", "-" );
1578 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1579 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1581 MsiSetProperty(hpkg, "bandalmael", "+0" );
1582 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1583 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1585 MsiSetProperty(hpkg, "bandalmael", "0.0" );
1586 r = MsiEvaluateCondition(hpkg, "bandalmael=0");
1587 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1588 r = MsiEvaluateCondition(hpkg, "bandalmael<>0");
1589 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1591 MsiSetProperty(hpkg, "one", "hi");
1592 MsiSetProperty(hpkg, "two", "hithere");
1593 r = MsiEvaluateCondition(hpkg, "one >< two");
1594 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1596 MsiSetProperty(hpkg, "one", "hithere");
1597 MsiSetProperty(hpkg, "two", "hi");
1598 r = MsiEvaluateCondition(hpkg, "one >< two");
1599 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1601 MsiSetProperty(hpkg, "one", "hello");
1602 MsiSetProperty(hpkg, "two", "hi");
1603 r = MsiEvaluateCondition(hpkg, "one >< two");
1604 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1606 MsiSetProperty(hpkg, "one", "hellohithere");
1607 MsiSetProperty(hpkg, "two", "hi");
1608 r = MsiEvaluateCondition(hpkg, "one >< two");
1609 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1611 MsiSetProperty(hpkg, "one", "");
1612 MsiSetProperty(hpkg, "two", "hi");
1613 r = MsiEvaluateCondition(hpkg, "one >< two");
1614 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1616 MsiSetProperty(hpkg, "one", "hi");
1617 MsiSetProperty(hpkg, "two", "");
1618 r = MsiEvaluateCondition(hpkg, "one >< two");
1619 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1621 MsiSetProperty(hpkg, "one", "");
1622 MsiSetProperty(hpkg, "two", "");
1623 r = MsiEvaluateCondition(hpkg, "one >< two");
1624 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1626 MsiSetProperty(hpkg, "one", "1234");
1627 MsiSetProperty(hpkg, "two", "1");
1628 r = MsiEvaluateCondition(hpkg, "one >< two");
1629 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1631 MsiSetProperty(hpkg, "one", "one 1234");
1632 MsiSetProperty(hpkg, "two", "1");
1633 r = MsiEvaluateCondition(hpkg, "one >< two");
1634 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1636 MsiSetProperty(hpkg, "one", "hithere");
1637 MsiSetProperty(hpkg, "two", "hi");
1638 r = MsiEvaluateCondition(hpkg, "one << two");
1639 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1641 MsiSetProperty(hpkg, "one", "hi");
1642 MsiSetProperty(hpkg, "two", "hithere");
1643 r = MsiEvaluateCondition(hpkg, "one << two");
1644 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1646 MsiSetProperty(hpkg, "one", "hi");
1647 MsiSetProperty(hpkg, "two", "hi");
1648 r = MsiEvaluateCondition(hpkg, "one << two");
1649 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1651 MsiSetProperty(hpkg, "one", "abcdhithere");
1652 MsiSetProperty(hpkg, "two", "hi");
1653 r = MsiEvaluateCondition(hpkg, "one << two");
1654 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1656 MsiSetProperty(hpkg, "one", "");
1657 MsiSetProperty(hpkg, "two", "hi");
1658 r = MsiEvaluateCondition(hpkg, "one << two");
1659 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1661 MsiSetProperty(hpkg, "one", "hithere");
1662 MsiSetProperty(hpkg, "two", "");
1663 r = MsiEvaluateCondition(hpkg, "one << two");
1664 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1666 MsiSetProperty(hpkg, "one", "");
1667 MsiSetProperty(hpkg, "two", "");
1668 r = MsiEvaluateCondition(hpkg, "one << two");
1669 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1671 MsiSetProperty(hpkg, "one", "1234");
1672 MsiSetProperty(hpkg, "two", "1");
1673 r = MsiEvaluateCondition(hpkg, "one << two");
1674 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1676 MsiSetProperty(hpkg, "one", "1234 one");
1677 MsiSetProperty(hpkg, "two", "1");
1678 r = MsiEvaluateCondition(hpkg, "one << two");
1679 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1681 MsiSetProperty(hpkg, "one", "hithere");
1682 MsiSetProperty(hpkg, "two", "there");
1683 r = MsiEvaluateCondition(hpkg, "one >> two");
1684 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1686 MsiSetProperty(hpkg, "one", "hithere");
1687 MsiSetProperty(hpkg, "two", "hi");
1688 r = MsiEvaluateCondition(hpkg, "one >> two");
1689 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1691 MsiSetProperty(hpkg, "one", "there");
1692 MsiSetProperty(hpkg, "two", "hithere");
1693 r = MsiEvaluateCondition(hpkg, "one >> two");
1694 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1696 MsiSetProperty(hpkg, "one", "there");
1697 MsiSetProperty(hpkg, "two", "there");
1698 r = MsiEvaluateCondition(hpkg, "one >> two");
1699 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1701 MsiSetProperty(hpkg, "one", "abcdhithere");
1702 MsiSetProperty(hpkg, "two", "hi");
1703 r = MsiEvaluateCondition(hpkg, "one >> two");
1704 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1706 MsiSetProperty(hpkg, "one", "");
1707 MsiSetProperty(hpkg, "two", "there");
1708 r = MsiEvaluateCondition(hpkg, "one >> two");
1709 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1711 MsiSetProperty(hpkg, "one", "there");
1712 MsiSetProperty(hpkg, "two", "");
1713 r = MsiEvaluateCondition(hpkg, "one >> two");
1714 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1716 MsiSetProperty(hpkg, "one", "");
1717 MsiSetProperty(hpkg, "two", "");
1718 r = MsiEvaluateCondition(hpkg, "one >> two");
1719 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1721 MsiSetProperty(hpkg, "one", "1234");
1722 MsiSetProperty(hpkg, "two", "4");
1723 r = MsiEvaluateCondition(hpkg, "one >> two");
1724 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1726 MsiSetProperty(hpkg, "one", "one 1234");
1727 MsiSetProperty(hpkg, "two", "4");
1728 r = MsiEvaluateCondition(hpkg, "one >> two");
1729 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1731 MsiSetProperty(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1733 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1734 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1736 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1737 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1739 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1740 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1742 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1743 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1745 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1746 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1748 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1749 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1751 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1752 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1754 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1755 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1757 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1758 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1760 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1761 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1763 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1764 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1766 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1767 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1769 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1");
1770 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1772 r = MsiEvaluateCondition(hpkg, "\"2\" < \"1.1\"");
1773 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1775 r = MsiEvaluateCondition(hpkg, "\"2\" < \"12.1\"");
1776 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1778 r = MsiEvaluateCondition(hpkg, "\"02.1\" < \"2.11\"");
1779 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1781 r = MsiEvaluateCondition(hpkg, "\"02.1.1\" < \"2.1\"");
1782 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1784 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1785 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1787 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1788 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1790 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"0\"");
1791 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1793 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"-1\"");
1794 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1796 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a\"");
1797 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1799 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1800 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1802 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"!\"");
1803 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1805 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"/\"");
1806 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1808 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \" \"");
1809 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1811 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1812 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1814 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1815 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1817 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1818 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1820 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1821 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1823 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1824 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1826 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1827 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1829 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"{a\"");
1830 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1832 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"[a\"");
1833 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1835 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a{\"");
1836 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1838 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"a]\"");
1839 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1841 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"A\"");
1842 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1844 MsiSetProperty(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1845 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1846 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1848 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1849 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1851 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1852 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1854 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1855 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1857 r = MsiEvaluateCondition(hpkg, "MsiNetAssemblySupport < \"1\"");
1858 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1860 MsiSetProperty(hpkg, "one", "1");
1861 r = MsiEvaluateCondition(hpkg, "one < \"1\"");
1862 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1864 MsiSetProperty(hpkg, "X", "5.0");
1866 r = MsiEvaluateCondition(hpkg, "X != \"\"");
1867 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1869 r = MsiEvaluateCondition(hpkg, "X =\"5.0\"");
1870 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1872 r = MsiEvaluateCondition(hpkg, "X =\"5.1\"");
1873 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1875 r = MsiEvaluateCondition(hpkg, "X =\"6.0\"");
1876 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1878 r = MsiEvaluateCondition(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1879 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1881 r = MsiEvaluateCondition(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1882 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1884 r = MsiEvaluateCondition(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1885 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1887 /* feature doesn't exist */
1888 r = MsiEvaluateCondition(hpkg, "&nofeature");
1889 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1891 MsiSetProperty(hpkg, "A", "2");
1892 MsiSetProperty(hpkg, "X", "50");
1894 r = MsiEvaluateCondition(hpkg, "2 <= X");
1895 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1897 r = MsiEvaluateCondition(hpkg, "A <= X");
1898 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1900 r = MsiEvaluateCondition(hpkg, "A <= 50");
1901 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1903 MsiSetProperty(hpkg, "X", "50val");
1905 r = MsiEvaluateCondition(hpkg, "2 <= X");
1906 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1908 r = MsiEvaluateCondition(hpkg, "A <= X");
1909 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1911 MsiSetProperty(hpkg, "A", "7");
1912 MsiSetProperty(hpkg, "X", "50");
1914 r = MsiEvaluateCondition(hpkg, "7 <= X");
1915 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1917 r = MsiEvaluateCondition(hpkg, "A <= X");
1918 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1920 r = MsiEvaluateCondition(hpkg, "A <= 50");
1921 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1923 MsiSetProperty(hpkg, "X", "50val");
1925 r = MsiEvaluateCondition(hpkg, "2 <= X");
1926 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1928 r = MsiEvaluateCondition(hpkg, "A <= X");
1929 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1931 r = MsiEvaluateConditionW(hpkg, cond1);
1932 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1933 "wrong return val (%d)\n", r);
1935 r = MsiEvaluateConditionW(hpkg, cond2);
1936 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1937 "wrong return val (%d)\n", r);
1939 r = MsiEvaluateConditionW(hpkg, cond3);
1940 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1941 "wrong return val (%d)\n", r);
1943 r = MsiEvaluateConditionW(hpkg, cond4);
1944 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1945 "wrong return val (%d)\n", r);
1947 MsiCloseHandle( hpkg );
1948 DeleteFile(msifile);
1951 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
1953 UINT r;
1954 DWORD sz;
1955 char buffer[2];
1957 sz = sizeof buffer;
1958 strcpy(buffer,"x");
1959 r = MsiGetProperty( hpkg, prop, buffer, &sz );
1960 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
1963 static void test_props(void)
1965 MSIHANDLE hpkg, hdb;
1966 UINT r;
1967 DWORD sz;
1968 char buffer[0x100];
1970 hdb = create_package_db();
1971 r = run_query( hdb,
1972 "CREATE TABLE `Property` ( "
1973 "`Property` CHAR(255) NOT NULL, "
1974 "`Value` CHAR(255) "
1975 "PRIMARY KEY `Property`)" );
1976 ok( r == ERROR_SUCCESS , "Failed\n" );
1978 r = run_query(hdb,
1979 "INSERT INTO `Property` "
1980 "(`Property`, `Value`) "
1981 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
1982 ok( r == ERROR_SUCCESS , "Failed\n" );
1984 r = package_from_db( hdb, &hpkg );
1985 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1987 skip("Not enough rights to perform tests\n");
1988 DeleteFile(msifile);
1989 return;
1991 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1993 /* test invalid values */
1994 r = MsiGetProperty( 0, NULL, NULL, NULL );
1995 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1997 r = MsiGetProperty( hpkg, NULL, NULL, NULL );
1998 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2000 r = MsiGetProperty( hpkg, "boo", NULL, NULL );
2001 ok( r == ERROR_SUCCESS, "wrong return val\n");
2003 r = MsiGetProperty( hpkg, "boo", buffer, NULL );
2004 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2006 /* test retrieving an empty/nonexistent property */
2007 sz = sizeof buffer;
2008 r = MsiGetProperty( hpkg, "boo", NULL, &sz );
2009 ok( r == ERROR_SUCCESS, "wrong return val\n");
2010 ok( sz == 0, "wrong size returned\n");
2012 check_prop_empty( hpkg, "boo");
2013 sz = 0;
2014 strcpy(buffer,"x");
2015 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2016 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2017 ok( !strcmp(buffer,"x"), "buffer was changed\n");
2018 ok( sz == 0, "wrong size returned\n");
2020 sz = 1;
2021 strcpy(buffer,"x");
2022 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2023 ok( r == ERROR_SUCCESS, "wrong return val\n");
2024 ok( buffer[0] == 0, "buffer was not changed\n");
2025 ok( sz == 0, "wrong size returned\n");
2027 /* set the property to something */
2028 r = MsiSetProperty( 0, NULL, NULL );
2029 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
2031 r = MsiSetProperty( hpkg, NULL, NULL );
2032 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2034 r = MsiSetProperty( hpkg, "", NULL );
2035 ok( r == ERROR_SUCCESS, "wrong return val\n");
2037 /* try set and get some illegal property identifiers */
2038 r = MsiSetProperty( hpkg, "", "asdf" );
2039 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2041 r = MsiSetProperty( hpkg, "=", "asdf" );
2042 ok( r == ERROR_SUCCESS, "wrong return val\n");
2044 r = MsiSetProperty( hpkg, " ", "asdf" );
2045 ok( r == ERROR_SUCCESS, "wrong return val\n");
2047 r = MsiSetProperty( hpkg, "'", "asdf" );
2048 ok( r == ERROR_SUCCESS, "wrong return val\n");
2050 sz = sizeof buffer;
2051 buffer[0]=0;
2052 r = MsiGetProperty( hpkg, "'", buffer, &sz );
2053 ok( r == ERROR_SUCCESS, "wrong return val\n");
2054 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2056 /* set empty values */
2057 r = MsiSetProperty( hpkg, "boo", NULL );
2058 ok( r == ERROR_SUCCESS, "wrong return val\n");
2059 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2061 r = MsiSetProperty( hpkg, "boo", "" );
2062 ok( r == ERROR_SUCCESS, "wrong return val\n");
2063 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2065 /* set a non-empty value */
2066 r = MsiSetProperty( hpkg, "boo", "xyz" );
2067 ok( r == ERROR_SUCCESS, "wrong return val\n");
2069 sz = 1;
2070 strcpy(buffer,"x");
2071 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2072 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2073 ok( buffer[0] == 0, "buffer was not changed\n");
2074 ok( sz == 3, "wrong size returned\n");
2076 sz = 4;
2077 strcpy(buffer,"x");
2078 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2079 ok( r == ERROR_SUCCESS, "wrong return val\n");
2080 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2081 ok( sz == 3, "wrong size returned\n");
2083 sz = 3;
2084 strcpy(buffer,"x");
2085 r = MsiGetProperty( hpkg, "boo", buffer, &sz );
2086 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2087 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2088 ok( sz == 3, "wrong size returned\n");
2090 r = MsiSetProperty(hpkg, "SourceDir", "foo");
2091 ok( r == ERROR_SUCCESS, "wrong return val\n");
2093 sz = 4;
2094 r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
2095 ok( r == ERROR_SUCCESS, "wrong return val\n");
2096 ok( !strcmp(buffer,""), "buffer wrong\n");
2097 ok( sz == 0, "wrong size returned\n");
2099 sz = 4;
2100 r = MsiGetProperty(hpkg, "SOMERANDOMNAME", buffer, &sz);
2101 ok( r == ERROR_SUCCESS, "wrong return val\n");
2102 ok( !strcmp(buffer,""), "buffer wrong\n");
2103 ok( sz == 0, "wrong size returned\n");
2105 sz = 4;
2106 r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
2107 ok( r == ERROR_SUCCESS, "wrong return val\n");
2108 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2109 ok( sz == 3, "wrong size returned\n");
2111 r = MsiSetProperty(hpkg, "MetadataCompName", "Photoshop.dll");
2112 ok( r == ERROR_SUCCESS, "wrong return val\n");
2114 sz = 0;
2115 r = MsiGetProperty(hpkg, "MetadataCompName", NULL, &sz );
2116 ok( r == ERROR_SUCCESS, "return wrong\n");
2117 ok( sz == 13, "size wrong (%d)\n", sz);
2119 sz = 13;
2120 r = MsiGetProperty(hpkg, "MetadataCompName", buffer, &sz );
2121 ok( r == ERROR_MORE_DATA, "return wrong\n");
2122 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2124 r = MsiSetProperty(hpkg, "property", "value");
2125 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2127 sz = 6;
2128 r = MsiGetProperty(hpkg, "property", buffer, &sz);
2129 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2130 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2132 r = MsiSetProperty(hpkg, "property", NULL);
2133 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2135 sz = 6;
2136 r = MsiGetProperty(hpkg, "property", buffer, &sz);
2137 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2138 ok( !strlen(buffer), "Expected empty string, got %s\n", buffer);
2140 MsiCloseHandle( hpkg );
2141 DeleteFile(msifile);
2144 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val)
2146 MSIHANDLE hview, hrec;
2147 BOOL found;
2148 CHAR buffer[MAX_PATH];
2149 DWORD sz;
2150 UINT r;
2152 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
2153 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2154 r = MsiViewExecute(hview, 0);
2155 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2157 found = FALSE;
2158 while (r == ERROR_SUCCESS && !found)
2160 r = MsiViewFetch(hview, &hrec);
2161 if (r != ERROR_SUCCESS) break;
2163 sz = MAX_PATH;
2164 r = MsiRecordGetString(hrec, 1, buffer, &sz);
2165 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2167 sz = MAX_PATH;
2168 r = MsiRecordGetString(hrec, 2, buffer, &sz);
2169 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, val))
2170 found = TRUE;
2173 MsiCloseHandle(hrec);
2176 MsiViewClose(hview);
2177 MsiCloseHandle(hview);
2179 return found;
2182 static void test_property_table(void)
2184 const char *query;
2185 UINT r;
2186 MSIHANDLE hpkg, hdb, hrec;
2187 char buffer[MAX_PATH], package[10];
2188 DWORD sz;
2189 BOOL found;
2191 hdb = create_package_db();
2192 ok( hdb, "failed to create package\n");
2194 r = package_from_db(hdb, &hpkg);
2195 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2197 skip("Not enough rights to perform tests\n");
2198 DeleteFile(msifile);
2199 return;
2201 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2203 MsiCloseHandle(hdb);
2205 hdb = MsiGetActiveDatabase(hpkg);
2207 query = "CREATE TABLE `_Property` ( "
2208 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2209 r = run_query(hdb, query);
2210 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2212 MsiCloseHandle(hdb);
2213 MsiCloseHandle(hpkg);
2214 DeleteFile(msifile);
2216 hdb = create_package_db();
2217 ok( hdb, "failed to create package\n");
2219 query = "CREATE TABLE `_Property` ( "
2220 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2221 r = run_query(hdb, query);
2222 ok(r == ERROR_SUCCESS, "failed to create table\n");
2224 query = "ALTER `_Property` ADD `foo` INTEGER";
2225 r = run_query(hdb, query);
2226 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2228 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2229 r = run_query(hdb, query);
2230 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2232 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2233 r = run_query(hdb, query);
2234 ok(r == ERROR_SUCCESS, "failed to add column\n");
2236 sprintf(package, "#%i", hdb);
2237 r = MsiOpenPackage(package, &hpkg);
2238 todo_wine ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2239 if (r == ERROR_SUCCESS)
2240 MsiCloseHandle(hpkg);
2242 r = MsiCloseHandle(hdb);
2243 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2245 hdb = create_package_db();
2246 ok (hdb, "failed to create package database\n");
2248 r = create_property_table(hdb);
2249 ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2251 r = add_property_entry(hdb, "'prop', 'val'");
2252 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2254 r = package_from_db(hdb, &hpkg);
2255 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2257 MsiCloseHandle(hdb);
2259 sz = MAX_PATH;
2260 r = MsiGetProperty(hpkg, "prop", buffer, &sz);
2261 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2262 ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
2264 hdb = MsiGetActiveDatabase(hpkg);
2266 found = find_prop_in_property(hdb, "prop", "val");
2267 ok(found, "prop should be in the _Property table\n");
2269 r = add_property_entry(hdb, "'dantes', 'mercedes'");
2270 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2272 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2273 r = do_query(hdb, query, &hrec);
2274 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2276 found = find_prop_in_property(hdb, "dantes", "mercedes");
2277 ok(found == FALSE, "dantes should not be in the _Property table\n");
2279 sz = MAX_PATH;
2280 lstrcpy(buffer, "aaa");
2281 r = MsiGetProperty(hpkg, "dantes", buffer, &sz);
2282 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2283 ok(lstrlenA(buffer) == 0, "Expected empty string, got %s\n", buffer);
2285 r = MsiSetProperty(hpkg, "dantes", "mercedes");
2286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2288 found = find_prop_in_property(hdb, "dantes", "mercedes");
2289 ok(found == TRUE, "dantes should be in the _Property table\n");
2291 MsiCloseHandle(hdb);
2292 MsiCloseHandle(hpkg);
2293 DeleteFile(msifile);
2296 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2298 MSIHANDLE htab = 0;
2299 UINT res;
2301 res = MsiDatabaseOpenView( hdb, szQuery, &htab );
2302 if( res == ERROR_SUCCESS )
2304 UINT r;
2306 r = MsiViewExecute( htab, hrec );
2307 if( r != ERROR_SUCCESS )
2309 res = r;
2310 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2313 r = MsiViewClose( htab );
2314 if( r != ERROR_SUCCESS )
2315 res = r;
2317 r = MsiCloseHandle( htab );
2318 if( r != ERROR_SUCCESS )
2319 res = r;
2321 return res;
2324 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2326 return try_query_param( hdb, szQuery, 0 );
2329 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2331 MSIHANDLE summary;
2332 UINT r;
2334 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2337 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2338 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2340 r = MsiSummaryInfoPersist(summary);
2341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2343 MsiCloseHandle(summary);
2346 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2348 MSIHANDLE summary;
2349 UINT r;
2351 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2354 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2357 r = MsiSummaryInfoPersist(summary);
2358 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2360 MsiCloseHandle(summary);
2363 static void test_msipackage(void)
2365 MSIHANDLE hdb = 0, hpack = 100;
2366 UINT r;
2367 const char *query;
2368 char name[10];
2370 /* NULL szPackagePath */
2371 r = MsiOpenPackage(NULL, &hpack);
2372 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2374 /* empty szPackagePath */
2375 r = MsiOpenPackage("", &hpack);
2376 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2378 skip("Not enough rights to perform tests\n");
2379 return;
2381 todo_wine
2383 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2386 if (r == ERROR_SUCCESS)
2387 MsiCloseHandle(hpack);
2389 /* nonexistent szPackagePath */
2390 r = MsiOpenPackage("nonexistent", &hpack);
2391 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2393 /* NULL hProduct */
2394 r = MsiOpenPackage(msifile, NULL);
2395 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2397 name[0]='#';
2398 name[1]=0;
2399 r = MsiOpenPackage(name, &hpack);
2400 ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2402 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2403 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2405 /* database exists, but is emtpy */
2406 sprintf(name, "#%d", hdb);
2407 r = MsiOpenPackage(name, &hpack);
2408 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2409 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2411 query = "CREATE TABLE `Property` ( "
2412 "`Property` CHAR(72), `Value` CHAR(0) "
2413 "PRIMARY KEY `Property`)";
2414 r = try_query(hdb, query);
2415 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2417 query = "CREATE TABLE `InstallExecuteSequence` ("
2418 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2419 "PRIMARY KEY `Action`)";
2420 r = try_query(hdb, query);
2421 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2423 /* a few key tables exist */
2424 sprintf(name, "#%d", hdb);
2425 r = MsiOpenPackage(name, &hpack);
2426 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2427 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2429 MsiCloseHandle(hdb);
2430 DeleteFile(msifile);
2432 /* start with a clean database to show what constitutes a valid package */
2433 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
2434 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2436 sprintf(name, "#%d", hdb);
2438 /* The following summary information props must exist:
2439 * - PID_REVNUMBER
2440 * - PID_PAGECOUNT
2443 set_summary_dword(hdb, PID_PAGECOUNT, 100);
2444 r = MsiOpenPackage(name, &hpack);
2445 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2446 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2448 set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49c2-AD20-28E1CE0DF5F2}");
2449 r = MsiOpenPackage(name, &hpack);
2450 ok(r == ERROR_SUCCESS,
2451 "Expected ERROR_SUCCESS, got %d\n", r);
2453 MsiCloseHandle(hpack);
2454 MsiCloseHandle(hdb);
2455 DeleteFile(msifile);
2458 static void test_formatrecord2(void)
2460 MSIHANDLE hpkg, hrec ;
2461 char buffer[0x100];
2462 DWORD sz;
2463 UINT r;
2465 r = package_from_db(create_package_db(), &hpkg);
2466 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2468 skip("Not enough rights to perform tests\n");
2469 DeleteFile(msifile);
2470 return;
2472 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2474 r = MsiSetProperty(hpkg, "Manufacturer", " " );
2475 ok( r == ERROR_SUCCESS, "set property failed\n");
2477 hrec = MsiCreateRecord(2);
2478 ok(hrec, "create record failed\n");
2480 r = MsiRecordSetString( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2481 ok( r == ERROR_SUCCESS, "format record failed\n");
2483 buffer[0] = 0;
2484 sz = sizeof buffer;
2485 r = MsiFormatRecord( hpkg, hrec, buffer, &sz );
2486 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2488 r = MsiRecordSetString(hrec, 0, "[foo][1]");
2489 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2490 r = MsiRecordSetString(hrec, 1, "hoo");
2491 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2492 sz = sizeof buffer;
2493 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2494 ok( sz == 3, "size wrong\n");
2495 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2496 ok( r == ERROR_SUCCESS, "format failed\n");
2498 r = MsiRecordSetString(hrec, 0, "x[~]x");
2499 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2500 sz = sizeof buffer;
2501 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2502 ok( sz == 3, "size wrong\n");
2503 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2504 ok( r == ERROR_SUCCESS, "format failed\n");
2506 r = MsiRecordSetString(hrec, 0, "[foo.$%}][1]");
2507 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2508 r = MsiRecordSetString(hrec, 1, "hoo");
2509 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2510 sz = sizeof buffer;
2511 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2512 ok( sz == 3, "size wrong\n");
2513 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2514 ok( r == ERROR_SUCCESS, "format failed\n");
2516 r = MsiRecordSetString(hrec, 0, "[\\[]");
2517 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2518 sz = sizeof buffer;
2519 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2520 ok( sz == 1, "size wrong\n");
2521 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2522 ok( r == ERROR_SUCCESS, "format failed\n");
2524 SetEnvironmentVariable("FOO", "BAR");
2525 r = MsiRecordSetString(hrec, 0, "[%FOO]");
2526 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2527 sz = sizeof buffer;
2528 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2529 ok( sz == 3, "size wrong\n");
2530 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2531 ok( r == ERROR_SUCCESS, "format failed\n");
2533 r = MsiRecordSetString(hrec, 0, "[[1]]");
2534 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2535 r = MsiRecordSetString(hrec, 1, "%FOO");
2536 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2537 sz = sizeof buffer;
2538 r = MsiFormatRecord(hpkg, hrec, buffer, &sz);
2539 ok( sz == 3, "size wrong\n");
2540 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2541 ok( r == ERROR_SUCCESS, "format failed\n");
2543 MsiCloseHandle( hrec );
2544 MsiCloseHandle( hpkg );
2545 DeleteFile(msifile);
2548 static void test_feature_states( UINT line, MSIHANDLE package, const char *feature, UINT error,
2549 INSTALLSTATE expected_state, INSTALLSTATE expected_action, int todo )
2551 UINT r;
2552 INSTALLSTATE state = 0xdeadbee;
2553 INSTALLSTATE action = 0xdeadbee;
2555 r = MsiGetFeatureState( package, feature, &state, &action );
2556 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2557 if (r == ERROR_SUCCESS)
2559 ok( state == expected_state, "%u: expected state %d got %d\n",
2560 line, expected_state, state );
2561 if (todo) todo_wine
2562 ok( action == expected_action, "%u: expected action %d got %d\n",
2563 line, expected_action, action );
2564 else
2565 ok( action == expected_action, "%u: expected action %d got %d\n",
2566 line, expected_action, action );
2568 else
2570 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line, state );
2571 if (todo) todo_wine
2572 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2573 else
2574 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2579 static void test_component_states( UINT line, MSIHANDLE package, const char *component, UINT error,
2580 INSTALLSTATE expected_state, INSTALLSTATE expected_action, int todo )
2582 UINT r;
2583 INSTALLSTATE state = 0xdeadbee;
2584 INSTALLSTATE action = 0xdeadbee;
2586 r = MsiGetComponentState( package, component, &state, &action );
2587 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2588 if (r == ERROR_SUCCESS)
2590 ok( state == expected_state, "%u: expected state %d got %d\n",
2591 line, expected_state, state );
2592 if (todo) todo_wine
2593 ok( action == expected_action, "%u: expected action %d got %d\n",
2594 line, expected_action, action );
2595 else
2596 ok( action == expected_action, "%u: expected action %d got %d\n",
2597 line, expected_action, action );
2599 else
2601 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2602 line, state );
2603 if (todo) todo_wine
2604 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2605 line, action );
2606 else
2607 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2608 line, action );
2612 static void test_states(void)
2614 static char msifile2[] = "winetest2-package.msi";
2615 static char msifile3[] = "winetest3-package.msi";
2616 static char msifile4[] = "winetest4-package.msi";
2617 MSIHANDLE hpkg;
2618 UINT r;
2619 MSIHANDLE hdb;
2621 if (is_process_limited())
2623 skip("process is limited\n");
2624 return;
2627 hdb = create_package_db();
2628 ok ( hdb, "failed to create package database\n" );
2630 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2631 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2633 r = create_property_table( hdb );
2634 ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2636 r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2637 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2639 r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2640 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2642 r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2643 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2645 r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2646 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2648 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2649 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2651 r = create_install_execute_sequence_table( hdb );
2652 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2654 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2655 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2657 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2658 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2660 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2661 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2663 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2664 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2666 r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2667 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2669 r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2670 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2672 r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2673 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2675 r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2676 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2678 r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2679 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2681 r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2682 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2684 r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2685 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2687 r = create_media_table( hdb );
2688 ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2690 r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2691 ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2693 r = create_feature_table( hdb );
2694 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2696 r = create_component_table( hdb );
2697 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2699 /* msidbFeatureAttributesFavorLocal */
2700 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2701 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2703 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2704 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2705 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2707 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2708 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2709 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2711 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2712 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2713 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2715 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2716 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2717 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2719 /* msidbFeatureAttributesFavorSource */
2720 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2721 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2723 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2724 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2725 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2727 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2728 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2729 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2731 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2732 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2733 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2735 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2736 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2737 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2739 /* msidbFeatureAttributesFavorSource */
2740 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2741 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2743 /* msidbFeatureAttributesFavorLocal */
2744 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2745 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2747 /* disabled */
2748 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2749 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2751 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2752 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2753 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2755 /* no feature parent:msidbComponentAttributesLocalOnly */
2756 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2757 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2759 /* msidbFeatureAttributesFavorLocal:removed */
2760 r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2761 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2763 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2764 r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2765 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2767 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2768 r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2769 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2771 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2772 r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2773 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2775 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2776 r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2777 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2779 /* msidbFeatureAttributesFavorSource:removed */
2780 r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2781 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2783 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2784 r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2785 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2787 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2788 r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2789 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2791 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2792 r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2793 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2795 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2796 r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2797 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2799 /* msidbFeatureAttributesFavorLocal */
2800 r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2801 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2803 r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2804 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2806 /* msidbFeatureAttributesFavorSource */
2807 r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2808 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2810 r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2811 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2813 /* msidbFeatureAttributesFavorAdvertise */
2814 r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2815 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2817 r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2818 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2820 /* msidbFeatureAttributesUIDisallowAbsent */
2821 r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2822 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2824 r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2825 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2827 r = create_feature_components_table( hdb );
2828 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2830 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2831 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2833 r = add_feature_components_entry( hdb, "'one', 'beta'" );
2834 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2836 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2837 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2839 r = add_feature_components_entry( hdb, "'one', 'theta'" );
2840 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2842 r = add_feature_components_entry( hdb, "'two', 'delta'" );
2843 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2845 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2846 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2848 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2849 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2851 r = add_feature_components_entry( hdb, "'two', 'iota'" );
2852 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2854 r = add_feature_components_entry( hdb, "'three', 'eta'" );
2855 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2857 r = add_feature_components_entry( hdb, "'four', 'eta'" );
2858 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2860 r = add_feature_components_entry( hdb, "'five', 'eta'" );
2861 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2863 r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2864 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2866 r = add_feature_components_entry( hdb, "'six', 'mu'" );
2867 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2869 r = add_feature_components_entry( hdb, "'six', 'nu'" );
2870 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2872 r = add_feature_components_entry( hdb, "'six', 'xi'" );
2873 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2875 r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2876 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2878 r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2879 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2881 r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2882 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2884 r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2885 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2887 r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2888 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2890 r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2891 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2893 r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2894 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2896 r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
2897 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2899 r = create_file_table( hdb );
2900 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2902 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2903 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2905 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
2906 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2908 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
2909 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2911 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
2912 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2914 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
2915 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2917 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
2918 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2920 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
2921 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2923 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
2924 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2926 /* compressed file */
2927 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
2928 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2930 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
2931 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2933 r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
2934 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2936 r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
2937 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2939 r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
2940 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2942 r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
2943 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2945 r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
2946 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2948 r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
2949 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2951 r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
2952 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2954 r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
2955 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2957 r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
2958 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2960 r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
2961 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2963 r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
2964 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2966 r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
2967 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
2969 MsiDatabaseCommit(hdb);
2971 /* these properties must not be in the saved msi file */
2972 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
2973 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2975 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
2976 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2978 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
2979 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2981 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
2982 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2984 r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
2985 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
2987 r = package_from_db( hdb, &hpkg );
2988 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2990 skip("Not enough rights to perform tests\n");
2991 DeleteFile(msifile);
2992 return;
2994 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
2996 MsiCloseHandle(hdb);
2998 CopyFileA(msifile, msifile2, FALSE);
2999 CopyFileA(msifile, msifile3, FALSE);
3000 CopyFileA(msifile, msifile4, FALSE);
3002 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3003 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3005 r = MsiDoAction( hpkg, "CostInitialize");
3006 ok( r == ERROR_SUCCESS, "cost init failed\n");
3008 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3009 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3011 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3013 r = MsiDoAction( hpkg, "FileCost");
3014 ok( r == ERROR_SUCCESS, "file cost failed\n");
3016 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3017 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3019 r = MsiDoAction( hpkg, "CostFinalize");
3020 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3022 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3023 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3024 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3025 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3026 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3027 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3028 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3029 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3030 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3031 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3032 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3034 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3035 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3036 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3037 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3038 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3039 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3040 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
3041 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3042 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
3043 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3044 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3045 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3046 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3047 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3048 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3049 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3050 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3051 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3052 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3053 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3054 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3055 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3057 MsiCloseHandle( hpkg );
3059 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3061 /* publish the features and components */
3062 r = MsiInstallProduct(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3063 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3065 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
3066 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3068 /* these properties must not be in the saved msi file */
3069 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3070 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3072 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3073 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3075 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3076 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3078 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3079 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3081 r = package_from_db( hdb, &hpkg );
3082 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3084 MsiCloseHandle(hdb);
3086 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3087 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3089 r = MsiDoAction( hpkg, "CostInitialize");
3090 ok( r == ERROR_SUCCESS, "cost init failed\n");
3092 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3093 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3095 r = MsiDoAction( hpkg, "FileCost");
3096 ok( r == ERROR_SUCCESS, "file cost failed\n");
3098 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3099 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3101 r = MsiDoAction( hpkg, "CostFinalize");
3102 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3104 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3105 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3106 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3107 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3108 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3109 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3110 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3111 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3112 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3113 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3114 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3116 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3117 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3118 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3119 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3120 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3121 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3122 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3123 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3124 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3125 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3126 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3127 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3128 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3129 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3130 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3131 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3132 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3133 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3134 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3135 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3136 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3137 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3139 MsiCloseHandle(hpkg);
3141 /* uninstall the product */
3142 r = MsiInstallProduct(msifile, "REMOVE=ALL");
3143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3145 /* all features installed locally */
3146 r = MsiInstallProduct(msifile2, "ADDLOCAL=ALL");
3147 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3149 r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb);
3150 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3152 /* these properties must not be in the saved msi file */
3153 r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3154 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3156 r = package_from_db( hdb, &hpkg );
3157 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3159 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3160 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3162 r = MsiDoAction( hpkg, "CostInitialize");
3163 ok( r == ERROR_SUCCESS, "cost init failed\n");
3165 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3166 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3168 r = MsiDoAction( hpkg, "CostFinalize");
3169 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3171 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3172 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3173 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3174 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3175 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3176 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3177 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, 0 );
3178 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3179 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3180 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 1 );
3181 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3183 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3184 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3185 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3186 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3187 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3188 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3189 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3190 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3191 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3192 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3193 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3194 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3195 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3196 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3197 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3198 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3199 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3200 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3201 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3202 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3203 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3204 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3206 MsiCloseHandle(hpkg);
3208 /* uninstall the product */
3209 r = MsiInstallProduct(msifile2, "REMOVE=ALL");
3210 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3212 /* all features installed from source */
3213 r = MsiInstallProduct(msifile3, "ADDSOURCE=ALL");
3214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3216 r = MsiOpenDatabase(msifile3, MSIDBOPEN_DIRECT, &hdb);
3217 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3219 /* this property must not be in the saved msi file */
3220 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3221 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3223 r = package_from_db( hdb, &hpkg );
3224 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3226 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3227 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3229 r = MsiDoAction( hpkg, "CostInitialize");
3230 ok( r == ERROR_SUCCESS, "cost init failed\n");
3232 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3233 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3235 r = MsiDoAction( hpkg, "FileCost");
3236 ok( r == ERROR_SUCCESS, "file cost failed\n");
3238 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3239 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3241 r = MsiDoAction( hpkg, "CostFinalize");
3242 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3244 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3245 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3246 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3247 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3248 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3249 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3250 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3251 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3252 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3253 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3254 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3256 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3257 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3258 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3259 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3260 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3261 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3262 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3263 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3264 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3265 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3266 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3267 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3268 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3269 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3270 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3271 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3272 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3273 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3274 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3275 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3276 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3277 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3279 MsiCloseHandle(hpkg);
3281 /* reinstall the product */
3282 r = MsiInstallProduct(msifile3, "REINSTALL=ALL");
3283 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3285 r = MsiOpenDatabase(msifile4, MSIDBOPEN_DIRECT, &hdb);
3286 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3288 /* this property must not be in the saved msi file */
3289 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3290 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3292 r = package_from_db( hdb, &hpkg );
3293 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3295 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, 0 );
3296 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, 0 );
3298 r = MsiDoAction( hpkg, "CostInitialize");
3299 ok( r == ERROR_SUCCESS, "cost init failed\n");
3301 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3302 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3304 r = MsiDoAction( hpkg, "FileCost");
3305 ok( r == ERROR_SUCCESS, "file cost failed\n");
3307 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3308 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
3310 r = MsiDoAction( hpkg, "CostFinalize");
3311 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3313 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3314 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3315 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3316 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3317 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3318 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3319 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3320 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3321 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3322 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, 0 );
3323 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 1 );
3325 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3326 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3327 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3328 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3329 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3330 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3331 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3332 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3333 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3334 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
3335 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3336 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3337 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3338 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3339 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3340 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3341 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3342 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, 0 );
3343 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3344 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3345 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3346 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, 0 );
3348 MsiCloseHandle(hpkg);
3350 /* uninstall the product */
3351 r = MsiInstallProduct(msifile4, "REMOVE=ALL");
3352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3354 DeleteFileA(msifile);
3355 DeleteFileA(msifile2);
3356 DeleteFileA(msifile3);
3357 DeleteFileA(msifile4);
3360 static void test_getproperty(void)
3362 MSIHANDLE hPackage = 0;
3363 char prop[100];
3364 static CHAR empty[] = "";
3365 DWORD size;
3366 UINT r;
3368 r = package_from_db(create_package_db(), &hPackage);
3369 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3371 skip("Not enough rights to perform tests\n");
3372 DeleteFile(msifile);
3373 return;
3375 ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
3377 /* set the property */
3378 r = MsiSetProperty(hPackage, "Name", "Value");
3379 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3381 /* retrieve the size, NULL pointer */
3382 size = 0;
3383 r = MsiGetProperty(hPackage, "Name", NULL, &size);
3384 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3385 ok( size == 5, "Expected 5, got %d\n", size);
3387 /* retrieve the size, empty string */
3388 size = 0;
3389 r = MsiGetProperty(hPackage, "Name", empty, &size);
3390 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3391 ok( size == 5, "Expected 5, got %d\n", size);
3393 /* don't change size */
3394 r = MsiGetProperty(hPackage, "Name", prop, &size);
3395 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3396 ok( size == 5, "Expected 5, got %d\n", size);
3397 ok( !lstrcmp(prop, "Valu"), "Expected Valu, got %s\n", prop);
3399 /* increase the size by 1 */
3400 size++;
3401 r = MsiGetProperty(hPackage, "Name", prop, &size);
3402 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3403 ok( size == 5, "Expected 5, got %d\n", size);
3404 ok( !lstrcmp(prop, "Value"), "Expected Value, got %s\n", prop);
3406 r = MsiCloseHandle( hPackage);
3407 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
3408 DeleteFile(msifile);
3411 static void test_removefiles(void)
3413 MSIHANDLE hpkg;
3414 UINT r;
3415 MSIHANDLE hdb;
3416 INSTALLSTATE installed, action;
3418 hdb = create_package_db();
3419 ok ( hdb, "failed to create package database\n" );
3421 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3422 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3424 r = create_feature_table( hdb );
3425 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
3427 r = create_component_table( hdb );
3428 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
3430 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3431 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3433 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3434 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3436 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3437 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3439 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3440 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3442 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3443 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3445 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3446 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3448 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3449 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3451 r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3452 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3454 r = create_feature_components_table( hdb );
3455 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
3457 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
3458 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3460 r = add_feature_components_entry( hdb, "'one', 'helium'" );
3461 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3463 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
3464 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3466 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
3467 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3469 r = add_feature_components_entry( hdb, "'one', 'boron'" );
3470 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3472 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
3473 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3475 r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
3476 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3478 r = create_file_table( hdb );
3479 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3481 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3482 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3484 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3485 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3487 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3488 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3490 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3491 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3493 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3494 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3496 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3497 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3499 r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3500 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3502 r = create_remove_file_table( hdb );
3503 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
3505 r = package_from_db( hdb, &hpkg );
3506 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3508 skip("Not enough rights to perform tests\n");
3509 DeleteFile(msifile);
3510 return;
3512 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3514 MsiCloseHandle( hdb );
3516 create_test_file( "hydrogen.txt" );
3517 create_test_file( "helium.txt" );
3518 create_test_file( "lithium.txt" );
3519 create_test_file( "beryllium.txt" );
3520 create_test_file( "boron.txt" );
3521 create_test_file( "carbon.txt" );
3522 create_test_file( "oxygen.txt" );
3524 r = MsiSetProperty( hpkg, "TARGETDIR", CURR_DIR );
3525 ok( r == ERROR_SUCCESS, "set property failed\n");
3527 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3529 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3530 ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
3532 r = MsiDoAction( hpkg, "CostInitialize");
3533 ok( r == ERROR_SUCCESS, "cost init failed\n");
3535 r = MsiDoAction( hpkg, "FileCost");
3536 ok( r == ERROR_SUCCESS, "file cost failed\n");
3538 installed = action = 0xdeadbeef;
3539 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3540 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3541 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3542 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3544 r = MsiDoAction( hpkg, "CostFinalize");
3545 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3547 r = MsiDoAction( hpkg, "InstallValidate");
3548 ok( r == ERROR_SUCCESS, "install validate failed\n");
3550 r = MsiSetComponentState( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
3551 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3553 installed = action = 0xdeadbeef;
3554 r = MsiGetComponentState( hpkg, "hydrogen", &installed, &action );
3555 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3556 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3557 todo_wine ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3559 r = MsiSetComponentState( hpkg, "helium", INSTALLSTATE_LOCAL );
3560 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3562 r = MsiSetComponentState( hpkg, "lithium", INSTALLSTATE_SOURCE );
3563 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3565 r = MsiSetComponentState( hpkg, "beryllium", INSTALLSTATE_ABSENT );
3566 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3568 r = MsiSetComponentState( hpkg, "boron", INSTALLSTATE_LOCAL );
3569 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3571 r = MsiSetComponentState( hpkg, "carbon", INSTALLSTATE_SOURCE );
3572 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3574 installed = action = 0xdeadbeef;
3575 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3576 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3577 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3578 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3580 r = MsiSetComponentState( hpkg, "oxygen", INSTALLSTATE_ABSENT );
3581 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3583 installed = action = 0xdeadbeef;
3584 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3585 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3586 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3587 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3589 r = MsiDoAction( hpkg, "RemoveFiles");
3590 ok( r == ERROR_SUCCESS, "remove files failed\n");
3592 installed = action = 0xdeadbeef;
3593 r = MsiGetComponentState( hpkg, "oxygen", &installed, &action );
3594 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3595 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3596 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3598 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3599 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3600 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3601 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3602 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3603 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3604 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3606 MsiCloseHandle( hpkg );
3607 DeleteFileA(msifile);
3610 static void test_appsearch(void)
3612 MSIHANDLE hpkg;
3613 UINT r;
3614 MSIHANDLE hdb;
3615 CHAR prop[MAX_PATH];
3616 DWORD size;
3618 hdb = create_package_db();
3619 ok ( hdb, "failed to create package database\n" );
3621 r = create_appsearch_table( hdb );
3622 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
3624 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
3625 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3627 r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
3628 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3630 r = create_reglocator_table( hdb );
3631 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3633 r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3634 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3636 r = create_drlocator_table( hdb );
3637 ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
3639 r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3640 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3642 r = create_signature_table( hdb );
3643 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
3645 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3646 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3648 r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3649 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3651 r = package_from_db( hdb, &hpkg );
3652 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3654 skip("Not enough rights to perform tests\n");
3655 DeleteFile(msifile);
3656 return;
3658 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3659 MsiCloseHandle( hdb );
3660 if (r != ERROR_SUCCESS)
3661 goto done;
3663 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3665 r = MsiDoAction( hpkg, "AppSearch" );
3666 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
3668 size = sizeof(prop);
3669 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
3670 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3671 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3673 size = sizeof(prop);
3674 r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
3675 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3677 done:
3678 MsiCloseHandle( hpkg );
3679 DeleteFileA(msifile);
3682 static void test_appsearch_complocator(void)
3684 MSIHANDLE hpkg, hdb;
3685 CHAR path[MAX_PATH];
3686 CHAR prop[MAX_PATH];
3687 LPSTR usersid;
3688 DWORD size;
3689 UINT r;
3691 if (!(usersid = get_user_sid()))
3692 return;
3694 if (is_process_limited())
3696 skip("process is limited\n");
3697 return;
3700 create_test_file("FileName1");
3701 create_test_file("FileName4");
3702 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
3703 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
3705 create_test_file("FileName2");
3706 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
3707 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
3709 create_test_file("FileName3");
3710 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
3711 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
3713 create_test_file("FileName5");
3714 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
3715 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
3717 create_test_file("FileName6");
3718 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
3719 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
3721 create_test_file("FileName7");
3722 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
3723 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
3725 /* dir is FALSE, but we're pretending it's a directory */
3726 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
3727 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
3729 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3730 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
3731 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
3733 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3734 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
3735 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
3737 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3738 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
3739 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
3741 hdb = create_package_db();
3742 ok(hdb, "Expected a valid database handle\n");
3744 r = create_appsearch_table(hdb);
3745 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3747 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
3748 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3750 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
3751 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3753 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
3754 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3756 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
3757 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3759 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
3760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3762 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
3763 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3765 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
3766 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3768 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
3769 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3771 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
3772 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3774 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
3775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3777 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
3778 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3780 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
3781 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3783 r = create_complocator_table(hdb);
3784 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3786 /* published component, machine, file, signature, misdbLocatorTypeFile */
3787 r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
3788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3790 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
3791 r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
3792 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3794 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
3795 r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
3796 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3798 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
3799 r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
3800 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3802 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
3803 r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
3804 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3806 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
3807 r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
3808 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3810 /* published component, machine, file, no signature, misdbLocatorTypeFile */
3811 r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
3812 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3814 /* unpublished component, no signature, misdbLocatorTypeDir */
3815 r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
3816 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3818 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
3819 r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
3820 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3822 /* published component, signature w/ ver, misdbLocatorTypeFile */
3823 r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
3824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3826 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
3827 r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
3828 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3830 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
3831 r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
3832 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3834 r = create_signature_table(hdb);
3835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3837 r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
3838 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3840 r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
3841 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3843 r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
3844 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3846 r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
3847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3849 r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
3850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3852 r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3853 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3855 r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3856 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3858 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
3859 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3861 r = package_from_db(hdb, &hpkg);
3862 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3864 skip("Not enough rights to perform tests\n");
3865 goto error;
3867 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
3869 r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
3870 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3872 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3874 r = MsiDoAction(hpkg, "AppSearch");
3875 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3877 size = MAX_PATH;
3878 sprintf(path, "%s\\FileName1", CURR_DIR);
3879 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
3880 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3881 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3883 size = MAX_PATH;
3884 sprintf(path, "%s\\FileName2", CURR_DIR);
3885 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
3886 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3887 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3889 size = MAX_PATH;
3890 sprintf(path, "%s\\FileName3", CURR_DIR);
3891 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
3892 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3893 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3895 size = MAX_PATH;
3896 sprintf(path, "%s\\FileName4", CURR_DIR);
3897 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
3898 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3899 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3901 size = MAX_PATH;
3902 sprintf(path, "%s\\FileName5", CURR_DIR);
3903 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
3904 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3905 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3907 size = MAX_PATH;
3908 sprintf(path, "%s\\", CURR_DIR);
3909 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
3910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3911 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3913 size = MAX_PATH;
3914 sprintf(path, "%s\\", CURR_DIR);
3915 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
3916 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3917 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3919 size = MAX_PATH;
3920 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
3921 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3922 ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
3924 size = MAX_PATH;
3925 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
3926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3927 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3929 size = MAX_PATH;
3930 sprintf(path, "%s\\FileName8.dll", CURR_DIR);
3931 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
3932 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3933 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3935 size = MAX_PATH;
3936 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
3937 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3938 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
3940 size = MAX_PATH;
3941 sprintf(path, "%s\\FileName10.dll", CURR_DIR);
3942 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
3943 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3944 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
3946 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
3947 MSIINSTALLCONTEXT_MACHINE, NULL);
3948 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
3949 MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
3950 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
3951 MSIINSTALLCONTEXT_USERMANAGED, usersid);
3952 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
3953 MSIINSTALLCONTEXT_MACHINE, NULL);
3954 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
3955 MSIINSTALLCONTEXT_MACHINE, NULL);
3956 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
3957 MSIINSTALLCONTEXT_MACHINE, NULL);
3958 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
3959 MSIINSTALLCONTEXT_MACHINE, NULL);
3960 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
3961 MSIINSTALLCONTEXT_MACHINE, NULL);
3962 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
3963 MSIINSTALLCONTEXT_MACHINE, NULL);
3964 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
3965 MSIINSTALLCONTEXT_MACHINE, NULL);
3967 MsiCloseHandle(hpkg);
3969 error:
3970 DeleteFileA("FileName1");
3971 DeleteFileA("FileName2");
3972 DeleteFileA("FileName3");
3973 DeleteFileA("FileName4");
3974 DeleteFileA("FileName5");
3975 DeleteFileA("FileName6");
3976 DeleteFileA("FileName7");
3977 DeleteFileA("FileName8.dll");
3978 DeleteFileA("FileName9.dll");
3979 DeleteFileA("FileName10.dll");
3980 DeleteFileA(msifile);
3981 LocalFree(usersid);
3984 static void test_appsearch_reglocator(void)
3986 MSIHANDLE hpkg, hdb;
3987 CHAR path[MAX_PATH], prop[MAX_PATH];
3988 DWORD binary[2], size, val;
3989 BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
3990 HKEY hklm, classes, hkcu, users;
3991 LPSTR pathdata, pathvar, ptr;
3992 LPCSTR str;
3993 LONG res;
3994 UINT r, type = 0;
3995 SYSTEM_INFO si;
3997 version = TRUE;
3998 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
3999 version = FALSE;
4001 DeleteFileA("test.dll");
4003 res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
4004 if (res == ERROR_ACCESS_DENIED)
4006 skip("Not enough rights to perform tests\n");
4007 return;
4009 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4011 res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
4012 (const BYTE *)"regszdata", 10);
4013 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4015 res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
4016 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4018 res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
4019 (const BYTE *)"regszdata", 10);
4020 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4022 users = 0;
4023 res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
4024 ok(res == ERROR_SUCCESS ||
4025 broken(res == ERROR_INVALID_PARAMETER),
4026 "Expected ERROR_SUCCESS, got %d\n", res);
4028 if (res == ERROR_SUCCESS)
4030 res = RegSetValueExA(users, "Value1", 0, REG_SZ,
4031 (const BYTE *)"regszdata", 10);
4032 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4035 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
4036 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4038 res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
4039 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4041 res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
4042 (const BYTE *)"regszdata", 10);
4043 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4045 val = 42;
4046 res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
4047 (const BYTE *)&val, sizeof(DWORD));
4048 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4050 val = -42;
4051 res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
4052 (const BYTE *)&val, sizeof(DWORD));
4053 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4055 res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
4056 (const BYTE *)"%PATH%", 7);
4057 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4059 res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
4060 (const BYTE *)"my%NOVAR%", 10);
4061 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4063 res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
4064 (const BYTE *)"one\0two\0", 9);
4065 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4067 binary[0] = 0x1234abcd;
4068 binary[1] = 0x567890ef;
4069 res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
4070 (const BYTE *)binary, sizeof(binary));
4071 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4073 res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
4074 (const BYTE *)"#regszdata", 11);
4075 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4077 create_test_file("FileName1");
4078 sprintf(path, "%s\\FileName1", CURR_DIR);
4079 res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
4080 (const BYTE *)path, lstrlenA(path) + 1);
4081 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4083 sprintf(path, "%s\\FileName2", CURR_DIR);
4084 res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
4085 (const BYTE *)path, lstrlenA(path) + 1);
4086 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4088 lstrcpyA(path, CURR_DIR);
4089 res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
4090 (const BYTE *)path, lstrlenA(path) + 1);
4091 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4093 res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
4094 (const BYTE *)"", 1);
4095 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4097 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4098 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4099 res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
4100 (const BYTE *)path, lstrlenA(path) + 1);
4101 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4103 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4104 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4105 res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
4106 (const BYTE *)path, lstrlenA(path) + 1);
4107 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4109 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4110 sprintf(path, "%s\\FileName5.dll", CURR_DIR);
4111 res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
4112 (const BYTE *)path, lstrlenA(path) + 1);
4113 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4115 sprintf(path, "\"%s\\FileName1\" -option", CURR_DIR);
4116 res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
4117 (const BYTE *)path, lstrlenA(path) + 1);
4118 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4120 space = (strchr(CURR_DIR, ' ')) ? TRUE : FALSE;
4121 sprintf(path, "%s\\FileName1 -option", CURR_DIR);
4122 res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
4123 (const BYTE *)path, lstrlenA(path) + 1);
4124 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4126 hdb = create_package_db();
4127 ok(hdb, "Expected a valid database handle\n");
4129 r = create_appsearch_table(hdb);
4130 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4132 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4135 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4136 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4138 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4139 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4141 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4142 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4144 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4145 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4147 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4148 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4150 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4151 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4153 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4154 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4156 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4157 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4159 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4160 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4162 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4163 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4165 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4166 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4168 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
4169 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4171 r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
4172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4174 r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
4175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4177 r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
4178 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4180 r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
4181 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4183 r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
4184 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4186 r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
4187 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4189 r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
4190 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4192 r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
4193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4195 r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
4196 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4198 r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
4199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4201 r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
4202 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4204 r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
4205 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4207 r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
4208 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4210 r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
4211 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4213 r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
4214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4216 r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
4217 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4219 r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
4220 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4222 r = create_reglocator_table(hdb);
4223 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4225 type = msidbLocatorTypeRawValue;
4226 if (is_64bit)
4227 type |= msidbLocatorType64bit;
4229 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4230 r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
4231 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4233 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4234 r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
4235 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4237 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4238 r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
4239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4241 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4242 r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
4243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4245 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4246 r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
4247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4249 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4250 r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
4251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4253 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4254 r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
4255 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4257 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4258 r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
4259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4261 type = msidbLocatorTypeFileName;
4262 if (is_64bit)
4263 type |= msidbLocatorType64bit;
4265 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4266 r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
4267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4269 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4270 r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
4271 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4273 /* HKLM, msidbLocatorTypeFileName, no signature */
4274 r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
4275 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4277 type = msidbLocatorTypeDirectory;
4278 if (is_64bit)
4279 type |= msidbLocatorType64bit;
4281 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4282 r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
4283 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4285 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4286 r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
4287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4289 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4290 r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
4291 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4293 type = msidbLocatorTypeRawValue;
4294 if (is_64bit)
4295 type |= msidbLocatorType64bit;
4297 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4298 r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
4299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4301 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4302 r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
4303 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4305 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4306 r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
4307 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4309 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4310 r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
4311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4313 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4314 r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
4315 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4317 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4318 r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
4319 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4321 type = msidbLocatorTypeFileName;
4322 if (is_64bit)
4323 type |= msidbLocatorType64bit;
4325 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4326 r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
4327 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4329 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4330 r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
4331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4333 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4334 r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
4335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4337 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4338 r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
4339 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4341 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4342 r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
4343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4345 type = msidbLocatorTypeDirectory;
4346 if (is_64bit)
4347 type |= msidbLocatorType64bit;
4349 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4350 r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
4351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4353 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4354 r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
4355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4357 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4358 r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
4359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4361 type = msidbLocatorTypeFileName;
4362 if (is_64bit)
4363 type |= msidbLocatorType64bit;
4365 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4366 r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
4367 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4369 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4370 r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
4371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4373 r = create_signature_table(hdb);
4374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4376 str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4377 r = add_signature_entry(hdb, str);
4378 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4380 str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4381 r = add_signature_entry(hdb, str);
4382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4384 str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4385 r = add_signature_entry(hdb, str);
4386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4388 str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4389 r = add_signature_entry(hdb, str);
4390 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4392 str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4393 r = add_signature_entry(hdb, str);
4394 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4396 str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4397 r = add_signature_entry(hdb, str);
4398 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4400 ptr = strrchr(CURR_DIR, '\\') + 1;
4401 sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
4402 r = add_signature_entry(hdb, path);
4403 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4405 str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4406 r = add_signature_entry(hdb, str);
4407 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4409 str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4410 r = add_signature_entry(hdb, str);
4411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4413 str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4414 r = add_signature_entry(hdb, str);
4415 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4417 r = package_from_db(hdb, &hpkg);
4418 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4420 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4422 r = MsiDoAction(hpkg, "AppSearch");
4423 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4425 size = MAX_PATH;
4426 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4427 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4428 ok(!lstrcmpA(prop, "regszdata"),
4429 "Expected \"regszdata\", got \"%s\"\n", prop);
4431 size = MAX_PATH;
4432 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4433 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4434 ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
4436 size = MAX_PATH;
4437 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4438 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4439 ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
4441 memset(&si, 0, sizeof(si));
4442 if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
4444 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
4446 size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
4447 pathvar = HeapAlloc(GetProcessHeap(), 0, size);
4448 ExpandEnvironmentStringsA("%PATH%", pathvar, size);
4450 size = 0;
4451 r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
4452 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4454 pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
4455 r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
4456 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4457 ok(!lstrcmpA(pathdata, pathvar),
4458 "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
4460 HeapFree(GetProcessHeap(), 0, pathvar);
4461 HeapFree(GetProcessHeap(), 0, pathdata);
4464 size = MAX_PATH;
4465 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4467 ok(!lstrcmpA(prop,
4468 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
4470 size = MAX_PATH;
4471 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4472 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4473 todo_wine
4475 ok(!memcmp(prop, "\0one\0two\0\0", 10),
4476 "Expected \"\\0one\\0two\\0\\0\"\n");
4479 size = MAX_PATH;
4480 lstrcpyA(path, "#xCDAB3412EF907856");
4481 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4482 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4483 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4485 size = MAX_PATH;
4486 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4487 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4488 ok(!lstrcmpA(prop, "##regszdata"),
4489 "Expected \"##regszdata\", got \"%s\"\n", prop);
4491 size = MAX_PATH;
4492 sprintf(path, "%s\\FileName1", CURR_DIR);
4493 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4494 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4495 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4497 size = MAX_PATH;
4498 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4499 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4500 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4502 size = MAX_PATH;
4503 sprintf(path, "%s\\", CURR_DIR);
4504 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4505 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4506 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4508 size = MAX_PATH;
4509 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4510 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4511 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4513 size = MAX_PATH;
4514 sprintf(path, "%s\\", CURR_DIR);
4515 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
4516 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4517 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4519 size = MAX_PATH;
4520 r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
4521 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4522 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4524 size = MAX_PATH;
4525 r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
4526 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4527 ok(!lstrcmpA(prop, "regszdata"),
4528 "Expected \"regszdata\", got \"%s\"\n", prop);
4530 size = MAX_PATH;
4531 r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
4532 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4533 ok(!lstrcmpA(prop, "regszdata"),
4534 "Expected \"regszdata\", got \"%s\"\n", prop);
4536 if (users)
4538 size = MAX_PATH;
4539 r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
4540 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4541 ok(!lstrcmpA(prop, "regszdata"),
4542 "Expected \"regszdata\", got \"%s\"\n", prop);
4545 size = MAX_PATH;
4546 r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
4547 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4548 ok(!lstrcmpA(prop, "defvalue"),
4549 "Expected \"defvalue\", got \"%s\"\n", prop);
4551 size = MAX_PATH;
4552 r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
4553 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4554 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4556 size = MAX_PATH;
4557 r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
4558 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4559 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4561 if (version)
4563 size = MAX_PATH;
4564 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4565 r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
4566 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4567 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4569 size = MAX_PATH;
4570 r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
4571 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4572 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4574 size = MAX_PATH;
4575 sprintf(path, "%s\\FileName5.dll", CURR_DIR);
4576 r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
4577 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4578 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4581 size = MAX_PATH;
4582 lstrcpyA(path, CURR_DIR);
4583 ptr = strrchr(path, '\\') + 1;
4584 *ptr = '\0';
4585 r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
4586 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4587 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4589 size = MAX_PATH;
4590 sprintf(path, "%s\\", CURR_DIR);
4591 r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
4592 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4593 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4595 size = MAX_PATH;
4596 r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
4597 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4598 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4600 size = MAX_PATH;
4601 r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
4602 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4603 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4605 size = MAX_PATH;
4606 r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
4607 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4608 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4610 size = MAX_PATH;
4611 sprintf(path, "%s\\FileName1", CURR_DIR);
4612 r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
4613 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4614 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4616 size = MAX_PATH;
4617 sprintf(path, "%s\\FileName1", CURR_DIR);
4618 r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
4619 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4620 if (space)
4621 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4622 else
4623 todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4625 RegSetValueA(hklm, NULL, REG_SZ, "", 0);
4626 RegDeleteValueA(hklm, "Value1");
4627 RegDeleteValueA(hklm, "Value2");
4628 RegDeleteValueA(hklm, "Value3");
4629 RegDeleteValueA(hklm, "Value4");
4630 RegDeleteValueA(hklm, "Value5");
4631 RegDeleteValueA(hklm, "Value6");
4632 RegDeleteValueA(hklm, "Value7");
4633 RegDeleteValueA(hklm, "Value8");
4634 RegDeleteValueA(hklm, "Value9");
4635 RegDeleteValueA(hklm, "Value10");
4636 RegDeleteValueA(hklm, "Value11");
4637 RegDeleteValueA(hklm, "Value12");
4638 RegDeleteValueA(hklm, "Value13");
4639 RegDeleteValueA(hklm, "Value14");
4640 RegDeleteValueA(hklm, "Value15");
4641 RegDeleteValueA(hklm, "Value16");
4642 RegDeleteValueA(hklm, "Value17");
4643 RegDeleteKey(hklm, "");
4644 RegCloseKey(hklm);
4646 RegDeleteValueA(classes, "Value1");
4647 RegDeleteKeyA(classes, "");
4648 RegCloseKey(classes);
4650 RegDeleteValueA(hkcu, "Value1");
4651 RegDeleteKeyA(hkcu, "");
4652 RegCloseKey(hkcu);
4654 RegDeleteValueA(users, "Value1");
4655 RegDeleteKeyA(users, "");
4656 RegCloseKey(users);
4658 DeleteFileA("FileName1");
4659 DeleteFileA("FileName3.dll");
4660 DeleteFileA("FileName4.dll");
4661 DeleteFileA("FileName5.dll");
4662 MsiCloseHandle(hpkg);
4663 DeleteFileA(msifile);
4666 static void delete_win_ini(LPCSTR file)
4668 CHAR path[MAX_PATH];
4670 GetWindowsDirectoryA(path, MAX_PATH);
4671 lstrcatA(path, "\\");
4672 lstrcatA(path, file);
4674 DeleteFileA(path);
4677 static void test_appsearch_inilocator(void)
4679 MSIHANDLE hpkg, hdb;
4680 CHAR path[MAX_PATH];
4681 CHAR prop[MAX_PATH];
4682 BOOL version;
4683 LPCSTR str;
4684 LPSTR ptr;
4685 DWORD size;
4686 UINT r;
4688 version = TRUE;
4689 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4690 version = FALSE;
4692 DeleteFileA("test.dll");
4694 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4696 create_test_file("FileName1");
4697 sprintf(path, "%s\\FileName1", CURR_DIR);
4698 WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
4700 WritePrivateProfileStringA("Section", "Key3", CURR_DIR, "IniFile.ini");
4702 sprintf(path, "%s\\IDontExist", CURR_DIR);
4703 WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
4705 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4706 sprintf(path, "%s\\FileName2.dll", CURR_DIR);
4707 WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
4709 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4710 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
4711 WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
4713 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4714 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4715 WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
4717 hdb = create_package_db();
4718 ok(hdb, "Expected a valid database handle\n");
4720 r = create_appsearch_table(hdb);
4721 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4723 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4724 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4726 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4727 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4729 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4732 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4733 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4735 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4736 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4738 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4739 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4741 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4742 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4744 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4745 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4747 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4748 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4750 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4751 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4753 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4754 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4756 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4757 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4759 r = create_inilocator_table(hdb);
4760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4762 /* msidbLocatorTypeRawValue, field 1 */
4763 str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
4764 r = add_inilocator_entry(hdb, str);
4765 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4767 /* msidbLocatorTypeRawValue, field 2 */
4768 str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
4769 r = add_inilocator_entry(hdb, str);
4770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4772 /* msidbLocatorTypeRawValue, entire field */
4773 str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
4774 r = add_inilocator_entry(hdb, str);
4775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4777 /* msidbLocatorTypeFile */
4778 str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4779 r = add_inilocator_entry(hdb, str);
4780 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4782 /* msidbLocatorTypeDirectory, file */
4783 str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
4784 r = add_inilocator_entry(hdb, str);
4785 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4787 /* msidbLocatorTypeDirectory, directory */
4788 str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
4789 r = add_inilocator_entry(hdb, str);
4790 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4792 /* msidbLocatorTypeFile, file, no signature */
4793 str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4794 r = add_inilocator_entry(hdb, str);
4795 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4797 /* msidbLocatorTypeFile, dir, no signature */
4798 str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
4799 r = add_inilocator_entry(hdb, str);
4800 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4802 /* msidbLocatorTypeFile, file does not exist */
4803 str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
4804 r = add_inilocator_entry(hdb, str);
4805 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4807 /* msidbLocatorTypeFile, signature with version */
4808 str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
4809 r = add_inilocator_entry(hdb, str);
4810 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4812 /* msidbLocatorTypeFile, signature with version, ver > max */
4813 str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
4814 r = add_inilocator_entry(hdb, str);
4815 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4817 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4818 str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
4819 r = add_inilocator_entry(hdb, str);
4820 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4822 r = create_signature_table(hdb);
4823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4825 r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4826 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4828 r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4829 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4831 r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4832 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4834 r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4837 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4838 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4840 r = package_from_db(hdb, &hpkg);
4841 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4843 skip("Not enough rights to perform tests\n");
4844 goto error;
4846 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4848 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4850 r = MsiDoAction(hpkg, "AppSearch");
4851 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4853 size = MAX_PATH;
4854 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4855 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4856 ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
4858 size = MAX_PATH;
4859 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4861 ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
4863 size = MAX_PATH;
4864 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4865 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4866 ok(!lstrcmpA(prop, "keydata,field2"),
4867 "Expected \"keydata,field2\", got \"%s\"\n", prop);
4869 size = MAX_PATH;
4870 sprintf(path, "%s\\FileName1", CURR_DIR);
4871 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
4872 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4873 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4875 size = MAX_PATH;
4876 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4877 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4878 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4880 size = MAX_PATH;
4881 sprintf(path, "%s\\", CURR_DIR);
4882 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4883 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4884 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4886 size = MAX_PATH;
4887 sprintf(path, "%s\\", CURR_DIR);
4888 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4889 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4890 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4892 size = MAX_PATH;
4893 lstrcpyA(path, CURR_DIR);
4894 ptr = strrchr(path, '\\');
4895 *(ptr + 1) = '\0';
4896 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4897 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4898 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4900 size = MAX_PATH;
4901 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4903 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4905 if (version)
4907 size = MAX_PATH;
4908 sprintf(path, "%s\\FileName2.dll", CURR_DIR);
4909 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4911 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4913 size = MAX_PATH;
4914 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4915 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4916 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4918 size = MAX_PATH;
4919 sprintf(path, "%s\\FileName4.dll", CURR_DIR);
4920 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4921 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4922 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4925 MsiCloseHandle(hpkg);
4927 error:
4928 delete_win_ini("IniFile.ini");
4929 DeleteFileA("FileName1");
4930 DeleteFileA("FileName2.dll");
4931 DeleteFileA("FileName3.dll");
4932 DeleteFileA("FileName4.dll");
4933 DeleteFileA(msifile);
4937 * MSI AppSearch action on DrLocator table always returns absolute paths.
4938 * If a relative path was set, it returns the first absolute path that
4939 * matches or an empty string if it didn't find anything.
4940 * This helper function replicates this behaviour.
4942 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
4944 int i, size;
4945 DWORD attr, drives;
4947 size = lstrlenA(relative);
4948 drives = GetLogicalDrives();
4949 lstrcpyA(absolute, "A:\\");
4950 for (i = 0; i < 26; absolute[0] = '\0', i++)
4952 if (!(drives & (1 << i)))
4953 continue;
4955 absolute[0] = 'A' + i;
4956 if (GetDriveType(absolute) != DRIVE_FIXED)
4957 continue;
4959 lstrcpynA(absolute + 3, relative, size + 1);
4960 attr = GetFileAttributesA(absolute);
4961 if (attr != INVALID_FILE_ATTRIBUTES &&
4962 (attr & FILE_ATTRIBUTE_DIRECTORY))
4964 if (absolute[3 + size - 1] != '\\')
4965 lstrcatA(absolute, "\\");
4966 break;
4968 absolute[3] = '\0';
4972 static void test_appsearch_drlocator(void)
4974 MSIHANDLE hpkg, hdb;
4975 CHAR path[MAX_PATH];
4976 CHAR prop[MAX_PATH];
4977 BOOL version;
4978 LPCSTR str;
4979 DWORD size;
4980 UINT r;
4982 version = TRUE;
4983 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4984 version = FALSE;
4986 DeleteFileA("test.dll");
4988 create_test_file("FileName1");
4989 CreateDirectoryA("one", NULL);
4990 CreateDirectoryA("one\\two", NULL);
4991 CreateDirectoryA("one\\two\\three", NULL);
4992 create_test_file("one\\two\\three\\FileName2");
4993 CreateDirectoryA("another", NULL);
4994 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4995 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4996 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4998 hdb = create_package_db();
4999 ok(hdb, "Expected a valid database handle\n");
5001 r = create_appsearch_table(hdb);
5002 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5004 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5005 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5007 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5008 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5010 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5011 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5013 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5014 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5016 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5019 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5020 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5022 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5023 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5025 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5026 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5028 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5031 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
5032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5034 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
5035 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5037 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
5038 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5040 r = create_drlocator_table(hdb);
5041 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5043 /* no parent, full path, depth 0, signature */
5044 sprintf(path, "'NewSignature1', '', '%s', 0", CURR_DIR);
5045 r = add_drlocator_entry(hdb, path);
5046 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5048 /* no parent, full path, depth 0, no signature */
5049 sprintf(path, "'NewSignature2', '', '%s', 0", CURR_DIR);
5050 r = add_drlocator_entry(hdb, path);
5051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5053 /* no parent, relative path, depth 0, no signature */
5054 sprintf(path, "'NewSignature3', '', '%s', 0", CURR_DIR + 3);
5055 r = add_drlocator_entry(hdb, path);
5056 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5058 /* no parent, full path, depth 2, signature */
5059 sprintf(path, "'NewSignature4', '', '%s', 2", CURR_DIR);
5060 r = add_drlocator_entry(hdb, path);
5061 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5063 /* no parent, full path, depth 3, signature */
5064 sprintf(path, "'NewSignature5', '', '%s', 3", CURR_DIR);
5065 r = add_drlocator_entry(hdb, path);
5066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5068 /* no parent, full path, depth 1, signature is dir */
5069 sprintf(path, "'NewSignature6', '', '%s', 1", CURR_DIR);
5070 r = add_drlocator_entry(hdb, path);
5071 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5073 /* parent is in DrLocator, relative path, depth 0, signature */
5074 sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5075 r = add_drlocator_entry(hdb, path);
5076 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5078 /* no parent, full path, depth 0, signature w/ version */
5079 sprintf(path, "'NewSignature8', '', '%s', 0", CURR_DIR);
5080 r = add_drlocator_entry(hdb, path);
5081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5083 /* no parent, full path, depth 0, signature w/ version, ver > max */
5084 sprintf(path, "'NewSignature9', '', '%s', 0", CURR_DIR);
5085 r = add_drlocator_entry(hdb, path);
5086 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5088 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5089 sprintf(path, "'NewSignature10', '', '%s', 0", CURR_DIR);
5090 r = add_drlocator_entry(hdb, path);
5091 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5093 /* no parent, relative empty path, depth 0, no signature */
5094 sprintf(path, "'NewSignature11', '', '', 0");
5095 r = add_drlocator_entry(hdb, path);
5096 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5098 r = create_reglocator_table(hdb);
5099 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5101 /* parent */
5102 r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5103 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5105 /* parent is in RegLocator, no path, depth 0, no signature */
5106 sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
5107 r = add_drlocator_entry(hdb, path);
5108 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5110 r = create_signature_table(hdb);
5111 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5113 str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5114 r = add_signature_entry(hdb, str);
5115 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5117 str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5118 r = add_signature_entry(hdb, str);
5119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5121 str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5122 r = add_signature_entry(hdb, str);
5123 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5125 str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5126 r = add_signature_entry(hdb, str);
5127 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5129 str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5130 r = add_signature_entry(hdb, str);
5131 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5133 str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5134 r = add_signature_entry(hdb, str);
5135 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5137 str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5138 r = add_signature_entry(hdb, str);
5139 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5141 str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5142 r = add_signature_entry(hdb, str);
5143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5145 r = package_from_db(hdb, &hpkg);
5146 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5148 skip("Not enough rights to perform tests\n");
5149 goto error;
5151 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5153 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5155 r = MsiDoAction(hpkg, "AppSearch");
5156 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5158 size = MAX_PATH;
5159 sprintf(path, "%s\\FileName1", CURR_DIR);
5160 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5162 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5164 size = MAX_PATH;
5165 sprintf(path, "%s\\", CURR_DIR);
5166 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5168 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5170 size = MAX_PATH;
5171 search_absolute_directory(path, CURR_DIR + 3);
5172 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5173 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5174 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5176 size = MAX_PATH;
5177 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5178 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5179 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5181 size = MAX_PATH;
5182 sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
5183 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5184 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5185 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5187 size = MAX_PATH;
5188 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5190 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5192 size = MAX_PATH;
5193 sprintf(path, "%s\\one\\two\\three\\FileName2", CURR_DIR);
5194 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5196 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5198 if (version)
5200 size = MAX_PATH;
5201 sprintf(path, "%s\\FileName3.dll", CURR_DIR);
5202 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5204 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5206 size = MAX_PATH;
5207 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5208 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5209 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5211 size = MAX_PATH;
5212 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5213 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5214 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5217 size = MAX_PATH;
5218 search_absolute_directory(path, "");
5219 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5220 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5221 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5223 size = MAX_PATH;
5224 strcpy(path, "c:\\");
5225 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
5226 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5227 ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
5229 MsiCloseHandle(hpkg);
5231 error:
5232 DeleteFileA("FileName1");
5233 DeleteFileA("FileName3.dll");
5234 DeleteFileA("FileName4.dll");
5235 DeleteFileA("FileName5.dll");
5236 DeleteFileA("one\\two\\three\\FileName2");
5237 RemoveDirectoryA("one\\two\\three");
5238 RemoveDirectoryA("one\\two");
5239 RemoveDirectoryA("one");
5240 RemoveDirectoryA("another");
5241 DeleteFileA(msifile);
5244 static void test_featureparents(void)
5246 MSIHANDLE hpkg;
5247 UINT r;
5248 MSIHANDLE hdb;
5250 hdb = create_package_db();
5251 ok ( hdb, "failed to create package database\n" );
5253 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
5254 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
5256 r = create_feature_table( hdb );
5257 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
5259 r = create_component_table( hdb );
5260 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
5262 r = create_feature_components_table( hdb );
5263 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
5265 r = create_file_table( hdb );
5266 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
5268 /* msidbFeatureAttributesFavorLocal */
5269 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
5270 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5272 /* msidbFeatureAttributesFavorSource */
5273 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
5274 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5276 /* msidbFeatureAttributesFavorLocal */
5277 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
5278 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5280 /* msidbFeatureAttributesUIDisallowAbsent */
5281 r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
5282 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5284 /* disabled because of install level */
5285 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
5286 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5288 /* child feature of disabled feature */
5289 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5290 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5292 /* component of disabled feature (install level) */
5293 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5294 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5296 /* component of disabled child feature (install level) */
5297 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5298 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5300 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5301 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5302 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5304 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5305 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5306 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5308 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5309 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5310 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5312 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5313 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5314 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5316 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5317 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5318 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5320 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5321 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5322 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5324 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5325 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5326 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5328 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5329 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5330 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5332 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5333 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5334 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5336 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
5337 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5339 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
5340 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5342 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
5343 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5345 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
5346 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5348 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
5349 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5351 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
5352 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5354 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
5355 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5357 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
5358 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5360 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
5361 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5363 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
5364 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5366 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
5367 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5369 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
5370 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5372 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
5373 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5375 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
5376 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5378 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
5379 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5381 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
5382 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5384 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
5385 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5387 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5388 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5390 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5391 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5393 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5394 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5396 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5397 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5399 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5400 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5402 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5403 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5405 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5406 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5408 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5409 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5411 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5412 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5414 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5415 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5417 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5418 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5420 r = package_from_db( hdb, &hpkg );
5421 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5423 skip("Not enough rights to perform tests\n");
5424 DeleteFile(msifile);
5425 return;
5427 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5429 MsiCloseHandle( hdb );
5431 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5433 r = MsiDoAction( hpkg, "CostInitialize");
5434 ok( r == ERROR_SUCCESS, "cost init failed\n");
5436 r = MsiDoAction( hpkg, "FileCost");
5437 ok( r == ERROR_SUCCESS, "file cost failed\n");
5439 r = MsiDoAction( hpkg, "CostFinalize");
5440 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5442 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5443 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
5444 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5445 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5446 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5447 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5449 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5450 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5451 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5452 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5453 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5454 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5455 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5456 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5457 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5458 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5459 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5461 r = MsiSetFeatureState(hpkg, "orion", INSTALLSTATE_ABSENT);
5462 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5464 r = MsiSetFeatureState(hpkg, "lyra", INSTALLSTATE_ABSENT);
5465 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5467 r = MsiSetFeatureState(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
5468 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
5470 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, 0 );
5471 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, 0 );
5472 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, 0 );
5473 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, 0 );
5474 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5475 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, 0 );
5477 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5478 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5479 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5480 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, 0 );
5481 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5482 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, 0 );
5483 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5484 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5485 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5486 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5487 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, 0 );
5489 MsiCloseHandle(hpkg);
5490 DeleteFileA(msifile);
5493 static void test_installprops(void)
5495 MSIHANDLE hpkg, hdb;
5496 CHAR path[MAX_PATH], buf[MAX_PATH];
5497 DWORD size, type;
5498 LANGID langid;
5499 HKEY hkey1, hkey2;
5500 int res;
5501 UINT r;
5502 REGSAM access = KEY_ALL_ACCESS;
5503 SYSTEM_INFO si;
5504 INSTALLUILEVEL uilevel;
5506 if (is_wow64)
5507 access |= KEY_WOW64_64KEY;
5509 GetCurrentDirectory(MAX_PATH, path);
5510 lstrcat(path, "\\");
5511 lstrcat(path, msifile);
5513 uilevel = MsiSetInternalUI(INSTALLUILEVEL_BASIC|INSTALLUILEVEL_SOURCERESONLY, NULL);
5515 hdb = create_package_db();
5516 ok( hdb, "failed to create database\n");
5518 r = package_from_db(hdb, &hpkg);
5519 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5521 skip("Not enough rights to perform tests\n");
5522 MsiSetInternalUI(uilevel, NULL);
5523 DeleteFile(msifile);
5524 return;
5526 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5528 MsiCloseHandle(hdb);
5530 buf[0] = 0;
5531 size = MAX_PATH;
5532 r = MsiGetProperty(hpkg, "UILevel", buf, &size);
5533 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5534 ok( !lstrcmp(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5536 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5538 buf[0] = 0;
5539 size = MAX_PATH;
5540 r = MsiGetProperty(hpkg, "UILevel", buf, &size);
5541 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5542 ok( !lstrcmp(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5544 buf[0] = 0;
5545 size = MAX_PATH;
5546 r = MsiGetProperty(hpkg, "DATABASE", buf, &size);
5547 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5548 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5550 RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
5551 RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
5553 size = MAX_PATH;
5554 type = REG_SZ;
5555 *path = '\0';
5556 if (RegQueryValueEx(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5558 size = MAX_PATH;
5559 type = REG_SZ;
5560 RegQueryValueEx(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
5563 buf[0] = 0;
5564 size = MAX_PATH;
5565 r = MsiGetProperty(hpkg, "USERNAME", buf, &size);
5566 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5567 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5569 size = MAX_PATH;
5570 type = REG_SZ;
5571 *path = '\0';
5572 if (RegQueryValueEx(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5574 size = MAX_PATH;
5575 type = REG_SZ;
5576 RegQueryValueEx(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
5579 if (*path)
5581 buf[0] = 0;
5582 size = MAX_PATH;
5583 r = MsiGetProperty(hpkg, "COMPANYNAME", buf, &size);
5584 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5585 ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
5588 buf[0] = 0;
5589 size = MAX_PATH;
5590 r = MsiGetProperty(hpkg, "VersionDatabase", buf, &size);
5591 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5592 trace("VersionDatabase = %s\n", buf);
5594 buf[0] = 0;
5595 size = MAX_PATH;
5596 r = MsiGetProperty(hpkg, "VersionMsi", buf, &size);
5597 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5598 trace("VersionMsi = %s\n", buf);
5600 buf[0] = 0;
5601 size = MAX_PATH;
5602 r = MsiGetProperty(hpkg, "Date", buf, &size);
5603 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5604 trace("Date = %s\n", buf);
5606 buf[0] = 0;
5607 size = MAX_PATH;
5608 r = MsiGetProperty(hpkg, "Time", buf, &size);
5609 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5610 trace("Time = %s\n", buf);
5612 buf[0] = 0;
5613 size = MAX_PATH;
5614 r = MsiGetProperty(hpkg, "PackageCode", buf, &size);
5615 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5616 trace("PackageCode = %s\n", buf);
5618 buf[0] = 0;
5619 size = MAX_PATH;
5620 r = MsiGetProperty(hpkg, "ComputerName", buf, &size);
5621 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5622 trace("ComputerName = %s\n", buf);
5624 langid = GetUserDefaultLangID();
5625 sprintf(path, "%d", langid);
5627 buf[0] = 0;
5628 size = MAX_PATH;
5629 r = MsiGetProperty(hpkg, "UserLanguageID", buf, &size);
5630 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5631 ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
5633 res = GetSystemMetrics(SM_CXSCREEN);
5634 buf[0] = 0;
5635 size = MAX_PATH;
5636 r = MsiGetProperty(hpkg, "ScreenX", buf, &size);
5637 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5638 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5640 res = GetSystemMetrics(SM_CYSCREEN);
5641 buf[0] = 0;
5642 size = MAX_PATH;
5643 r = MsiGetProperty(hpkg, "ScreenY", buf, &size);
5644 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5645 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5647 if (pGetSystemInfo && pSHGetFolderPathA)
5649 pGetSystemInfo(&si);
5650 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
5652 buf[0] = 0;
5653 size = MAX_PATH;
5654 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5655 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5656 ok(buf[0], "property not set\n");
5658 buf[0] = 0;
5659 size = MAX_PATH;
5660 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5661 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5662 ok(buf[0], "property not set\n");
5664 buf[0] = 0;
5665 size = MAX_PATH;
5666 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5667 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5668 ok(buf[0], "property not set\n");
5670 buf[0] = 0;
5671 size = MAX_PATH;
5672 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5673 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5674 GetSystemDirectoryA(path, MAX_PATH);
5675 if (size) buf[size - 1] = 0;
5676 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5678 buf[0] = 0;
5679 size = MAX_PATH;
5680 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5681 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5682 pGetSystemWow64DirectoryA(path, MAX_PATH);
5683 if (size) buf[size - 1] = 0;
5684 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5686 buf[0] = 0;
5687 size = MAX_PATH;
5688 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
5689 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5690 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5691 if (size) buf[size - 1] = 0;
5692 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5694 buf[0] = 0;
5695 size = MAX_PATH;
5696 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5697 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5698 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5699 if (size) buf[size - 1] = 0;
5700 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5702 buf[0] = 0;
5703 size = MAX_PATH;
5704 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
5705 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5706 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5707 if (size) buf[size - 1] = 0;
5708 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5710 buf[0] = 0;
5711 size = MAX_PATH;
5712 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5713 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5714 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5715 if (size) buf[size - 1] = 0;
5716 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5718 buf[0] = 0;
5719 size = MAX_PATH;
5720 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5721 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5722 ok(buf[0], "property not set\n");
5724 else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
5726 if (!is_wow64)
5728 buf[0] = 0;
5729 size = MAX_PATH;
5730 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5731 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5732 ok(buf[0], "property not set\n");
5734 buf[0] = 0;
5735 size = MAX_PATH;
5736 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5737 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5738 ok(!buf[0], "property set\n");
5740 buf[0] = 0;
5741 size = MAX_PATH;
5742 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5743 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5744 ok(!buf[0], "property set\n");
5746 buf[0] = 0;
5747 size = MAX_PATH;
5748 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5749 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5750 ok(!buf[0], "property set\n");
5752 buf[0] = 0;
5753 size = MAX_PATH;
5754 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5755 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5756 GetSystemDirectoryA(path, MAX_PATH);
5757 if (size) buf[size - 1] = 0;
5758 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5760 buf[0] = 0;
5761 size = MAX_PATH;
5762 r = MsiGetProperty(hpkg, "ProgramFiles64Folder", buf, &size);
5763 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5764 ok(!buf[0], "property set\n");
5766 buf[0] = 0;
5767 size = MAX_PATH;
5768 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5769 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5770 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5771 if (size) buf[size - 1] = 0;
5772 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5774 buf[0] = 0;
5775 size = MAX_PATH;
5776 r = MsiGetProperty(hpkg, "CommonFiles64Folder", buf, &size);
5777 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5778 ok(!buf[0], "property set\n");
5780 buf[0] = 0;
5781 size = MAX_PATH;
5782 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5783 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5784 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5785 if (size) buf[size - 1] = 0;
5786 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5788 buf[0] = 0;
5789 size = MAX_PATH;
5790 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5791 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5792 ok(!buf[0], "property set\n");
5794 else
5796 buf[0] = 0;
5797 size = MAX_PATH;
5798 r = MsiGetProperty(hpkg, "Intel", buf, &size);
5799 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5800 ok(buf[0], "property not set\n");
5802 buf[0] = 0;
5803 size = MAX_PATH;
5804 r = MsiGetProperty(hpkg, "MsiAMD64", buf, &size);
5805 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5806 ok(buf[0], "property not set\n");
5808 buf[0] = 0;
5809 size = MAX_PATH;
5810 r = MsiGetProperty(hpkg, "Msix64", buf, &size);
5811 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5812 ok(buf[0], "property not set\n");
5814 buf[0] = 0;
5815 size = MAX_PATH;
5816 r = MsiGetProperty(hpkg, "System64Folder", buf, &size);
5817 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5818 GetSystemDirectoryA(path, MAX_PATH);
5819 if (size) buf[size - 1] = 0;
5820 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5822 buf[0] = 0;
5823 size = MAX_PATH;
5824 r = MsiGetProperty(hpkg, "SystemFolder", buf, &size);
5825 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5826 pGetSystemWow64DirectoryA(path, MAX_PATH);
5827 if (size) buf[size - 1] = 0;
5828 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5830 buf[0] = 0;
5831 size = MAX_PATH;
5832 r = MsiGetProperty(hpkg, "ProgramFilesFolder64", buf, &size);
5833 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5834 ok(!buf[0], "property set\n");
5836 buf[0] = 0;
5837 size = MAX_PATH;
5838 r = MsiGetProperty(hpkg, "ProgramFilesFolder", buf, &size);
5839 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5840 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5841 if (size) buf[size - 1] = 0;
5842 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5844 buf[0] = 0;
5845 size = MAX_PATH;
5846 r = MsiGetProperty(hpkg, "CommonFilesFolder64", buf, &size);
5847 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5848 ok(!buf[0], "property set\n");
5850 buf[0] = 0;
5851 size = MAX_PATH;
5852 r = MsiGetProperty(hpkg, "CommonFilesFolder", buf, &size);
5853 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5854 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5855 if (size) buf[size - 1] = 0;
5856 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5858 buf[0] = 0;
5859 size = MAX_PATH;
5860 r = MsiGetProperty(hpkg, "VersionNT64", buf, &size);
5861 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5862 ok(buf[0], "property not set\n");
5867 CloseHandle(hkey1);
5868 CloseHandle(hkey2);
5869 MsiCloseHandle(hpkg);
5870 DeleteFile(msifile);
5871 MsiSetInternalUI(uilevel, NULL);
5874 static void test_launchconditions(void)
5876 MSIHANDLE hpkg;
5877 MSIHANDLE hdb;
5878 UINT r;
5880 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5882 hdb = create_package_db();
5883 ok( hdb, "failed to create package database\n" );
5885 r = create_launchcondition_table( hdb );
5886 ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
5888 r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
5889 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
5891 /* invalid condition */
5892 r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
5893 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
5895 r = package_from_db( hdb, &hpkg );
5896 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5898 skip("Not enough rights to perform tests\n");
5899 DeleteFile(msifile);
5900 return;
5902 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5904 MsiCloseHandle( hdb );
5906 r = MsiSetProperty( hpkg, "X", "1" );
5907 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5909 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5911 /* invalid conditions are ignored */
5912 r = MsiDoAction( hpkg, "LaunchConditions" );
5913 ok( r == ERROR_SUCCESS, "cost init failed\n" );
5915 /* verify LaunchConditions still does some verification */
5916 r = MsiSetProperty( hpkg, "X", "2" );
5917 ok( r == ERROR_SUCCESS, "failed to set property\n" );
5919 r = MsiDoAction( hpkg, "LaunchConditions" );
5920 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
5922 MsiCloseHandle( hpkg );
5923 DeleteFile( msifile );
5926 static void test_ccpsearch(void)
5928 MSIHANDLE hdb, hpkg;
5929 CHAR prop[MAX_PATH];
5930 DWORD size = MAX_PATH;
5931 UINT r;
5933 hdb = create_package_db();
5934 ok(hdb, "failed to create package database\n");
5936 r = create_ccpsearch_table(hdb);
5937 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5939 r = add_ccpsearch_entry(hdb, "'CCP_random'");
5940 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5942 r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
5943 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5945 r = create_reglocator_table(hdb);
5946 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5948 r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
5949 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5951 r = create_drlocator_table(hdb);
5952 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5954 r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
5955 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5957 r = create_signature_table(hdb);
5958 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5960 r = package_from_db(hdb, &hpkg);
5961 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5963 skip("Not enough rights to perform tests\n");
5964 DeleteFile(msifile);
5965 return;
5967 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
5969 MsiCloseHandle(hdb);
5971 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5973 r = MsiDoAction(hpkg, "CCPSearch");
5974 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5976 r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
5977 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5978 ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
5980 MsiCloseHandle(hpkg);
5981 DeleteFileA(msifile);
5984 static void test_complocator(void)
5986 MSIHANDLE hdb, hpkg;
5987 UINT r;
5988 CHAR prop[MAX_PATH];
5989 CHAR expected[MAX_PATH];
5990 DWORD size = MAX_PATH;
5992 hdb = create_package_db();
5993 ok(hdb, "failed to create package database\n");
5995 r = create_appsearch_table(hdb);
5996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5998 r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
5999 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6001 r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
6002 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6004 r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
6005 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6007 r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
6008 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6010 r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
6011 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6013 r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
6014 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6016 r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
6017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6019 r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
6020 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6022 r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
6023 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6025 r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
6026 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6028 r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
6029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6031 r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
6032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6034 r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
6035 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6037 r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
6038 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6040 r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
6041 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6043 r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
6044 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6046 r = create_complocator_table(hdb);
6047 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6049 r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6050 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6052 r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6053 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6055 r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6056 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6058 r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6059 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6061 r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6062 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6064 r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6065 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6067 r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6068 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6070 r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6071 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6073 r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6076 r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6077 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6079 r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6080 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6082 r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6083 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6085 r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6086 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6088 r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6089 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6091 r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6092 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6094 r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6095 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6097 r = create_signature_table(hdb);
6098 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6100 r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6103 r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6106 r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6107 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6109 r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6112 r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6113 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6115 r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6116 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6118 r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6121 r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6124 r = package_from_db(hdb, &hpkg);
6125 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6127 skip("Not enough rights to perform tests\n");
6128 DeleteFile(msifile);
6129 return;
6131 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6133 MsiCloseHandle(hdb);
6135 create_test_file("abelisaurus");
6136 create_test_file("bactrosaurus");
6137 create_test_file("camelotia");
6138 create_test_file("diclonius");
6139 create_test_file("echinodon");
6140 create_test_file("falcarius");
6141 create_test_file("gallimimus");
6142 create_test_file("hagryphus");
6143 CreateDirectoryA("iguanodon", NULL);
6144 CreateDirectoryA("jobaria", NULL);
6145 CreateDirectoryA("kakuru", NULL);
6146 CreateDirectoryA("labocania", NULL);
6147 CreateDirectoryA("megaraptor", NULL);
6148 CreateDirectoryA("neosodon", NULL);
6149 CreateDirectoryA("olorotitan", NULL);
6150 CreateDirectoryA("pantydraco", NULL);
6152 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
6153 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
6154 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
6155 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
6156 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
6157 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
6158 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
6159 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
6160 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
6161 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
6162 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
6163 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
6164 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
6165 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
6166 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
6167 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
6169 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6171 r = MsiDoAction(hpkg, "AppSearch");
6172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6174 size = MAX_PATH;
6175 r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
6176 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6178 lstrcpyA(expected, CURR_DIR);
6179 lstrcatA(expected, "\\abelisaurus");
6180 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6181 "Expected %s or empty string, got %s\n", expected, prop);
6183 size = MAX_PATH;
6184 r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
6185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6186 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6188 size = MAX_PATH;
6189 r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
6190 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6191 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6193 size = MAX_PATH;
6194 r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
6195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6196 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6198 size = MAX_PATH;
6199 r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
6200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6202 lstrcpyA(expected, CURR_DIR);
6203 lstrcatA(expected, "\\");
6204 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6205 "Expected %s or empty string, got %s\n", expected, prop);
6207 size = MAX_PATH;
6208 r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
6209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6210 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6212 size = MAX_PATH;
6213 r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
6214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6215 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6217 size = MAX_PATH;
6218 r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
6219 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6220 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6222 size = MAX_PATH;
6223 r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
6224 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6225 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6227 size = MAX_PATH;
6228 r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
6229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6230 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6232 size = MAX_PATH;
6233 r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
6234 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6235 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6237 size = MAX_PATH;
6238 r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
6239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6240 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6242 size = MAX_PATH;
6243 r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
6244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6246 lstrcpyA(expected, CURR_DIR);
6247 lstrcatA(expected, "\\");
6248 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6249 "Expected %s or empty string, got %s\n", expected, prop);
6251 size = MAX_PATH;
6252 r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
6253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6255 lstrcpyA(expected, CURR_DIR);
6256 lstrcatA(expected, "\\neosodon\\");
6257 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6258 "Expected %s or empty string, got %s\n", expected, prop);
6260 size = MAX_PATH;
6261 r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
6262 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6263 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6265 size = MAX_PATH;
6266 r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
6267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6268 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6270 MsiCloseHandle(hpkg);
6271 DeleteFileA("abelisaurus");
6272 DeleteFileA("bactrosaurus");
6273 DeleteFileA("camelotia");
6274 DeleteFileA("diclonius");
6275 DeleteFileA("echinodon");
6276 DeleteFileA("falcarius");
6277 DeleteFileA("gallimimus");
6278 DeleteFileA("hagryphus");
6279 RemoveDirectoryA("iguanodon");
6280 RemoveDirectoryA("jobaria");
6281 RemoveDirectoryA("kakuru");
6282 RemoveDirectoryA("labocania");
6283 RemoveDirectoryA("megaraptor");
6284 RemoveDirectoryA("neosodon");
6285 RemoveDirectoryA("olorotitan");
6286 RemoveDirectoryA("pantydraco");
6287 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6288 MSIINSTALLCONTEXT_MACHINE, NULL);
6289 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6290 MSIINSTALLCONTEXT_MACHINE, NULL);
6291 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6292 MSIINSTALLCONTEXT_MACHINE, NULL);
6293 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6294 MSIINSTALLCONTEXT_MACHINE, NULL);
6295 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6296 MSIINSTALLCONTEXT_MACHINE, NULL);
6297 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6298 MSIINSTALLCONTEXT_MACHINE, NULL);
6299 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6300 MSIINSTALLCONTEXT_MACHINE, NULL);
6301 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6302 MSIINSTALLCONTEXT_MACHINE, NULL);
6303 DeleteFileA(msifile);
6306 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
6308 MSIHANDLE summary;
6309 UINT r;
6311 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6312 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6314 r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
6315 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6317 r = MsiSummaryInfoPersist(summary);
6318 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6320 MsiCloseHandle(summary);
6323 static void test_MsiGetSourcePath(void)
6325 MSIHANDLE hdb, hpkg;
6326 CHAR path[MAX_PATH];
6327 CHAR cwd[MAX_PATH];
6328 CHAR subsrc[MAX_PATH];
6329 CHAR sub2[MAX_PATH];
6330 DWORD size;
6331 UINT r;
6333 lstrcpyA(cwd, CURR_DIR);
6334 lstrcatA(cwd, "\\");
6336 lstrcpyA(subsrc, cwd);
6337 lstrcatA(subsrc, "subsource");
6338 lstrcatA(subsrc, "\\");
6340 lstrcpyA(sub2, subsrc);
6341 lstrcatA(sub2, "sub2");
6342 lstrcatA(sub2, "\\");
6344 /* uncompressed source */
6346 hdb = create_package_db();
6347 ok( hdb, "failed to create database\n");
6349 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
6351 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
6352 ok(r == S_OK, "failed\n");
6354 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6355 ok(r == S_OK, "failed\n");
6357 r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
6358 ok(r == S_OK, "failed\n");
6360 r = MsiDatabaseCommit(hdb);
6361 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6363 r = package_from_db(hdb, &hpkg);
6364 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6366 skip("Not enough rights to perform tests\n");
6367 DeleteFile(msifile);
6368 return;
6370 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6372 MsiCloseHandle(hdb);
6374 /* invalid database handle */
6375 size = MAX_PATH;
6376 lstrcpyA(path, "kiwi");
6377 r = MsiGetSourcePath(-1, "TARGETDIR", path, &size);
6378 ok(r == ERROR_INVALID_HANDLE,
6379 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
6380 ok(!lstrcmpA(path, "kiwi"),
6381 "Expected path to be unchanged, got \"%s\"\n", path);
6382 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6384 /* NULL szFolder */
6385 size = MAX_PATH;
6386 lstrcpyA(path, "kiwi");
6387 r = MsiGetSourcePath(hpkg, NULL, path, &size);
6388 ok(r == ERROR_INVALID_PARAMETER,
6389 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6390 ok(!lstrcmpA(path, "kiwi"),
6391 "Expected path to be unchanged, got \"%s\"\n", path);
6392 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6394 /* empty szFolder */
6395 size = MAX_PATH;
6396 lstrcpyA(path, "kiwi");
6397 r = MsiGetSourcePath(hpkg, "", path, &size);
6398 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6399 ok(!lstrcmpA(path, "kiwi"),
6400 "Expected path to be unchanged, got \"%s\"\n", path);
6401 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6403 /* try TARGETDIR */
6404 size = MAX_PATH;
6405 lstrcpyA(path, "kiwi");
6406 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6407 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6408 ok(!lstrcmpA(path, "kiwi"),
6409 "Expected path to be unchanged, got \"%s\"\n", path);
6410 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6412 size = MAX_PATH;
6413 lstrcpyA(path, "kiwi");
6414 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6415 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6416 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6417 ok(size == 0, "Expected 0, got %d\n", size);
6419 size = MAX_PATH;
6420 lstrcpyA(path, "kiwi");
6421 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6422 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6423 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6424 ok(size == 0, "Expected 0, got %d\n", size);
6426 /* try SourceDir */
6427 size = MAX_PATH;
6428 lstrcpyA(path, "kiwi");
6429 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6430 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6431 ok(!lstrcmpA(path, "kiwi"),
6432 "Expected path to be unchanged, got \"%s\"\n", path);
6433 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6435 /* try SOURCEDIR */
6436 size = MAX_PATH;
6437 lstrcpyA(path, "kiwi");
6438 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6439 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6440 ok(!lstrcmpA(path, "kiwi"),
6441 "Expected path to be unchanged, got \"%s\"\n", path);
6442 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6444 /* source path does not exist, but the property exists */
6445 size = MAX_PATH;
6446 lstrcpyA(path, "kiwi");
6447 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6448 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6449 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6450 ok(size == 0, "Expected 0, got %d\n", size);
6452 size = MAX_PATH;
6453 lstrcpyA(path, "kiwi");
6454 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6455 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6456 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6457 ok(size == 0, "Expected 0, got %d\n", size);
6459 /* try SubDir */
6460 size = MAX_PATH;
6461 lstrcpyA(path, "kiwi");
6462 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6463 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6464 ok(!lstrcmpA(path, "kiwi"),
6465 "Expected path to be unchanged, got \"%s\"\n", path);
6466 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6468 /* try SubDir2 */
6469 size = MAX_PATH;
6470 lstrcpyA(path, "kiwi");
6471 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6472 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6473 ok(!lstrcmpA(path, "kiwi"),
6474 "Expected path to be unchanged, got \"%s\"\n", path);
6475 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6477 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6479 r = MsiDoAction(hpkg, "CostInitialize");
6480 ok(r == ERROR_SUCCESS, "cost init failed\n");
6482 /* try TARGETDIR after CostInitialize */
6483 size = MAX_PATH;
6484 lstrcpyA(path, "kiwi");
6485 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6486 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6487 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6488 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6490 /* try SourceDir after CostInitialize */
6491 size = MAX_PATH;
6492 lstrcpyA(path, "kiwi");
6493 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6494 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6495 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6496 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6498 /* try SOURCEDIR after CostInitialize */
6499 size = MAX_PATH;
6500 lstrcpyA(path, "kiwi");
6501 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6502 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6503 ok(!lstrcmpA(path, "kiwi"),
6504 "Expected path to be unchanged, got \"%s\"\n", path);
6505 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6507 /* source path does not exist, but the property exists */
6508 size = MAX_PATH;
6509 lstrcpyA(path, "kiwi");
6510 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6511 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6512 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6513 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6515 size = MAX_PATH;
6516 lstrcpyA(path, "kiwi");
6517 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6518 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6519 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6520 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6522 /* try SubDir after CostInitialize */
6523 size = MAX_PATH;
6524 lstrcpyA(path, "kiwi");
6525 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6526 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6527 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6528 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6530 /* try SubDir2 after CostInitialize */
6531 size = MAX_PATH;
6532 lstrcpyA(path, "kiwi");
6533 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6534 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6535 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6536 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6538 r = MsiDoAction(hpkg, "ResolveSource");
6539 ok(r == ERROR_SUCCESS, "file cost failed\n");
6541 /* try TARGETDIR after ResolveSource */
6542 size = MAX_PATH;
6543 lstrcpyA(path, "kiwi");
6544 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6545 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6546 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6547 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6549 /* try SourceDir after ResolveSource */
6550 size = MAX_PATH;
6551 lstrcpyA(path, "kiwi");
6552 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6553 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6554 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6555 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6557 /* try SOURCEDIR after ResolveSource */
6558 size = MAX_PATH;
6559 lstrcpyA(path, "kiwi");
6560 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6561 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6562 ok(!lstrcmpA(path, "kiwi"),
6563 "Expected path to be unchanged, got \"%s\"\n", path);
6564 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6566 /* source path does not exist, but the property exists */
6567 size = MAX_PATH;
6568 lstrcpyA(path, "kiwi");
6569 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6570 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6571 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6572 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6574 size = MAX_PATH;
6575 lstrcpyA(path, "kiwi");
6576 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6577 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6578 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6579 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6581 /* try SubDir after ResolveSource */
6582 size = MAX_PATH;
6583 lstrcpyA(path, "kiwi");
6584 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6585 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6586 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6587 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6589 /* try SubDir2 after ResolveSource */
6590 size = MAX_PATH;
6591 lstrcpyA(path, "kiwi");
6592 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6593 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6594 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6595 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6597 r = MsiDoAction(hpkg, "FileCost");
6598 ok(r == ERROR_SUCCESS, "file cost failed\n");
6600 /* try TARGETDIR after FileCost */
6601 size = MAX_PATH;
6602 lstrcpyA(path, "kiwi");
6603 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6605 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6606 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6608 /* try SourceDir after FileCost */
6609 size = MAX_PATH;
6610 lstrcpyA(path, "kiwi");
6611 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6612 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6613 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6614 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6616 /* try SOURCEDIR after FileCost */
6617 size = MAX_PATH;
6618 lstrcpyA(path, "kiwi");
6619 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6620 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6621 ok(!lstrcmpA(path, "kiwi"),
6622 "Expected path to be unchanged, got \"%s\"\n", path);
6623 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6625 /* source path does not exist, but the property exists */
6626 size = MAX_PATH;
6627 lstrcpyA(path, "kiwi");
6628 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6629 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6630 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6631 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6633 size = MAX_PATH;
6634 lstrcpyA(path, "kiwi");
6635 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6636 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6637 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6638 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6640 /* try SubDir after FileCost */
6641 size = MAX_PATH;
6642 lstrcpyA(path, "kiwi");
6643 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6644 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6645 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6646 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6648 /* try SubDir2 after FileCost */
6649 size = MAX_PATH;
6650 lstrcpyA(path, "kiwi");
6651 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6652 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6653 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6654 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6656 r = MsiDoAction(hpkg, "CostFinalize");
6657 ok(r == ERROR_SUCCESS, "file cost failed\n");
6659 /* try TARGETDIR after CostFinalize */
6660 size = MAX_PATH;
6661 lstrcpyA(path, "kiwi");
6662 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6663 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6664 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6665 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6667 /* try SourceDir after CostFinalize */
6668 size = MAX_PATH;
6669 lstrcpyA(path, "kiwi");
6670 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6671 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6672 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6673 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6675 /* try SOURCEDIR after CostFinalize */
6676 size = MAX_PATH;
6677 lstrcpyA(path, "kiwi");
6678 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6679 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6680 ok(!lstrcmpA(path, "kiwi"),
6681 "Expected path to be unchanged, got \"%s\"\n", path);
6682 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6684 /* source path does not exist, but the property exists */
6685 size = MAX_PATH;
6686 lstrcpyA(path, "kiwi");
6687 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6688 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6689 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6690 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6692 size = MAX_PATH;
6693 lstrcpyA(path, "kiwi");
6694 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6695 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6696 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6697 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6699 /* try SubDir after CostFinalize */
6700 size = MAX_PATH;
6701 lstrcpyA(path, "kiwi");
6702 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6703 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6704 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6705 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6707 /* try SubDir2 after CostFinalize */
6708 size = MAX_PATH;
6709 lstrcpyA(path, "kiwi");
6710 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6711 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6712 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6713 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6715 /* nonexistent directory */
6716 size = MAX_PATH;
6717 lstrcpyA(path, "kiwi");
6718 r = MsiGetSourcePath(hpkg, "IDontExist", path, &size);
6719 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6720 ok(!lstrcmpA(path, "kiwi"),
6721 "Expected path to be unchanged, got \"%s\"\n", path);
6722 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6724 /* NULL szPathBuf */
6725 size = MAX_PATH;
6726 r = MsiGetSourcePath(hpkg, "SourceDir", NULL, &size);
6727 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6728 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6730 /* NULL pcchPathBuf */
6731 lstrcpyA(path, "kiwi");
6732 r = MsiGetSourcePath(hpkg, "SourceDir", path, NULL);
6733 ok(r == ERROR_INVALID_PARAMETER,
6734 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6735 ok(!lstrcmpA(path, "kiwi"),
6736 "Expected path to be unchanged, got \"%s\"\n", path);
6738 /* pcchPathBuf is 0 */
6739 size = 0;
6740 lstrcpyA(path, "kiwi");
6741 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6742 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6743 ok(!lstrcmpA(path, "kiwi"),
6744 "Expected path to be unchanged, got \"%s\"\n", path);
6745 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6747 /* pcchPathBuf does not have room for NULL terminator */
6748 size = lstrlenA(cwd);
6749 lstrcpyA(path, "kiwi");
6750 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6751 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6752 ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
6753 "Expected path with no backslash, got \"%s\"\n", path);
6754 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6756 /* pcchPathBuf has room for NULL terminator */
6757 size = lstrlenA(cwd) + 1;
6758 lstrcpyA(path, "kiwi");
6759 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6761 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6762 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6764 /* remove property */
6765 r = MsiSetProperty(hpkg, "SourceDir", NULL);
6766 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6768 /* try SourceDir again */
6769 size = MAX_PATH;
6770 lstrcpyA(path, "kiwi");
6771 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6772 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6773 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6774 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6776 /* set property to a valid directory */
6777 r = MsiSetProperty(hpkg, "SOURCEDIR", cwd);
6778 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6780 /* try SOURCEDIR again */
6781 size = MAX_PATH;
6782 lstrcpyA(path, "kiwi");
6783 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6784 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6785 ok(!lstrcmpA(path, "kiwi"),
6786 "Expected path to be unchanged, got \"%s\"\n", path);
6787 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6789 MsiCloseHandle(hpkg);
6791 /* compressed source */
6793 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
6794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6796 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
6798 r = package_from_db(hdb, &hpkg);
6799 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6801 /* try TARGETDIR */
6802 size = MAX_PATH;
6803 lstrcpyA(path, "kiwi");
6804 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6805 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6806 ok(!lstrcmpA(path, "kiwi"),
6807 "Expected path to be unchanged, got \"%s\"\n", path);
6808 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6810 /* try SourceDir */
6811 size = MAX_PATH;
6812 lstrcpyA(path, "kiwi");
6813 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6814 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6815 ok(!lstrcmpA(path, "kiwi"),
6816 "Expected path to be unchanged, got \"%s\"\n", path);
6817 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6819 /* try SOURCEDIR */
6820 size = MAX_PATH;
6821 lstrcpyA(path, "kiwi");
6822 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6823 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6824 ok(!lstrcmpA(path, "kiwi"),
6825 "Expected path to be unchanged, got \"%s\"\n", path);
6826 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6828 /* source path nor the property exist */
6829 size = MAX_PATH;
6830 lstrcpyA(path, "kiwi");
6831 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6832 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6833 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6834 ok(size == 0, "Expected 0, got %d\n", size);
6836 size = MAX_PATH;
6837 lstrcpyA(path, "kiwi");
6838 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6839 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6840 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6841 ok(size == 0, "Expected 0, got %d\n", size);
6843 /* try SubDir */
6844 size = MAX_PATH;
6845 lstrcpyA(path, "kiwi");
6846 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6847 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6848 ok(!lstrcmpA(path, "kiwi"),
6849 "Expected path to be unchanged, got \"%s\"\n", path);
6850 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6852 /* try SubDir2 */
6853 size = MAX_PATH;
6854 lstrcpyA(path, "kiwi");
6855 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6856 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6857 ok(!lstrcmpA(path, "kiwi"),
6858 "Expected path to be unchanged, got \"%s\"\n", path);
6859 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6861 r = MsiDoAction(hpkg, "CostInitialize");
6862 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6864 /* try TARGETDIR after CostInitialize */
6865 size = MAX_PATH;
6866 lstrcpyA(path, "kiwi");
6867 r = MsiGetSourcePath(hpkg, "TARGETDIR", 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 SourceDir after CostInitialize */
6873 size = MAX_PATH;
6874 lstrcpyA(path, "kiwi");
6875 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6876 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6877 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6878 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6880 /* try SOURCEDIR after CostInitialize */
6881 size = MAX_PATH;
6882 lstrcpyA(path, "kiwi");
6883 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6884 todo_wine
6886 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6887 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6888 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6891 /* source path does not exist, but the property exists */
6892 size = MAX_PATH;
6893 lstrcpyA(path, "kiwi");
6894 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6895 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6896 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6897 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6899 size = MAX_PATH;
6900 lstrcpyA(path, "kiwi");
6901 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6903 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6904 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6906 /* try SubDir after CostInitialize */
6907 size = MAX_PATH;
6908 lstrcpyA(path, "kiwi");
6909 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6911 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6912 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6914 /* try SubDir2 after CostInitialize */
6915 size = MAX_PATH;
6916 lstrcpyA(path, "kiwi");
6917 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6918 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6919 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6920 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6922 r = MsiDoAction(hpkg, "ResolveSource");
6923 ok(r == ERROR_SUCCESS, "file cost failed\n");
6925 /* try TARGETDIR after ResolveSource */
6926 size = MAX_PATH;
6927 lstrcpyA(path, "kiwi");
6928 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6930 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6931 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6933 /* try SourceDir after ResolveSource */
6934 size = MAX_PATH;
6935 lstrcpyA(path, "kiwi");
6936 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6937 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6938 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6939 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6941 /* try SOURCEDIR after ResolveSource */
6942 size = MAX_PATH;
6943 lstrcpyA(path, "kiwi");
6944 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
6945 todo_wine
6947 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6948 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6949 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6952 /* source path and the property exist */
6953 size = MAX_PATH;
6954 lstrcpyA(path, "kiwi");
6955 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
6956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6957 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6958 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6960 size = MAX_PATH;
6961 lstrcpyA(path, "kiwi");
6962 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
6963 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6964 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6965 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6967 /* try SubDir after ResolveSource */
6968 size = MAX_PATH;
6969 lstrcpyA(path, "kiwi");
6970 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
6971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6972 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6973 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6975 /* try SubDir2 after ResolveSource */
6976 size = MAX_PATH;
6977 lstrcpyA(path, "kiwi");
6978 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
6979 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6980 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6981 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6983 r = MsiDoAction(hpkg, "FileCost");
6984 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6986 /* try TARGETDIR after CostFinalize */
6987 size = MAX_PATH;
6988 lstrcpyA(path, "kiwi");
6989 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
6990 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6991 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6992 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6994 /* try SourceDir after CostFinalize */
6995 size = MAX_PATH;
6996 lstrcpyA(path, "kiwi");
6997 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
6998 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6999 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7000 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7002 /* try SOURCEDIR after CostFinalize */
7003 size = MAX_PATH;
7004 lstrcpyA(path, "kiwi");
7005 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7006 todo_wine
7008 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7009 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7010 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7013 /* source path and the property exist */
7014 size = MAX_PATH;
7015 lstrcpyA(path, "kiwi");
7016 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7018 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7019 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7021 size = MAX_PATH;
7022 lstrcpyA(path, "kiwi");
7023 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7025 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7026 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7028 /* try SubDir after CostFinalize */
7029 size = MAX_PATH;
7030 lstrcpyA(path, "kiwi");
7031 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7033 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7034 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7036 /* try SubDir2 after CostFinalize */
7037 size = MAX_PATH;
7038 lstrcpyA(path, "kiwi");
7039 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7040 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7041 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7042 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7044 r = MsiDoAction(hpkg, "CostFinalize");
7045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7047 /* try TARGETDIR after CostFinalize */
7048 size = MAX_PATH;
7049 lstrcpyA(path, "kiwi");
7050 r = MsiGetSourcePath(hpkg, "TARGETDIR", path, &size);
7051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7052 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7053 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7055 /* try SourceDir after CostFinalize */
7056 size = MAX_PATH;
7057 lstrcpyA(path, "kiwi");
7058 r = MsiGetSourcePath(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);
7063 /* try SOURCEDIR after CostFinalize */
7064 size = MAX_PATH;
7065 lstrcpyA(path, "kiwi");
7066 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7067 todo_wine
7069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7070 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7071 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7074 /* source path and the property exist */
7075 size = MAX_PATH;
7076 lstrcpyA(path, "kiwi");
7077 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7078 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7079 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7080 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7082 size = MAX_PATH;
7083 lstrcpyA(path, "kiwi");
7084 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7085 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7086 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7087 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7089 /* try SubDir after CostFinalize */
7090 size = MAX_PATH;
7091 lstrcpyA(path, "kiwi");
7092 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7093 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7094 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7095 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7097 /* try SubDir2 after CostFinalize */
7098 size = MAX_PATH;
7099 lstrcpyA(path, "kiwi");
7100 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7102 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7103 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7105 MsiCloseHandle(hpkg);
7106 DeleteFile(msifile);
7109 static void test_shortlongsource(void)
7111 MSIHANDLE hdb, hpkg;
7112 CHAR path[MAX_PATH];
7113 CHAR cwd[MAX_PATH];
7114 CHAR subsrc[MAX_PATH];
7115 DWORD size;
7116 UINT r;
7118 lstrcpyA(cwd, CURR_DIR);
7119 lstrcatA(cwd, "\\");
7121 lstrcpyA(subsrc, cwd);
7122 lstrcatA(subsrc, "long");
7123 lstrcatA(subsrc, "\\");
7125 /* long file names */
7127 hdb = create_package_db();
7128 ok( hdb, "failed to create database\n");
7130 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
7132 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7133 ok(r == S_OK, "failed\n");
7135 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
7136 ok(r == S_OK, "failed\n");
7138 /* CostInitialize:short */
7139 r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
7140 ok(r == S_OK, "failed\n");
7142 /* CostInitialize:long */
7143 r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
7144 ok(r == S_OK, "failed\n");
7146 /* FileCost:short */
7147 r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
7148 ok(r == S_OK, "failed\n");
7150 /* FileCost:long */
7151 r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7152 ok(r == S_OK, "failed\n");
7154 /* CostFinalize:short */
7155 r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7156 ok(r == S_OK, "failed\n");
7158 /* CostFinalize:long */
7159 r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7160 ok(r == S_OK, "failed\n");
7162 MsiDatabaseCommit(hdb);
7164 r = package_from_db(hdb, &hpkg);
7165 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7167 skip("Not enough rights to perform tests\n");
7168 DeleteFile(msifile);
7169 return;
7171 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7173 MsiCloseHandle(hdb);
7175 CreateDirectoryA("one", NULL);
7176 CreateDirectoryA("four", NULL);
7178 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7180 r = MsiDoAction(hpkg, "CostInitialize");
7181 ok(r == ERROR_SUCCESS, "file cost failed\n");
7183 CreateDirectory("five", NULL);
7184 CreateDirectory("eight", NULL);
7186 r = MsiDoAction(hpkg, "FileCost");
7187 ok(r == ERROR_SUCCESS, "file cost failed\n");
7189 CreateDirectory("nine", NULL);
7190 CreateDirectory("twelve", NULL);
7192 r = MsiDoAction(hpkg, "CostFinalize");
7193 ok(r == ERROR_SUCCESS, "file cost failed\n");
7195 /* neither short nor long source directories exist */
7196 size = MAX_PATH;
7197 lstrcpyA(path, "kiwi");
7198 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7200 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7201 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7203 CreateDirectoryA("short", NULL);
7205 /* short source directory exists */
7206 size = MAX_PATH;
7207 lstrcpyA(path, "kiwi");
7208 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7210 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7211 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7213 CreateDirectoryA("long", NULL);
7215 /* both short and long source directories exist */
7216 size = MAX_PATH;
7217 lstrcpyA(path, "kiwi");
7218 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7219 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7220 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7221 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7223 lstrcpyA(subsrc, cwd);
7224 lstrcatA(subsrc, "two");
7225 lstrcatA(subsrc, "\\");
7227 /* short dir exists before CostInitialize */
7228 size = MAX_PATH;
7229 lstrcpyA(path, "kiwi");
7230 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7231 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7232 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7233 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7235 lstrcpyA(subsrc, cwd);
7236 lstrcatA(subsrc, "four");
7237 lstrcatA(subsrc, "\\");
7239 /* long dir exists before CostInitialize */
7240 size = MAX_PATH;
7241 lstrcpyA(path, "kiwi");
7242 r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
7243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7244 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7245 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7247 lstrcpyA(subsrc, cwd);
7248 lstrcatA(subsrc, "six");
7249 lstrcatA(subsrc, "\\");
7251 /* short dir exists before FileCost */
7252 size = MAX_PATH;
7253 lstrcpyA(path, "kiwi");
7254 r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
7255 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7256 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7257 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7259 lstrcpyA(subsrc, cwd);
7260 lstrcatA(subsrc, "eight");
7261 lstrcatA(subsrc, "\\");
7263 /* long dir exists before FileCost */
7264 size = MAX_PATH;
7265 lstrcpyA(path, "kiwi");
7266 r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
7267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7268 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7269 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7271 lstrcpyA(subsrc, cwd);
7272 lstrcatA(subsrc, "ten");
7273 lstrcatA(subsrc, "\\");
7275 /* short dir exists before CostFinalize */
7276 size = MAX_PATH;
7277 lstrcpyA(path, "kiwi");
7278 r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
7279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7280 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7281 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7283 lstrcpyA(subsrc, cwd);
7284 lstrcatA(subsrc, "twelve");
7285 lstrcatA(subsrc, "\\");
7287 /* long dir exists before CostFinalize */
7288 size = MAX_PATH;
7289 lstrcpyA(path, "kiwi");
7290 r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
7291 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7292 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7293 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7295 MsiCloseHandle(hpkg);
7296 RemoveDirectoryA("short");
7297 RemoveDirectoryA("long");
7298 RemoveDirectoryA("one");
7299 RemoveDirectoryA("four");
7300 RemoveDirectoryA("five");
7301 RemoveDirectoryA("eight");
7302 RemoveDirectoryA("nine");
7303 RemoveDirectoryA("twelve");
7305 /* short file names */
7307 r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
7308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7310 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
7312 r = package_from_db(hdb, &hpkg);
7313 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7315 MsiCloseHandle(hdb);
7317 CreateDirectoryA("one", NULL);
7318 CreateDirectoryA("four", NULL);
7320 r = MsiDoAction(hpkg, "CostInitialize");
7321 ok(r == ERROR_SUCCESS, "file cost failed\n");
7323 CreateDirectory("five", NULL);
7324 CreateDirectory("eight", NULL);
7326 r = MsiDoAction(hpkg, "FileCost");
7327 ok(r == ERROR_SUCCESS, "file cost failed\n");
7329 CreateDirectory("nine", NULL);
7330 CreateDirectory("twelve", NULL);
7332 r = MsiDoAction(hpkg, "CostFinalize");
7333 ok(r == ERROR_SUCCESS, "file cost failed\n");
7335 lstrcpyA(subsrc, cwd);
7336 lstrcatA(subsrc, "short");
7337 lstrcatA(subsrc, "\\");
7339 /* neither short nor long source directories exist */
7340 size = MAX_PATH;
7341 lstrcpyA(path, "kiwi");
7342 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7344 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7345 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7347 CreateDirectoryA("short", NULL);
7349 /* short source directory exists */
7350 size = MAX_PATH;
7351 lstrcpyA(path, "kiwi");
7352 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7354 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7355 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7357 CreateDirectoryA("long", NULL);
7359 /* both short and long source directories exist */
7360 size = MAX_PATH;
7361 lstrcpyA(path, "kiwi");
7362 r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
7363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7364 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7365 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7367 lstrcpyA(subsrc, cwd);
7368 lstrcatA(subsrc, "one");
7369 lstrcatA(subsrc, "\\");
7371 /* short dir exists before CostInitialize */
7372 size = MAX_PATH;
7373 lstrcpyA(path, "kiwi");
7374 r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
7375 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7376 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7377 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7379 lstrcpyA(subsrc, cwd);
7380 lstrcatA(subsrc, "three");
7381 lstrcatA(subsrc, "\\");
7383 /* long dir exists before CostInitialize */
7384 size = MAX_PATH;
7385 lstrcpyA(path, "kiwi");
7386 r = MsiGetSourcePath(hpkg, "SubDir3", path, &size);
7387 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7388 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7389 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7391 lstrcpyA(subsrc, cwd);
7392 lstrcatA(subsrc, "five");
7393 lstrcatA(subsrc, "\\");
7395 /* short dir exists before FileCost */
7396 size = MAX_PATH;
7397 lstrcpyA(path, "kiwi");
7398 r = MsiGetSourcePath(hpkg, "SubDir4", path, &size);
7399 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7400 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7401 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7403 lstrcpyA(subsrc, cwd);
7404 lstrcatA(subsrc, "seven");
7405 lstrcatA(subsrc, "\\");
7407 /* long dir exists before FileCost */
7408 size = MAX_PATH;
7409 lstrcpyA(path, "kiwi");
7410 r = MsiGetSourcePath(hpkg, "SubDir5", path, &size);
7411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7412 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7413 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7415 lstrcpyA(subsrc, cwd);
7416 lstrcatA(subsrc, "nine");
7417 lstrcatA(subsrc, "\\");
7419 /* short dir exists before CostFinalize */
7420 size = MAX_PATH;
7421 lstrcpyA(path, "kiwi");
7422 r = MsiGetSourcePath(hpkg, "SubDir6", path, &size);
7423 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7424 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7425 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7427 lstrcpyA(subsrc, cwd);
7428 lstrcatA(subsrc, "eleven");
7429 lstrcatA(subsrc, "\\");
7431 /* long dir exists before CostFinalize */
7432 size = MAX_PATH;
7433 lstrcpyA(path, "kiwi");
7434 r = MsiGetSourcePath(hpkg, "SubDir7", path, &size);
7435 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7436 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7437 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7439 MsiCloseHandle(hpkg);
7440 RemoveDirectoryA("short");
7441 RemoveDirectoryA("long");
7442 RemoveDirectoryA("one");
7443 RemoveDirectoryA("four");
7444 RemoveDirectoryA("five");
7445 RemoveDirectoryA("eight");
7446 RemoveDirectoryA("nine");
7447 RemoveDirectoryA("twelve");
7448 DeleteFileA(msifile);
7451 static void test_sourcedir(void)
7453 MSIHANDLE hdb, hpkg;
7454 CHAR package[12];
7455 CHAR path[MAX_PATH];
7456 CHAR cwd[MAX_PATH];
7457 CHAR subsrc[MAX_PATH];
7458 DWORD size;
7459 UINT r;
7461 lstrcpyA(cwd, CURR_DIR);
7462 lstrcatA(cwd, "\\");
7464 lstrcpyA(subsrc, cwd);
7465 lstrcatA(subsrc, "long");
7466 lstrcatA(subsrc, "\\");
7468 hdb = create_package_db();
7469 ok( hdb, "failed to create database\n");
7471 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7472 ok(r == S_OK, "failed\n");
7474 sprintf(package, "#%u", hdb);
7475 r = MsiOpenPackage(package, &hpkg);
7476 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7478 skip("Not enough rights to perform tests\n");
7479 goto error;
7481 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7483 /* properties only */
7485 /* SourceDir prop */
7486 size = MAX_PATH;
7487 lstrcpyA(path, "kiwi");
7488 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7489 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7490 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7491 ok(size == 0, "Expected 0, got %d\n", size);
7493 /* SOURCEDIR prop */
7494 size = MAX_PATH;
7495 lstrcpyA(path, "kiwi");
7496 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7497 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7498 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7499 ok(size == 0, "Expected 0, got %d\n", size);
7501 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7503 r = MsiDoAction(hpkg, "CostInitialize");
7504 ok(r == ERROR_SUCCESS, "file cost failed\n");
7506 /* SourceDir after CostInitialize */
7507 size = MAX_PATH;
7508 lstrcpyA(path, "kiwi");
7509 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7510 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7511 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7512 ok(size == 0, "Expected 0, got %d\n", size);
7514 /* SOURCEDIR after CostInitialize */
7515 size = MAX_PATH;
7516 lstrcpyA(path, "kiwi");
7517 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7518 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7519 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7520 ok(size == 0, "Expected 0, got %d\n", size);
7522 r = MsiDoAction(hpkg, "FileCost");
7523 ok(r == ERROR_SUCCESS, "file cost failed\n");
7525 /* SourceDir after FileCost */
7526 size = MAX_PATH;
7527 lstrcpyA(path, "kiwi");
7528 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7529 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7530 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7531 ok(size == 0, "Expected 0, got %d\n", size);
7533 /* SOURCEDIR after FileCost */
7534 size = MAX_PATH;
7535 lstrcpyA(path, "kiwi");
7536 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7537 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7538 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7539 ok(size == 0, "Expected 0, got %d\n", size);
7541 r = MsiDoAction(hpkg, "CostFinalize");
7542 ok(r == ERROR_SUCCESS, "file cost failed\n");
7544 /* SourceDir after CostFinalize */
7545 size = MAX_PATH;
7546 lstrcpyA(path, "kiwi");
7547 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7549 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7550 ok(size == 0, "Expected 0, got %d\n", size);
7552 /* SOURCEDIR after CostFinalize */
7553 size = MAX_PATH;
7554 lstrcpyA(path, "kiwi");
7555 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7556 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7557 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7558 ok(size == 0, "Expected 0, got %d\n", size);
7560 size = MAX_PATH;
7561 lstrcpyA(path, "kiwi");
7562 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7563 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7564 ok(!lstrcmpA(path, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path);
7565 ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
7567 /* SOURCEDIR after calling MsiGetSourcePath */
7568 size = MAX_PATH;
7569 lstrcpyA(path, "kiwi");
7570 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7571 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7572 todo_wine {
7573 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7574 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7577 r = MsiDoAction(hpkg, "ResolveSource");
7578 ok(r == ERROR_SUCCESS, "file cost failed\n");
7580 /* SourceDir after ResolveSource */
7581 size = MAX_PATH;
7582 lstrcpyA(path, "kiwi");
7583 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7584 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7585 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7586 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7588 /* SOURCEDIR after ResolveSource */
7589 size = MAX_PATH;
7590 lstrcpyA(path, "kiwi");
7591 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7592 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7593 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7594 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7596 /* random casing */
7597 size = MAX_PATH;
7598 lstrcpyA(path, "kiwi");
7599 r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
7600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7601 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7602 ok(size == 0, "Expected 0, got %d\n", size);
7604 MsiCloseHandle(hpkg);
7606 /* reset the package state */
7607 sprintf(package, "#%i", hdb);
7608 r = MsiOpenPackage(package, &hpkg);
7609 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7611 /* test how MsiGetSourcePath affects the properties */
7613 /* SourceDir prop */
7614 size = MAX_PATH;
7615 lstrcpyA(path, "kiwi");
7616 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7617 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7618 todo_wine
7620 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7621 ok(size == 0, "Expected 0, got %d\n", size);
7624 size = MAX_PATH;
7625 lstrcpyA(path, "kiwi");
7626 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7627 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7628 ok(!lstrcmpA(path, "kiwi"),
7629 "Expected path to be unchanged, got \"%s\"\n", path);
7630 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7632 /* SourceDir after MsiGetSourcePath */
7633 size = MAX_PATH;
7634 lstrcpyA(path, "kiwi");
7635 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7636 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7637 todo_wine
7639 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7640 ok(size == 0, "Expected 0, got %d\n", size);
7643 /* SOURCEDIR prop */
7644 size = MAX_PATH;
7645 lstrcpyA(path, "kiwi");
7646 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7647 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7648 todo_wine
7650 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7651 ok(size == 0, "Expected 0, got %d\n", size);
7654 size = MAX_PATH;
7655 lstrcpyA(path, "kiwi");
7656 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7657 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7658 ok(!lstrcmpA(path, "kiwi"),
7659 "Expected path to be unchanged, got \"%s\"\n", path);
7660 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7662 /* SOURCEDIR prop after MsiGetSourcePath */
7663 size = MAX_PATH;
7664 lstrcpyA(path, "kiwi");
7665 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7666 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7667 todo_wine
7669 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7670 ok(size == 0, "Expected 0, got %d\n", size);
7673 r = MsiDoAction(hpkg, "CostInitialize");
7674 ok(r == ERROR_SUCCESS, "file cost failed\n");
7676 /* SourceDir after CostInitialize */
7677 size = MAX_PATH;
7678 lstrcpyA(path, "kiwi");
7679 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7680 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7681 todo_wine
7683 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7684 ok(size == 0, "Expected 0, got %d\n", size);
7687 size = MAX_PATH;
7688 lstrcpyA(path, "kiwi");
7689 r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
7690 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7691 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7692 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7694 /* SourceDir after MsiGetSourcePath */
7695 size = MAX_PATH;
7696 lstrcpyA(path, "kiwi");
7697 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7698 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7699 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7700 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7702 /* SOURCEDIR after CostInitialize */
7703 size = MAX_PATH;
7704 lstrcpyA(path, "kiwi");
7705 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7706 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7707 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7708 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7710 /* SOURCEDIR source path still does not exist */
7711 size = MAX_PATH;
7712 lstrcpyA(path, "kiwi");
7713 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7714 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7715 ok(!lstrcmpA(path, "kiwi"),
7716 "Expected path to be unchanged, got \"%s\"\n", path);
7717 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7719 r = MsiDoAction(hpkg, "FileCost");
7720 ok(r == ERROR_SUCCESS, "file cost failed\n");
7722 /* SourceDir after FileCost */
7723 size = MAX_PATH;
7724 lstrcpyA(path, "kiwi");
7725 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7726 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7727 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7728 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7730 /* SOURCEDIR after FileCost */
7731 size = MAX_PATH;
7732 lstrcpyA(path, "kiwi");
7733 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7734 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7735 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7736 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7738 /* SOURCEDIR source path still does not exist */
7739 size = MAX_PATH;
7740 lstrcpyA(path, "kiwi");
7741 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7742 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7743 ok(!lstrcmpA(path, "kiwi"),
7744 "Expected path to be unchanged, got \"%s\"\n", path);
7745 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7747 r = MsiDoAction(hpkg, "CostFinalize");
7748 ok(r == ERROR_SUCCESS, "file cost failed\n");
7750 /* SourceDir after CostFinalize */
7751 size = MAX_PATH;
7752 lstrcpyA(path, "kiwi");
7753 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7754 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7755 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7756 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7758 /* SOURCEDIR after CostFinalize */
7759 size = MAX_PATH;
7760 lstrcpyA(path, "kiwi");
7761 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7762 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7763 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7764 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7766 /* SOURCEDIR source path still does not exist */
7767 size = MAX_PATH;
7768 lstrcpyA(path, "kiwi");
7769 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7770 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7771 ok(!lstrcmpA(path, "kiwi"),
7772 "Expected path to be unchanged, got \"%s\"\n", path);
7773 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7775 r = MsiDoAction(hpkg, "ResolveSource");
7776 ok(r == ERROR_SUCCESS, "file cost failed\n");
7778 /* SourceDir after ResolveSource */
7779 size = MAX_PATH;
7780 lstrcpyA(path, "kiwi");
7781 r = MsiGetProperty(hpkg, "SourceDir", path, &size);
7782 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7783 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7784 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7786 /* SOURCEDIR after ResolveSource */
7787 size = MAX_PATH;
7788 lstrcpyA(path, "kiwi");
7789 r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
7790 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7791 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7792 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7794 /* SOURCEDIR source path still does not exist */
7795 size = MAX_PATH;
7796 lstrcpyA(path, "kiwi");
7797 r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
7798 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7799 ok(!lstrcmpA(path, "kiwi"),
7800 "Expected path to be unchanged, got \"%s\"\n", path);
7801 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7803 MsiCloseHandle(hpkg);
7805 error:
7806 MsiCloseHandle(hdb);
7807 DeleteFileA(msifile);
7810 struct access_res
7812 BOOL gothandle;
7813 DWORD lasterr;
7814 BOOL ignore;
7817 static const struct access_res create[16] =
7819 { TRUE, ERROR_SUCCESS, TRUE },
7820 { TRUE, ERROR_SUCCESS, TRUE },
7821 { TRUE, ERROR_SUCCESS, FALSE },
7822 { TRUE, ERROR_SUCCESS, FALSE },
7823 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7824 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7825 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7826 { TRUE, ERROR_SUCCESS, FALSE },
7827 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7828 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7829 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7830 { TRUE, ERROR_SUCCESS, TRUE },
7831 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7832 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7833 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7834 { TRUE, ERROR_SUCCESS, TRUE }
7837 static const struct access_res create_commit[16] =
7839 { TRUE, ERROR_SUCCESS, TRUE },
7840 { TRUE, ERROR_SUCCESS, TRUE },
7841 { TRUE, ERROR_SUCCESS, FALSE },
7842 { TRUE, ERROR_SUCCESS, FALSE },
7843 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7844 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7845 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7846 { TRUE, ERROR_SUCCESS, FALSE },
7847 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7848 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7849 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7850 { TRUE, ERROR_SUCCESS, TRUE },
7851 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7852 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7853 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7854 { TRUE, ERROR_SUCCESS, TRUE }
7857 static const struct access_res create_close[16] =
7859 { TRUE, ERROR_SUCCESS, FALSE },
7860 { TRUE, ERROR_SUCCESS, FALSE },
7861 { TRUE, ERROR_SUCCESS, FALSE },
7862 { TRUE, ERROR_SUCCESS, FALSE },
7863 { TRUE, ERROR_SUCCESS, FALSE },
7864 { TRUE, ERROR_SUCCESS, FALSE },
7865 { TRUE, ERROR_SUCCESS, FALSE },
7866 { TRUE, ERROR_SUCCESS, FALSE },
7867 { TRUE, ERROR_SUCCESS, FALSE },
7868 { TRUE, ERROR_SUCCESS, FALSE },
7869 { TRUE, ERROR_SUCCESS, FALSE },
7870 { TRUE, ERROR_SUCCESS, FALSE },
7871 { TRUE, ERROR_SUCCESS, FALSE },
7872 { TRUE, ERROR_SUCCESS, FALSE },
7873 { TRUE, ERROR_SUCCESS, FALSE },
7874 { TRUE, ERROR_SUCCESS }
7877 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
7879 DWORD access = 0, share = 0;
7880 DWORD lasterr;
7881 HANDLE hfile;
7882 int i, j, idx = 0;
7884 for (i = 0; i < 4; i++)
7886 if (i == 0) access = 0;
7887 if (i == 1) access = GENERIC_READ;
7888 if (i == 2) access = GENERIC_WRITE;
7889 if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
7891 for (j = 0; j < 4; j++)
7893 if (ares[idx].ignore)
7894 continue;
7896 if (j == 0) share = 0;
7897 if (j == 1) share = FILE_SHARE_READ;
7898 if (j == 2) share = FILE_SHARE_WRITE;
7899 if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
7901 SetLastError(0xdeadbeef);
7902 hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
7903 FILE_ATTRIBUTE_NORMAL, 0);
7904 lasterr = GetLastError();
7906 ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
7907 "(%d, handle, %d): Expected %d, got %d\n",
7908 line, idx, ares[idx].gothandle,
7909 (hfile != INVALID_HANDLE_VALUE));
7911 ok(lasterr == ares[idx].lasterr, "(%d, lasterr, %d): Expected %d, got %d\n",
7912 line, idx, ares[idx].lasterr, lasterr);
7914 CloseHandle(hfile);
7915 idx++;
7920 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
7922 static void test_access(void)
7924 MSIHANDLE hdb;
7925 UINT r;
7927 r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATE, &hdb);
7928 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7930 test_file_access(msifile, create);
7932 r = MsiDatabaseCommit(hdb);
7933 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7935 test_file_access(msifile, create_commit);
7936 MsiCloseHandle(hdb);
7938 test_file_access(msifile, create_close);
7939 DeleteFileA(msifile);
7941 r = MsiOpenDatabaseA(msifile, MSIDBOPEN_CREATEDIRECT, &hdb);
7942 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7944 test_file_access(msifile, create);
7946 r = MsiDatabaseCommit(hdb);
7947 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7949 test_file_access(msifile, create_commit);
7950 MsiCloseHandle(hdb);
7952 test_file_access(msifile, create_close);
7953 DeleteFileA(msifile);
7956 static void test_emptypackage(void)
7958 MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
7959 MSIHANDLE hview = 0, hrec = 0;
7960 MSICONDITION condition;
7961 CHAR buffer[MAX_PATH];
7962 DWORD size;
7963 UINT r;
7965 r = MsiOpenPackageA("", &hpkg);
7966 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7968 skip("Not enough rights to perform tests\n");
7969 return;
7971 todo_wine
7973 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7976 hdb = MsiGetActiveDatabase(hpkg);
7977 todo_wine
7979 ok(hdb != 0, "Expected a valid database handle\n");
7982 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Tables`", &hview);
7983 todo_wine
7985 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7987 r = MsiViewExecute(hview, 0);
7988 todo_wine
7990 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7993 r = MsiViewFetch(hview, &hrec);
7994 todo_wine
7996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7999 buffer[0] = 0;
8000 size = MAX_PATH;
8001 r = MsiRecordGetString(hrec, 1, buffer, &size);
8002 todo_wine
8004 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8005 ok(!lstrcmpA(buffer, "_Property"),
8006 "Expected \"_Property\", got \"%s\"\n", buffer);
8009 MsiCloseHandle(hrec);
8011 r = MsiViewFetch(hview, &hrec);
8012 todo_wine
8014 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8017 size = MAX_PATH;
8018 r = MsiRecordGetString(hrec, 1, buffer, &size);
8019 todo_wine
8021 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8022 ok(!lstrcmpA(buffer, "#_FolderCache"),
8023 "Expected \"_Property\", got \"%s\"\n", buffer);
8026 MsiCloseHandle(hrec);
8027 MsiViewClose(hview);
8028 MsiCloseHandle(hview);
8030 condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
8031 todo_wine
8033 ok(condition == MSICONDITION_FALSE,
8034 "Expected MSICONDITION_FALSE, got %d\n", condition);
8037 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Property`", &hview);
8038 todo_wine
8040 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8042 r = MsiViewExecute(hview, 0);
8043 todo_wine
8045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8048 /* _Property table is not empty */
8049 r = MsiViewFetch(hview, &hrec);
8050 todo_wine
8052 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8055 MsiCloseHandle(hrec);
8056 MsiViewClose(hview);
8057 MsiCloseHandle(hview);
8059 condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
8060 todo_wine
8062 ok(condition == MSICONDITION_FALSE,
8063 "Expected MSICONDITION_FALSE, got %d\n", condition);
8066 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `#_FolderCache`", &hview);
8067 todo_wine
8069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8071 r = MsiViewExecute(hview, 0);
8072 todo_wine
8074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8077 /* #_FolderCache is not empty */
8078 r = MsiViewFetch(hview, &hrec);
8079 todo_wine
8081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8084 MsiCloseHandle(hrec);
8085 MsiViewClose(hview);
8086 MsiCloseHandle(hview);
8088 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Streams`", &hview);
8089 todo_wine
8091 ok(r == ERROR_BAD_QUERY_SYNTAX,
8092 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8095 r = MsiDatabaseOpenView(hdb, "SELECT * FROM `_Storages`", &hview);
8096 todo_wine
8098 ok(r == ERROR_BAD_QUERY_SYNTAX,
8099 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8102 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
8103 todo_wine
8105 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
8106 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
8109 MsiCloseHandle(hsuminfo);
8111 r = MsiDatabaseCommit(hdb);
8112 todo_wine
8114 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8117 MsiCloseHandle(hdb);
8118 MsiCloseHandle(hpkg);
8121 static void test_MsiGetProductProperty(void)
8123 MSIHANDLE hprod, hdb;
8124 CHAR val[MAX_PATH];
8125 CHAR path[MAX_PATH];
8126 CHAR query[MAX_PATH];
8127 CHAR keypath[MAX_PATH*2];
8128 CHAR prodcode[MAX_PATH];
8129 CHAR prod_squashed[MAX_PATH];
8130 HKEY prodkey, userkey, props;
8131 DWORD size;
8132 LONG res;
8133 UINT r;
8134 REGSAM access = KEY_ALL_ACCESS;
8136 GetCurrentDirectoryA(MAX_PATH, path);
8137 lstrcatA(path, "\\");
8139 create_test_guid(prodcode, prod_squashed);
8141 if (is_wow64)
8142 access |= KEY_WOW64_64KEY;
8144 r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
8145 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8147 r = MsiDatabaseCommit(hdb);
8148 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8150 r = set_summary_info(hdb);
8151 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8153 r = run_query(hdb,
8154 "CREATE TABLE `Directory` ( "
8155 "`Directory` CHAR(255) NOT NULL, "
8156 "`Directory_Parent` CHAR(255), "
8157 "`DefaultDir` CHAR(255) NOT NULL "
8158 "PRIMARY KEY `Directory`)");
8159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8161 r = run_query(hdb,
8162 "CREATE TABLE `Property` ( "
8163 "`Property` CHAR(72) NOT NULL, "
8164 "`Value` CHAR(255) "
8165 "PRIMARY KEY `Property`)");
8166 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8168 sprintf(query, "INSERT INTO `Property` "
8169 "(`Property`, `Value`) "
8170 "VALUES( 'ProductCode', '%s' )", prodcode);
8171 r = run_query(hdb, query);
8172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8174 r = MsiDatabaseCommit(hdb);
8175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8177 MsiCloseHandle(hdb);
8179 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8180 lstrcatA(keypath, prod_squashed);
8182 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8183 if (res == ERROR_ACCESS_DENIED)
8185 skip("Not enough rights to perform tests\n");
8186 DeleteFile(msifile);
8187 return;
8189 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8191 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8192 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8193 lstrcatA(keypath, prod_squashed);
8195 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
8196 if (res == ERROR_ACCESS_DENIED)
8198 skip("Not enough rights to perform tests\n");
8199 RegDeleteKeyA(prodkey, "");
8200 RegCloseKey(prodkey);
8201 return;
8203 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8205 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8206 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8208 lstrcpyA(val, path);
8209 lstrcatA(val, "\\");
8210 lstrcatA(val, msifile);
8211 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8212 (const BYTE *)val, lstrlenA(val) + 1);
8213 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8215 hprod = 0xdeadbeef;
8216 r = MsiOpenProductA(prodcode, &hprod);
8217 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8218 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
8220 /* hProduct is invalid */
8221 size = MAX_PATH;
8222 lstrcpyA(val, "apple");
8223 r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
8224 ok(r == ERROR_INVALID_HANDLE,
8225 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8226 ok(!lstrcmpA(val, "apple"),
8227 "Expected val to be unchanged, got \"%s\"\n", val);
8228 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8230 /* szProperty is NULL */
8231 size = MAX_PATH;
8232 lstrcpyA(val, "apple");
8233 r = MsiGetProductPropertyA(hprod, NULL, val, &size);
8234 ok(r == ERROR_INVALID_PARAMETER,
8235 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8236 ok(!lstrcmpA(val, "apple"),
8237 "Expected val to be unchanged, got \"%s\"\n", val);
8238 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8240 /* szProperty is empty */
8241 size = MAX_PATH;
8242 lstrcpyA(val, "apple");
8243 r = MsiGetProductPropertyA(hprod, "", val, &size);
8244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8245 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8246 ok(size == 0, "Expected 0, got %d\n", size);
8248 /* get the property */
8249 size = MAX_PATH;
8250 lstrcpyA(val, "apple");
8251 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8252 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8253 ok(!lstrcmpA(val, prodcode),
8254 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8255 ok(size == lstrlenA(prodcode),
8256 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8258 /* lpValueBuf is NULL */
8259 size = MAX_PATH;
8260 r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
8261 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8262 ok(size == lstrlenA(prodcode),
8263 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8265 /* pcchValueBuf is NULL */
8266 lstrcpyA(val, "apple");
8267 r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
8268 ok(r == ERROR_INVALID_PARAMETER,
8269 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8270 ok(!lstrcmpA(val, "apple"),
8271 "Expected val to be unchanged, got \"%s\"\n", val);
8272 ok(size == lstrlenA(prodcode),
8273 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8275 /* pcchValueBuf is too small */
8276 size = 4;
8277 lstrcpyA(val, "apple");
8278 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8279 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8280 ok(!strncmp(val, prodcode, 3),
8281 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
8282 ok(size == lstrlenA(prodcode),
8283 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8285 /* pcchValueBuf does not leave room for NULL terminator */
8286 size = lstrlenA(prodcode);
8287 lstrcpyA(val, "apple");
8288 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8289 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8290 ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
8291 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
8292 ok(size == lstrlenA(prodcode),
8293 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8295 /* pcchValueBuf has enough room for NULL terminator */
8296 size = lstrlenA(prodcode) + 1;
8297 lstrcpyA(val, "apple");
8298 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8300 ok(!lstrcmpA(val, prodcode),
8301 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8302 ok(size == lstrlenA(prodcode),
8303 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8305 /* nonexistent property */
8306 size = MAX_PATH;
8307 lstrcpyA(val, "apple");
8308 r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
8309 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8310 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8311 ok(size == 0, "Expected 0, got %d\n", size);
8313 r = MsiSetPropertyA(hprod, "NewProperty", "value");
8314 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8316 /* non-product property set */
8317 size = MAX_PATH;
8318 lstrcpyA(val, "apple");
8319 r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
8320 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8321 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8322 ok(size == 0, "Expected 0, got %d\n", size);
8324 r = MsiSetPropertyA(hprod, "ProductCode", "value");
8325 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8327 /* non-product property that is also a product property set */
8328 size = MAX_PATH;
8329 lstrcpyA(val, "apple");
8330 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8332 ok(!lstrcmpA(val, prodcode),
8333 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8334 ok(size == lstrlenA(prodcode),
8335 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8337 MsiCloseHandle(hprod);
8339 RegDeleteValueA(props, "LocalPackage");
8340 delete_key(props, "", access);
8341 RegCloseKey(props);
8342 delete_key(userkey, "", access);
8343 RegCloseKey(userkey);
8344 delete_key(prodkey, "", access);
8345 RegCloseKey(prodkey);
8346 DeleteFileA(msifile);
8349 static void test_MsiSetProperty(void)
8351 MSIHANDLE hpkg, hdb, hrec;
8352 CHAR buf[MAX_PATH];
8353 LPCSTR query;
8354 DWORD size;
8355 UINT r;
8357 r = package_from_db(create_package_db(), &hpkg);
8358 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8360 skip("Not enough rights to perform tests\n");
8361 DeleteFile(msifile);
8362 return;
8364 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
8366 /* invalid hInstall */
8367 r = MsiSetPropertyA(0, "Prop", "Val");
8368 ok(r == ERROR_INVALID_HANDLE,
8369 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8371 /* invalid hInstall */
8372 r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8373 ok(r == ERROR_INVALID_HANDLE,
8374 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8376 /* szName is NULL */
8377 r = MsiSetPropertyA(hpkg, NULL, "Val");
8378 ok(r == ERROR_INVALID_PARAMETER,
8379 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8381 /* both szName and szValue are NULL */
8382 r = MsiSetPropertyA(hpkg, NULL, NULL);
8383 ok(r == ERROR_INVALID_PARAMETER,
8384 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8386 /* szName is empty */
8387 r = MsiSetPropertyA(hpkg, "", "Val");
8388 ok(r == ERROR_FUNCTION_FAILED,
8389 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8391 /* szName is empty and szValue is NULL */
8392 r = MsiSetPropertyA(hpkg, "", NULL);
8393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8395 /* set a property */
8396 r = MsiSetPropertyA(hpkg, "Prop", "Val");
8397 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8399 /* get the property */
8400 size = MAX_PATH;
8401 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8402 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8403 ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
8404 ok(size == 3, "Expected 3, got %d\n", size);
8406 /* update the property */
8407 r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
8408 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8410 /* get the property */
8411 size = MAX_PATH;
8412 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8413 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8414 ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
8415 ok(size == 4, "Expected 4, got %d\n", size);
8417 hdb = MsiGetActiveDatabase(hpkg);
8418 ok(hdb != 0, "Expected a valid database handle\n");
8420 /* set prop is not in the _Property table */
8421 query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8422 r = do_query(hdb, query, &hrec);
8423 ok(r == ERROR_BAD_QUERY_SYNTAX,
8424 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8426 /* set prop is not in the Property table */
8427 query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8428 r = do_query(hdb, query, &hrec);
8429 ok(r == ERROR_BAD_QUERY_SYNTAX,
8430 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8432 MsiCloseHandle(hdb);
8434 /* szValue is an empty string */
8435 r = MsiSetPropertyA(hpkg, "Prop", "");
8436 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8438 /* try to get the property */
8439 size = MAX_PATH;
8440 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8442 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8443 ok(size == 0, "Expected 0, got %d\n", size);
8445 /* reset the property */
8446 r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
8447 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8449 /* delete the property */
8450 r = MsiSetPropertyA(hpkg, "Prop", NULL);
8451 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8453 /* try to get the property */
8454 size = MAX_PATH;
8455 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8456 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8457 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8458 ok(size == 0, "Expected 0, got %d\n", size);
8460 MsiCloseHandle(hpkg);
8461 DeleteFileA(msifile);
8464 static void test_MsiApplyMultiplePatches(void)
8466 UINT r, type = GetDriveType(NULL);
8468 if (!pMsiApplyMultiplePatchesA) {
8469 win_skip("MsiApplyMultiplePatchesA not found\n");
8470 return;
8473 r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
8474 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8476 r = pMsiApplyMultiplePatchesA("", NULL, NULL);
8477 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8479 r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
8480 if (type == DRIVE_FIXED)
8481 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8482 else
8483 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8485 r = pMsiApplyMultiplePatchesA(" ;", NULL, NULL);
8486 if (type == DRIVE_FIXED)
8487 todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
8488 else
8489 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8491 r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
8492 if (type == DRIVE_FIXED)
8493 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8494 else
8495 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8497 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
8498 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8500 r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
8501 if (type == DRIVE_FIXED)
8502 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8503 else
8504 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8506 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
8507 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8509 r = pMsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL, NULL);
8510 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8513 static void test_MsiApplyPatch(void)
8515 UINT r;
8517 r = MsiApplyPatch(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
8518 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8520 r = MsiApplyPatch("", NULL, INSTALLTYPE_DEFAULT, NULL);
8521 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8524 static void test_MsiEnumComponentCosts(void)
8526 MSIHANDLE hdb, hpkg;
8527 char package[12], drive[3];
8528 DWORD len;
8529 UINT r;
8530 int cost, temp;
8532 hdb = create_package_db();
8533 ok( hdb, "failed to create database\n" );
8535 r = create_property_table( hdb );
8536 ok( r == ERROR_SUCCESS, "cannot create Property table %u\n", r );
8538 r = add_property_entry( hdb, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8539 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8541 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
8542 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8544 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
8545 ok( r == ERROR_SUCCESS, "failed to add directory entry %u\n" , r );
8547 r = create_media_table( hdb );
8548 ok( r == ERROR_SUCCESS, "cannot create Media table %u\n", r );
8550 r = add_media_entry( hdb, "'1', '2', 'cabinet', '', '', ''");
8551 ok( r == ERROR_SUCCESS, "cannot add media entry %u\n", r );
8553 r = create_file_table( hdb );
8554 ok( r == ERROR_SUCCESS, "cannot create File table %u\n", r );
8556 r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8557 ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
8559 r = create_component_table( hdb );
8560 ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
8562 r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8563 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8565 r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8566 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8568 r = create_feature_table( hdb );
8569 ok( r == ERROR_SUCCESS, "cannot create Feature table %u\n", r );
8571 r = add_feature_entry( hdb, "'one', '', '', '', 0, 1, '', 0" );
8572 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8574 r = add_feature_entry( hdb, "'two', '', '', '', 0, 1, '', 0" );
8575 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8577 r = create_feature_components_table( hdb );
8578 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table %u\n", r );
8580 r = add_feature_components_entry( hdb, "'one', 'one'" );
8581 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8583 r = add_feature_components_entry( hdb, "'two', 'two'" );
8584 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8586 r = create_install_execute_sequence_table( hdb );
8587 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table %u\n", r );
8589 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
8590 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8592 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
8593 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8595 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
8596 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8598 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1100'" );
8599 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8601 MsiDatabaseCommit( hdb );
8603 sprintf( package, "#%u", hdb );
8604 r = MsiOpenPackageA( package, &hpkg );
8605 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8607 skip("Not enough rights to perform tests\n");
8608 goto error;
8610 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8612 r = MsiEnumComponentCostsA( 0, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8613 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8615 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8616 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8618 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8619 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8621 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8622 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8624 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8625 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8627 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, NULL, NULL, NULL );
8628 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8630 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, NULL, NULL, NULL );
8631 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8633 len = sizeof(drive);
8634 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, NULL, NULL );
8635 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8637 len = sizeof(drive);
8638 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, NULL );
8639 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8641 len = sizeof(drive);
8642 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8643 todo_wine ok( r == ERROR_INVALID_HANDLE_STATE, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r );
8645 len = sizeof(drive);
8646 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, &len, &cost, &temp );
8647 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8649 MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );
8651 r = MsiDoAction( hpkg, "CostInitialize" );
8652 ok( r == ERROR_SUCCESS, "CostInitialize failed %u\n", r );
8654 r = MsiDoAction( hpkg, "FileCost" );
8655 ok( r == ERROR_SUCCESS, "FileCost failed %u\n", r );
8657 len = sizeof(drive);
8658 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8659 ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8661 r = MsiDoAction( hpkg, "CostFinalize" );
8662 ok( r == ERROR_SUCCESS, "CostFinalize failed %u\n", r );
8664 /* contrary to what msdn says InstallValidate must be called too */
8665 len = sizeof(drive);
8666 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8667 todo_wine ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8669 r = MsiDoAction( hpkg, "InstallValidate" );
8670 ok( r == ERROR_SUCCESS, "InstallValidate failed %u\n", r );
8672 len = 0;
8673 r = MsiEnumComponentCostsA( hpkg, "three", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8674 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
8676 len = 0;
8677 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8678 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8679 ok( len == 2, "expected len == 2, got %u\n", len );
8681 len = 2;
8682 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8683 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8684 ok( len == 2, "expected len == 2, got %u\n", len );
8686 len = 2;
8687 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8688 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8689 ok( len == 2, "expected len == 2, got %u\n", len );
8691 /* install state doesn't seem to matter */
8692 len = sizeof(drive);
8693 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8694 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8696 len = sizeof(drive);
8697 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_ABSENT, drive, &len, &cost, &temp );
8698 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8700 len = sizeof(drive);
8701 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_SOURCE, drive, &len, &cost, &temp );
8702 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8704 len = sizeof(drive);
8705 drive[0] = 0;
8706 cost = temp = 0xdead;
8707 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8708 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8709 ok( len == 2, "expected len == 2, got %u\n", len );
8710 ok( drive[0], "expected a drive\n" );
8711 ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
8712 ok( !temp, "expected temp == 0, got %d\n", temp );
8714 len = sizeof(drive);
8715 drive[0] = 0;
8716 cost = temp = 0xdead;
8717 r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8718 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8719 ok( len == 2, "expected len == 2, got %u\n", len );
8720 ok( drive[0], "expected a drive\n" );
8721 ok( !cost, "expected cost == 0, got %d\n", cost );
8722 ok( !temp, "expected temp == 0, got %d\n", temp );
8724 len = sizeof(drive);
8725 drive[0] = 0;
8726 cost = temp = 0xdead;
8727 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8728 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8729 ok( len == 2, "expected len == 2, got %u\n", len );
8730 ok( drive[0], "expected a drive\n" );
8731 ok( !cost, "expected cost == 0, got %d\n", cost );
8732 ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
8734 /* increased index */
8735 len = sizeof(drive);
8736 r = MsiEnumComponentCostsA( hpkg, "one", 1, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8737 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8739 len = sizeof(drive);
8740 r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8741 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
8743 MsiCloseHandle( hpkg );
8744 error:
8745 MsiCloseHandle( hdb );
8746 DeleteFileA( msifile );
8749 static void test_MsiDatabaseCommit(void)
8751 UINT r;
8752 MSIHANDLE hdb, hpkg = 0;
8753 char buf[32], package[12];
8754 DWORD sz;
8756 hdb = create_package_db();
8757 ok( hdb, "failed to create database\n" );
8759 r = create_property_table( hdb );
8760 ok( r == ERROR_SUCCESS, "can't create Property table %u\n", r );
8762 sprintf( package, "#%u", hdb );
8763 r = MsiOpenPackage( package, &hpkg );
8764 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8766 skip("Not enough rights to perform tests\n");
8767 goto error;
8769 ok( r == ERROR_SUCCESS, "got %u\n", r );
8771 r = MsiSetPropertyA( hpkg, "PROP", "value" );
8772 ok( r == ERROR_SUCCESS, "got %u\n", r );
8774 buf[0] = 0;
8775 sz = sizeof(buf);
8776 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8777 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8778 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8780 r = MsiDatabaseCommit( hdb );
8781 ok( r == ERROR_SUCCESS, "MsiDatabaseCommit returned %u\n", r );
8783 buf[0] = 0;
8784 sz = sizeof(buf);
8785 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
8786 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
8787 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
8789 MsiCloseHandle( hpkg );
8790 error:
8791 MsiCloseHandle( hdb );
8792 DeleteFileA( msifile );
8795 START_TEST(package)
8797 STATEMGRSTATUS status;
8798 BOOL ret = FALSE;
8800 init_functionpointers();
8802 if (pIsWow64Process)
8803 pIsWow64Process(GetCurrentProcess(), &is_wow64);
8805 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
8807 /* Create a restore point ourselves so we circumvent the multitude of restore points
8808 * that would have been created by all the installation and removal tests.
8810 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
8811 * creation of restore points.
8813 if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
8815 memset(&status, 0, sizeof(status));
8816 ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
8819 test_createpackage();
8820 test_doaction();
8821 test_gettargetpath_bad();
8822 test_settargetpath();
8823 test_props();
8824 test_property_table();
8825 test_condition();
8826 test_msipackage();
8827 test_formatrecord2();
8828 test_states();
8829 test_getproperty();
8830 test_removefiles();
8831 test_appsearch();
8832 test_appsearch_complocator();
8833 test_appsearch_reglocator();
8834 test_appsearch_inilocator();
8835 test_appsearch_drlocator();
8836 test_featureparents();
8837 test_installprops();
8838 test_launchconditions();
8839 test_ccpsearch();
8840 test_complocator();
8841 test_MsiGetSourcePath();
8842 test_shortlongsource();
8843 test_sourcedir();
8844 test_access();
8845 test_emptypackage();
8846 test_MsiGetProductProperty();
8847 test_MsiSetProperty();
8848 test_MsiApplyMultiplePatches();
8849 test_MsiApplyPatch();
8850 test_MsiEnumComponentCosts();
8851 test_MsiDatabaseCommit();
8853 if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
8855 ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
8856 if (ret)
8857 remove_restore_point(status.llSequenceNumber);