2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002,2003,2004,2005 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
31 #include "wine/debug.h"
42 #include "wine/unicode.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msi);
46 static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0};
48 static UINT msi_locate_product(LPCWSTR szProduct, MSIINSTALLCONTEXT *context)
52 *context = MSIINSTALLCONTEXT_NONE;
54 if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
55 &hkey, FALSE) == ERROR_SUCCESS)
56 *context = MSIINSTALLCONTEXT_USERMANAGED;
57 else if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
58 &hkey, FALSE) == ERROR_SUCCESS)
59 *context = MSIINSTALLCONTEXT_MACHINE;
60 else if (MSIREG_OpenProductKey(szProduct, NULL,
61 MSIINSTALLCONTEXT_USERUNMANAGED,
62 &hkey, FALSE) == ERROR_SUCCESS)
63 *context = MSIINSTALLCONTEXT_USERUNMANAGED;
67 if (*context == MSIINSTALLCONTEXT_NONE)
68 return ERROR_UNKNOWN_PRODUCT;
73 UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
76 LPWSTR szwProd = NULL;
78 TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
82 szwProd = strdupAtoW( szProduct );
84 return ERROR_OUTOFMEMORY;
87 r = MsiOpenProductW( szwProd, phProduct );
94 static UINT MSI_OpenProductW(LPCWSTR szProduct, MSIPACKAGE **package)
99 MSIINSTALLCONTEXT context;
101 static const WCHAR managed[] = {
102 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
103 static const WCHAR local[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
105 TRACE("%s %p\n", debugstr_w(szProduct), package);
107 r = msi_locate_product(szProduct, &context);
108 if (r != ERROR_SUCCESS)
111 r = MSIREG_OpenInstallProps(szProduct, context, NULL, &props, FALSE);
112 if (r != ERROR_SUCCESS)
113 return ERROR_UNKNOWN_PRODUCT;
115 if (context == MSIINSTALLCONTEXT_USERMANAGED)
116 path = msi_reg_get_val_str(props, managed);
118 path = msi_reg_get_val_str(props, local);
120 r = ERROR_UNKNOWN_PRODUCT;
122 if (!path || GetFileAttributesW(path) == INVALID_FILE_ATTRIBUTES)
125 if (PathIsRelativeW(path))
127 r = ERROR_INSTALL_PACKAGE_OPEN_FAILED;
131 r = MSI_OpenPackageW(path, package);
139 UINT WINAPI MsiOpenProductW(LPCWSTR szProduct, MSIHANDLE *phProduct)
141 MSIPACKAGE *package = NULL;
142 WCHAR squished_pc[GUID_SIZE];
145 if (!szProduct || !squash_guid(szProduct, squished_pc))
146 return ERROR_INVALID_PARAMETER;
149 return ERROR_INVALID_PARAMETER;
151 r = MSI_OpenProductW(szProduct, &package);
152 if (r != ERROR_SUCCESS)
155 *phProduct = alloc_msihandle(&package->hdr);
157 r = ERROR_NOT_ENOUGH_MEMORY;
159 msiobj_release(&package->hdr);
163 UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
164 LPCSTR szTransforms, LANGID lgidLanguage)
166 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath),
167 debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
168 return ERROR_CALL_NOT_IMPLEMENTED;
171 UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
172 LPCWSTR szTransforms, LANGID lgidLanguage)
174 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath),
175 debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
176 return ERROR_CALL_NOT_IMPLEMENTED;
179 UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
180 LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
182 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath),
183 debugstr_a(szScriptfilePath), debugstr_a(szTransforms),
184 lgidLanguage, dwPlatform, dwOptions);
185 return ERROR_CALL_NOT_IMPLEMENTED;
188 UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
189 LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
191 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath),
192 debugstr_w(szScriptfilePath), debugstr_w(szTransforms),
193 lgidLanguage, dwPlatform, dwOptions);
194 return ERROR_CALL_NOT_IMPLEMENTED;
197 UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
199 LPWSTR szwPath = NULL, szwCommand = NULL;
200 UINT r = ERROR_OUTOFMEMORY;
202 TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
206 szwPath = strdupAtoW( szPackagePath );
213 szwCommand = strdupAtoW( szCommandLine );
218 r = MsiInstallProductW( szwPath, szwCommand );
222 msi_free( szwCommand );
227 UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
229 MSIPACKAGE *package = NULL;
232 TRACE("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
235 return ERROR_INVALID_PARAMETER;
238 return ERROR_PATH_NOT_FOUND;
240 r = MSI_OpenPackageW( szPackagePath, &package );
241 if (r == ERROR_SUCCESS)
243 r = MSI_InstallPackage( package, szPackagePath, szCommandLine );
244 msiobj_release( &package->hdr );
250 UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
255 TRACE("%s %08x\n", debugstr_a(szProduct), dwReinstallMode);
257 wszProduct = strdupAtoW(szProduct);
259 rc = MsiReinstallProductW(wszProduct, dwReinstallMode);
261 msi_free(wszProduct);
265 UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
267 TRACE("%s %08x\n", debugstr_w(szProduct), dwReinstallMode);
269 return MsiReinstallFeatureW(szProduct, szAll, dwReinstallMode);
272 UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage,
273 INSTALLTYPE eInstallType, LPCSTR szCommandLine)
275 LPWSTR patch_package = NULL;
276 LPWSTR install_package = NULL;
277 LPWSTR command_line = NULL;
278 UINT r = ERROR_OUTOFMEMORY;
280 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage),
281 eInstallType, debugstr_a(szCommandLine));
283 if (szPatchPackage && !(patch_package = strdupAtoW(szPatchPackage)))
286 if (szInstallPackage && !(install_package = strdupAtoW(szInstallPackage)))
289 if (szCommandLine && !(command_line = strdupAtoW(szCommandLine)))
292 r = MsiApplyPatchW(patch_package, install_package, eInstallType, command_line);
295 msi_free(patch_package);
296 msi_free(install_package);
297 msi_free(command_line);
302 static UINT MSI_ApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szProductCode, LPCWSTR szCommandLine)
304 MSIHANDLE patch = 0, info = 0;
305 UINT r = ERROR_SUCCESS, type;
307 LPCWSTR cmd_ptr = szCommandLine;
308 LPWSTR beg, end, cmd = NULL, codes = NULL;
309 BOOL succeeded = FALSE;
311 static const WCHAR patcheq[] = {'P','A','T','C','H','=',0};
312 static WCHAR empty[] = {0};
314 if (!szPatchPackage || !szPatchPackage[0])
315 return ERROR_INVALID_PARAMETER;
319 r = MsiOpenDatabaseW(szPatchPackage, MSIDBOPEN_READONLY, &patch);
320 if (r != ERROR_SUCCESS)
323 r = MsiGetSummaryInformationW(patch, NULL, 0, &info);
324 if (r != ERROR_SUCCESS)
327 r = MsiSummaryInfoGetPropertyW(info, PID_TEMPLATE, &type, NULL, NULL, empty, &size);
328 if (r != ERROR_MORE_DATA || !size || type != VT_LPSTR)
330 ERR("Failed to read product codes from patch\n");
334 codes = msi_alloc(++size * sizeof(WCHAR));
337 r = ERROR_OUTOFMEMORY;
341 r = MsiSummaryInfoGetPropertyW(info, PID_TEMPLATE, &type, NULL, NULL, codes, &size);
342 if (r != ERROR_SUCCESS)
349 size = lstrlenW(cmd_ptr) + lstrlenW(patcheq) + lstrlenW(szPatchPackage) + 1;
350 cmd = msi_alloc(size * sizeof(WCHAR));
353 r = ERROR_OUTOFMEMORY;
357 lstrcpyW(cmd, cmd_ptr);
358 if (szCommandLine) lstrcatW(cmd, szSpace);
359 lstrcatW(cmd, patcheq);
360 lstrcatW(cmd, szPatchPackage);
363 r = MsiConfigureProductExW(szProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
367 while ((end = strchrW(beg, '}')))
370 r = MsiConfigureProductExW(beg, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
371 if (r == ERROR_SUCCESS)
373 TRACE("patch applied\n");
387 MsiCloseHandle(info);
388 MsiCloseHandle(patch);
393 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
394 INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
396 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
397 eInstallType, debugstr_w(szCommandLine));
399 if (szInstallPackage || eInstallType == INSTALLTYPE_NETWORK_IMAGE ||
400 eInstallType == INSTALLTYPE_SINGLE_INSTANCE)
402 FIXME("Only reading target products from patch\n");
403 return ERROR_CALL_NOT_IMPLEMENTED;
406 return MSI_ApplyPatchW(szPatchPackage, NULL, szCommandLine);
409 UINT WINAPI MsiApplyMultiplePatchesA(LPCSTR szPatchPackages,
410 LPCSTR szProductCode, LPCSTR szPropertiesList)
412 LPWSTR patch_packages = NULL;
413 LPWSTR product_code = NULL;
414 LPWSTR properties_list = NULL;
415 UINT r = ERROR_OUTOFMEMORY;
417 TRACE("%s %s %s\n", debugstr_a(szPatchPackages), debugstr_a(szProductCode),
418 debugstr_a(szPropertiesList));
420 if (!szPatchPackages || !szPatchPackages[0])
421 return ERROR_INVALID_PARAMETER;
423 if (!(patch_packages = strdupAtoW(szPatchPackages)))
424 return ERROR_OUTOFMEMORY;
426 if (szProductCode && !(product_code = strdupAtoW(szProductCode)))
429 if (szPropertiesList && !(properties_list = strdupAtoW(szPropertiesList)))
432 r = MsiApplyMultiplePatchesW(patch_packages, product_code, properties_list);
435 msi_free(patch_packages);
436 msi_free(product_code);
437 msi_free(properties_list);
442 UINT WINAPI MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages,
443 LPCWSTR szProductCode, LPCWSTR szPropertiesList)
445 UINT r = ERROR_SUCCESS;
448 TRACE("%s %s %s\n", debugstr_w(szPatchPackages), debugstr_w(szProductCode),
449 debugstr_w(szPropertiesList));
451 if (!szPatchPackages || !szPatchPackages[0])
452 return ERROR_INVALID_PARAMETER;
454 beg = end = szPatchPackages;
460 while (*beg == ' ') beg++;
461 while (*end && *end != ';') end++;
464 while (len && beg[len - 1] == ' ') len--;
466 if (!len) return ERROR_INVALID_NAME;
468 patch = msi_alloc((len + 1) * sizeof(WCHAR));
470 return ERROR_OUTOFMEMORY;
472 memcpy(patch, beg, len * sizeof(WCHAR));
475 r = MSI_ApplyPatchW(patch, szProductCode, szPropertiesList);
478 if (r != ERROR_SUCCESS)
486 UINT WINAPI MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath,
487 DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOA pPatchInfo)
490 WCHAR *package_path = NULL;
491 MSIPATCHSEQUENCEINFOW *psi;
493 TRACE("(%s, %d, %p)\n", debugstr_a(szProductPackagePath), cPatchInfo, pPatchInfo);
495 if (szProductPackagePath && !(package_path = strdupAtoW( szProductPackagePath )))
496 return ERROR_OUTOFMEMORY;
498 psi = msi_alloc( cPatchInfo * sizeof(*psi) );
501 msi_free( package_path );
502 return ERROR_OUTOFMEMORY;
505 for (i = 0; i < cPatchInfo; i++)
507 psi[i].szPatchData = strdupAtoW( pPatchInfo[i].szPatchData );
508 psi[i].ePatchDataType = pPatchInfo[i].ePatchDataType;
511 r = MsiDetermineApplicablePatchesW( package_path, cPatchInfo, psi );
512 if (r == ERROR_SUCCESS)
514 for (i = 0; i < cPatchInfo; i++)
516 pPatchInfo[i].dwOrder = psi[i].dwOrder;
517 pPatchInfo[i].uStatus = psi[i].uStatus;
521 msi_free( package_path );
522 for (i = 0; i < cPatchInfo; i++)
523 msi_free( (WCHAR *)psi[i].szPatchData );
528 static UINT MSI_ApplicablePatchW( MSIPACKAGE *package, LPCWSTR patch )
531 MSIDATABASE *patch_db;
532 UINT r = ERROR_SUCCESS;
534 r = MSI_OpenDatabaseW( patch, MSIDBOPEN_READONLY, &patch_db );
535 if (r != ERROR_SUCCESS)
537 WARN("failed to open patch file %s\n", debugstr_w(patch));
541 si = MSI_GetSummaryInformationW( patch_db->storage, 0 );
544 msiobj_release( &patch_db->hdr );
545 return ERROR_FUNCTION_FAILED;
548 r = msi_check_patch_applicable( package, si );
549 if (r != ERROR_SUCCESS)
550 TRACE("patch not applicable\n");
552 msiobj_release( &patch_db->hdr );
553 msiobj_release( &si->hdr );
557 UINT WINAPI MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath,
558 DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOW pPatchInfo)
560 UINT i, r, ret = ERROR_FUNCTION_FAILED;
563 TRACE("(%s, %d, %p)\n", debugstr_w(szProductPackagePath), cPatchInfo, pPatchInfo);
565 r = MSI_OpenPackageW( szProductPackagePath, &package );
566 if (r != ERROR_SUCCESS)
568 ERR("failed to open package %u\n", r);
572 for (i = 0; i < cPatchInfo; i++)
574 switch (pPatchInfo[i].ePatchDataType)
576 case MSIPATCH_DATATYPE_PATCHFILE:
578 FIXME("patch ordering not supported\n");
579 r = MSI_ApplicablePatchW( package, pPatchInfo[i].szPatchData );
580 if (r != ERROR_SUCCESS)
582 pPatchInfo[i].dwOrder = ~0u;
583 pPatchInfo[i].uStatus = ERROR_PATCH_TARGET_NOT_FOUND;
587 pPatchInfo[i].dwOrder = i;
588 pPatchInfo[i].uStatus = ret = ERROR_SUCCESS;
594 FIXME("patch data type %u not supported\n", pPatchInfo[i].ePatchDataType);
595 pPatchInfo[i].dwOrder = ~0u;
596 pPatchInfo[i].uStatus = ERROR_PATCH_TARGET_NOT_FOUND;
601 TRACE(" szPatchData: %s\n", debugstr_w(pPatchInfo[i].szPatchData));
602 TRACE("ePatchDataType: %u\n", pPatchInfo[i].ePatchDataType);
603 TRACE(" dwOrder: %u\n", pPatchInfo[i].dwOrder);
604 TRACE(" uStatus: %u\n", pPatchInfo[i].uStatus);
609 UINT WINAPI MsiDeterminePatchSequenceA(LPCSTR szProductCode, LPCSTR szUserSid,
610 MSIINSTALLCONTEXT dwContext, DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOA pPatchInfo)
612 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_a(szProductCode),
613 debugstr_a(szUserSid), dwContext, cPatchInfo, pPatchInfo);
615 return ERROR_CALL_NOT_IMPLEMENTED;
618 UINT WINAPI MsiDeterminePatchSequenceW(LPCWSTR szProductCode, LPCWSTR szUserSid,
619 MSIINSTALLCONTEXT dwContext, DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOW pPatchInfo)
621 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_w(szProductCode),
622 debugstr_w(szUserSid), dwContext, cPatchInfo, pPatchInfo);
624 return ERROR_CALL_NOT_IMPLEMENTED;
627 static UINT msi_open_package(LPCWSTR product, MSIINSTALLCONTEXT context,
628 MSIPACKAGE **package)
634 WCHAR sourcepath[MAX_PATH];
635 WCHAR filename[MAX_PATH];
637 r = MSIREG_OpenInstallProps(product, context, NULL, &props, FALSE);
638 if (r != ERROR_SUCCESS)
639 return ERROR_BAD_CONFIGURATION;
641 localpack = msi_reg_get_val_str(props, szLocalPackage);
644 lstrcpyW(sourcepath, localpack);
648 if (!localpack || GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES)
650 sz = sizeof(sourcepath);
651 MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT,
652 INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
654 sz = sizeof(filename);
655 MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT,
656 INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
658 lstrcatW(sourcepath, filename);
661 if (GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES)
662 return ERROR_INSTALL_SOURCE_ABSENT;
664 return MSI_OpenPackageW(sourcepath, package);
667 UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
668 INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
670 MSIPACKAGE* package = NULL;
671 MSIINSTALLCONTEXT context;
674 WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
677 static const WCHAR szInstalled[] = {
678 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
679 static const WCHAR szRemoveAll[] = {
680 ' ','R','E','M','O','V','E','=','A','L','L',0};
681 static const WCHAR szMachine[] = {
682 ' ','A','L','L','U','S','E','R','S','=','1',0};
684 TRACE("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
685 debugstr_w(szCommandLine));
687 if (!szProduct || lstrlenW(szProduct) != GUID_SIZE - 1)
688 return ERROR_INVALID_PARAMETER;
690 if (eInstallState == INSTALLSTATE_ADVERTISED ||
691 eInstallState == INSTALLSTATE_SOURCE)
693 FIXME("State %d not implemented\n", eInstallState);
694 return ERROR_CALL_NOT_IMPLEMENTED;
697 r = msi_locate_product(szProduct, &context);
698 if (r != ERROR_SUCCESS)
701 r = msi_open_package(szProduct, context, &package);
702 if (r != ERROR_SUCCESS)
705 sz = lstrlenW(szInstalled) + 1;
708 sz += lstrlenW(szCommandLine);
710 if (eInstallState == INSTALLSTATE_ABSENT)
711 sz += lstrlenW(szRemoveAll);
713 if (context == MSIINSTALLCONTEXT_MACHINE)
714 sz += lstrlenW(szMachine);
716 commandline = msi_alloc(sz * sizeof(WCHAR));
719 r = ERROR_OUTOFMEMORY;
725 lstrcpyW(commandline,szCommandLine);
727 if (eInstallState == INSTALLSTATE_ABSENT)
728 lstrcatW(commandline, szRemoveAll);
730 if (context == MSIINSTALLCONTEXT_MACHINE)
731 lstrcatW(commandline, szMachine);
733 sz = sizeof(sourcepath);
734 MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT,
735 INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
737 sz = sizeof(filename);
738 MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT,
739 INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
741 strcatW(sourcepath, filename);
743 r = MSI_InstallPackage( package, sourcepath, commandline );
745 msi_free(commandline);
748 msiobj_release( &package->hdr );
753 UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
754 INSTALLSTATE eInstallState, LPCSTR szCommandLine)
756 LPWSTR szwProduct = NULL;
757 LPWSTR szwCommandLine = NULL;
758 UINT r = ERROR_OUTOFMEMORY;
762 szwProduct = strdupAtoW( szProduct );
769 szwCommandLine = strdupAtoW( szCommandLine );
774 r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
777 msi_free( szwProduct );
778 msi_free( szwCommandLine);
783 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
784 INSTALLSTATE eInstallState)
786 LPWSTR szwProduct = NULL;
789 TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
793 szwProduct = strdupAtoW( szProduct );
795 return ERROR_OUTOFMEMORY;
798 r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
799 msi_free( szwProduct );
804 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
805 INSTALLSTATE eInstallState)
807 return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
810 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
812 LPWSTR szwComponent = NULL;
814 WCHAR szwBuffer[GUID_SIZE];
816 TRACE("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
820 szwComponent = strdupAtoW( szComponent );
822 return ERROR_OUTOFMEMORY;
826 r = MsiGetProductCodeW( szwComponent, szwBuffer );
829 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
831 msi_free( szwComponent );
836 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
839 HKEY compkey, prodkey;
840 WCHAR squished_comp[GUID_SIZE];
841 WCHAR squished_prod[GUID_SIZE];
842 DWORD sz = GUID_SIZE;
844 TRACE("%s %p\n", debugstr_w(szComponent), szBuffer);
846 if (!szComponent || !*szComponent)
847 return ERROR_INVALID_PARAMETER;
849 if (!squash_guid(szComponent, squished_comp))
850 return ERROR_INVALID_PARAMETER;
852 if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &compkey, FALSE) != ERROR_SUCCESS &&
853 MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &compkey, FALSE) != ERROR_SUCCESS)
855 return ERROR_UNKNOWN_COMPONENT;
858 rc = RegEnumValueW(compkey, 0, squished_prod, &sz, NULL, NULL, NULL, NULL);
859 if (rc != ERROR_SUCCESS)
861 RegCloseKey(compkey);
862 return ERROR_UNKNOWN_COMPONENT;
865 /* check simple case, only one product */
866 rc = RegEnumValueW(compkey, 1, squished_prod, &sz, NULL, NULL, NULL, NULL);
867 if (rc == ERROR_NO_MORE_ITEMS)
874 while ((rc = RegEnumValueW(compkey, index, squished_prod, &sz,
875 NULL, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS)
879 unsquash_guid(squished_prod, szBuffer);
881 if (MSIREG_OpenProductKey(szBuffer, NULL,
882 MSIINSTALLCONTEXT_USERMANAGED,
883 &prodkey, FALSE) == ERROR_SUCCESS ||
884 MSIREG_OpenProductKey(szBuffer, NULL,
885 MSIINSTALLCONTEXT_USERUNMANAGED,
886 &prodkey, FALSE) == ERROR_SUCCESS ||
887 MSIREG_OpenProductKey(szBuffer, NULL,
888 MSIINSTALLCONTEXT_MACHINE,
889 &prodkey, FALSE) == ERROR_SUCCESS)
891 RegCloseKey(prodkey);
897 rc = ERROR_INSTALL_FAILURE;
900 RegCloseKey(compkey);
901 unsquash_guid(squished_prod, szBuffer);
905 static LPWSTR msi_reg_get_value(HKEY hkey, LPCWSTR name, DWORD *type)
911 static const WCHAR format[] = {'%','d',0};
913 res = RegQueryValueExW(hkey, name, NULL, type, NULL, NULL);
914 if (res != ERROR_SUCCESS)
918 return msi_reg_get_val_str(hkey, name);
920 if (!msi_reg_get_val_dword(hkey, name, &dval))
923 sprintfW(temp, format, dval);
924 return strdupW(temp);
927 static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
928 awstring *szValue, LPDWORD pcchValueBuf)
930 MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
931 UINT r = ERROR_UNKNOWN_PROPERTY;
932 HKEY prodkey, userdata, source;
934 WCHAR squished_pc[GUID_SIZE];
935 WCHAR packagecode[GUID_SIZE];
936 BOOL badconfig = FALSE;
938 DWORD type = REG_NONE;
940 static WCHAR empty[] = {0};
941 static const WCHAR sourcelist[] = {
942 'S','o','u','r','c','e','L','i','s','t',0};
943 static const WCHAR display_name[] = {
944 'D','i','s','p','l','a','y','N','a','m','e',0};
945 static const WCHAR display_version[] = {
946 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
947 static const WCHAR assignment[] = {
948 'A','s','s','i','g','n','m','e','n','t',0};
950 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
951 debugstr_w(szAttribute), szValue, pcchValueBuf);
953 if ((szValue->str.w && !pcchValueBuf) || !szProduct || !szAttribute)
954 return ERROR_INVALID_PARAMETER;
956 if (!squash_guid(szProduct, squished_pc))
957 return ERROR_INVALID_PARAMETER;
959 if ((r = MSIREG_OpenProductKey(szProduct, NULL,
960 MSIINSTALLCONTEXT_USERMANAGED,
961 &prodkey, FALSE)) != ERROR_SUCCESS &&
962 (r = MSIREG_OpenProductKey(szProduct, NULL,
963 MSIINSTALLCONTEXT_USERUNMANAGED,
964 &prodkey, FALSE)) != ERROR_SUCCESS &&
965 (r = MSIREG_OpenProductKey(szProduct, NULL,
966 MSIINSTALLCONTEXT_MACHINE,
967 &prodkey, FALSE)) == ERROR_SUCCESS)
969 context = MSIINSTALLCONTEXT_MACHINE;
972 MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE);
974 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_HELPLINKW) ||
975 !lstrcmpW(szAttribute, INSTALLPROPERTY_HELPTELEPHONEW) ||
976 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLDATEW) ||
977 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW) ||
978 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLLOCATIONW) ||
979 !lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLSOURCEW) ||
980 !lstrcmpW(szAttribute, INSTALLPROPERTY_LOCALPACKAGEW) ||
981 !lstrcmpW(szAttribute, INSTALLPROPERTY_PUBLISHERW) ||
982 !lstrcmpW(szAttribute, INSTALLPROPERTY_URLINFOABOUTW) ||
983 !lstrcmpW(szAttribute, INSTALLPROPERTY_URLUPDATEINFOW) ||
984 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONMINORW) ||
985 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONMAJORW) ||
986 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONSTRINGW) ||
987 !lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTIDW) ||
988 !lstrcmpW(szAttribute, INSTALLPROPERTY_REGCOMPANYW) ||
989 !lstrcmpW(szAttribute, INSTALLPROPERTY_REGOWNERW))
993 r = ERROR_UNKNOWN_PRODUCT;
998 return ERROR_UNKNOWN_PROPERTY;
1000 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW))
1001 szAttribute = display_name;
1002 else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONSTRINGW))
1003 szAttribute = display_version;
1005 val = msi_reg_get_value(userdata, szAttribute, &type);
1009 else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_INSTANCETYPEW) ||
1010 !lstrcmpW(szAttribute, INSTALLPROPERTY_TRANSFORMSW) ||
1011 !lstrcmpW(szAttribute, INSTALLPROPERTY_LANGUAGEW) ||
1012 !lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTNAMEW) ||
1013 !lstrcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW) ||
1014 !lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW) ||
1015 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONW) ||
1016 !lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTICONW) ||
1017 !lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGENAMEW) ||
1018 !lstrcmpW(szAttribute, INSTALLPROPERTY_AUTHORIZED_LUA_APPW))
1022 r = ERROR_UNKNOWN_PRODUCT;
1026 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW))
1027 szAttribute = assignment;
1029 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGENAMEW))
1031 res = RegOpenKeyW(prodkey, sourcelist, &source);
1032 if (res != ERROR_SUCCESS)
1034 r = ERROR_UNKNOWN_PRODUCT;
1038 val = msi_reg_get_value(source, szAttribute, &type);
1042 RegCloseKey(source);
1046 val = msi_reg_get_value(prodkey, szAttribute, &type);
1051 if (val != empty && type != REG_DWORD &&
1052 !lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW))
1054 if (lstrlenW(val) != SQUISH_GUID_SIZE - 1)
1058 unsquash_guid(val, packagecode);
1060 val = strdupW(packagecode);
1067 r = ERROR_UNKNOWN_PROPERTY;
1073 /* If szBuffer (szValue->str) is NULL, there's no need to copy the value
1074 * out. Also, *pcchValueBuf may be uninitialized in this case, so we
1075 * can't rely on its value.
1077 if (szValue->str.a || szValue->str.w)
1079 DWORD size = *pcchValueBuf;
1080 if (strlenW(val) < size)
1081 r = msi_strcpy_to_awstring(val, szValue, &size);
1084 r = ERROR_MORE_DATA;
1089 *pcchValueBuf = lstrlenW(val);
1093 r = ERROR_BAD_CONFIGURATION;
1099 RegCloseKey(prodkey);
1100 RegCloseKey(userdata);
1104 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
1105 LPSTR szBuffer, LPDWORD pcchValueBuf)
1107 LPWSTR szwProduct, szwAttribute = NULL;
1108 UINT r = ERROR_OUTOFMEMORY;
1111 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
1112 szBuffer, pcchValueBuf);
1114 szwProduct = strdupAtoW( szProduct );
1115 if( szProduct && !szwProduct )
1118 szwAttribute = strdupAtoW( szAttribute );
1119 if( szAttribute && !szwAttribute )
1122 buffer.unicode = FALSE;
1123 buffer.str.a = szBuffer;
1125 r = MSI_GetProductInfo( szwProduct, szwAttribute,
1126 &buffer, pcchValueBuf );
1129 msi_free( szwProduct );
1130 msi_free( szwAttribute );
1135 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
1136 LPWSTR szBuffer, LPDWORD pcchValueBuf)
1140 TRACE("%s %s %p %p\n", debugstr_w(szProduct), debugstr_w(szAttribute),
1141 szBuffer, pcchValueBuf);
1143 buffer.unicode = TRUE;
1144 buffer.str.w = szBuffer;
1146 return MSI_GetProductInfo( szProduct, szAttribute,
1147 &buffer, pcchValueBuf );
1150 UINT WINAPI MsiGetProductInfoExA(LPCSTR szProductCode, LPCSTR szUserSid,
1151 MSIINSTALLCONTEXT dwContext, LPCSTR szProperty,
1152 LPSTR szValue, LPDWORD pcchValue)
1154 LPWSTR product = NULL;
1155 LPWSTR usersid = NULL;
1156 LPWSTR property = NULL;
1157 LPWSTR value = NULL;
1161 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode),
1162 debugstr_a(szUserSid), dwContext, debugstr_a(szProperty),
1163 szValue, pcchValue);
1165 if (szValue && !pcchValue)
1166 return ERROR_INVALID_PARAMETER;
1168 if (szProductCode) product = strdupAtoW(szProductCode);
1169 if (szUserSid) usersid = strdupAtoW(szUserSid);
1170 if (szProperty) property = strdupAtoW(szProperty);
1172 r = MsiGetProductInfoExW(product, usersid, dwContext, property,
1174 if (r != ERROR_SUCCESS)
1177 value = msi_alloc(++len * sizeof(WCHAR));
1180 r = ERROR_OUTOFMEMORY;
1184 r = MsiGetProductInfoExW(product, usersid, dwContext, property,
1186 if (r != ERROR_SUCCESS)
1192 len = WideCharToMultiByte(CP_ACP, 0, value, -1, NULL, 0, NULL, NULL);
1193 if (*pcchValue >= len)
1194 WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, len, NULL, NULL);
1197 r = ERROR_MORE_DATA;
1202 if (*pcchValue <= len || !szValue)
1203 len = len * sizeof(WCHAR) - 1;
1205 *pcchValue = len - 1;
1216 static UINT msi_copy_outval(LPWSTR val, LPWSTR out, LPDWORD size)
1218 UINT r = ERROR_SUCCESS;
1221 return ERROR_UNKNOWN_PROPERTY;
1225 if (strlenW(val) >= *size)
1227 r = ERROR_MORE_DATA;
1236 *size = lstrlenW(val);
1241 UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
1242 MSIINSTALLCONTEXT dwContext, LPCWSTR szProperty,
1243 LPWSTR szValue, LPDWORD pcchValue)
1245 WCHAR squished_pc[GUID_SIZE];
1247 LPCWSTR package = NULL;
1248 HKEY props = NULL, prod;
1249 HKEY classes = NULL, managed;
1252 UINT r = ERROR_UNKNOWN_PRODUCT;
1254 static const WCHAR five[] = {'5',0};
1255 static const WCHAR displayname[] = {
1256 'D','i','s','p','l','a','y','N','a','m','e',0};
1257 static const WCHAR displayversion[] = {
1258 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1259 static const WCHAR managed_local_package[] = {
1260 'M','a','n','a','g','e','d','L','o','c','a','l',
1261 'P','a','c','k','a','g','e',0};
1263 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode),
1264 debugstr_w(szUserSid), dwContext, debugstr_w(szProperty),
1265 szValue, pcchValue);
1267 if (!szProductCode || !squash_guid(szProductCode, squished_pc))
1268 return ERROR_INVALID_PARAMETER;
1270 if (szValue && !pcchValue)
1271 return ERROR_INVALID_PARAMETER;
1273 if (dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
1274 dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
1275 dwContext != MSIINSTALLCONTEXT_MACHINE)
1276 return ERROR_INVALID_PARAMETER;
1278 if (!szProperty || !*szProperty)
1279 return ERROR_INVALID_PARAMETER;
1281 if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
1282 return ERROR_INVALID_PARAMETER;
1284 /* FIXME: dwContext is provided, no need to search for it */
1285 MSIREG_OpenProductKey(szProductCode, NULL,MSIINSTALLCONTEXT_USERMANAGED,
1287 MSIREG_OpenProductKey(szProductCode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1290 MSIREG_OpenInstallProps(szProductCode, dwContext, NULL, &props, FALSE);
1292 if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
1294 package = INSTALLPROPERTY_LOCALPACKAGEW;
1296 if (!props && !prod)
1299 else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1301 package = managed_local_package;
1303 if (!props && !managed)
1306 else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1308 package = INSTALLPROPERTY_LOCALPACKAGEW;
1309 MSIREG_OpenProductKey(szProductCode, NULL, dwContext, &classes, FALSE);
1311 if (!props && !classes)
1315 if (!lstrcmpW(szProperty, INSTALLPROPERTY_HELPLINKW) ||
1316 !lstrcmpW(szProperty, INSTALLPROPERTY_HELPTELEPHONEW) ||
1317 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLDATEW) ||
1318 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW) ||
1319 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLLOCATIONW) ||
1320 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLSOURCEW) ||
1321 !lstrcmpW(szProperty, INSTALLPROPERTY_LOCALPACKAGEW) ||
1322 !lstrcmpW(szProperty, INSTALLPROPERTY_PUBLISHERW) ||
1323 !lstrcmpW(szProperty, INSTALLPROPERTY_URLINFOABOUTW) ||
1324 !lstrcmpW(szProperty, INSTALLPROPERTY_URLUPDATEINFOW) ||
1325 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONMINORW) ||
1326 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONMAJORW) ||
1327 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONSTRINGW) ||
1328 !lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTIDW) ||
1329 !lstrcmpW(szProperty, INSTALLPROPERTY_REGCOMPANYW) ||
1330 !lstrcmpW(szProperty, INSTALLPROPERTY_REGOWNERW) ||
1331 !lstrcmpW(szProperty, INSTALLPROPERTY_INSTANCETYPEW))
1333 val = msi_reg_get_value(props, package, &type);
1336 if (prod || classes)
1337 r = ERROR_UNKNOWN_PROPERTY;
1344 if (!lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW))
1345 szProperty = displayname;
1346 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONSTRINGW))
1347 szProperty = displayversion;
1349 val = msi_reg_get_value(props, szProperty, &type);
1351 val = strdupW(szEmpty);
1353 r = msi_copy_outval(val, szValue, pcchValue);
1355 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_TRANSFORMSW) ||
1356 !lstrcmpW(szProperty, INSTALLPROPERTY_LANGUAGEW) ||
1357 !lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTNAMEW) ||
1358 !lstrcmpW(szProperty, INSTALLPROPERTY_PACKAGECODEW) ||
1359 !lstrcmpW(szProperty, INSTALLPROPERTY_VERSIONW) ||
1360 !lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTICONW) ||
1361 !lstrcmpW(szProperty, INSTALLPROPERTY_PACKAGENAMEW) ||
1362 !lstrcmpW(szProperty, INSTALLPROPERTY_AUTHORIZED_LUA_APPW))
1364 if (!prod && !classes)
1367 if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
1369 else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1371 else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1374 val = msi_reg_get_value(hkey, szProperty, &type);
1376 val = strdupW(szEmpty);
1378 r = msi_copy_outval(val, szValue, pcchValue);
1380 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_PRODUCTSTATEW))
1382 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1386 val = msi_reg_get_value(props, package, &type);
1391 val = strdupW(five);
1394 val = strdupW(szOne);
1396 r = msi_copy_outval(val, szValue, pcchValue);
1399 else if (props && (val = msi_reg_get_value(props, package, &type)))
1402 val = strdupW(five);
1403 r = msi_copy_outval(val, szValue, pcchValue);
1407 if (prod || managed)
1408 val = strdupW(szOne);
1412 r = msi_copy_outval(val, szValue, pcchValue);
1414 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_ASSIGNMENTTYPEW))
1416 if (!prod && !classes)
1420 val = strdupW(szEmpty);
1421 r = msi_copy_outval(val, szValue, pcchValue);
1424 r = ERROR_UNKNOWN_PROPERTY;
1429 RegCloseKey(managed);
1430 RegCloseKey(classes);
1436 UINT WINAPI MsiGetPatchInfoExA(LPCSTR szPatchCode, LPCSTR szProductCode,
1437 LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1438 LPCSTR szProperty, LPSTR lpValue, DWORD *pcchValue)
1440 LPWSTR patch = NULL, product = NULL, usersid = NULL;
1441 LPWSTR property = NULL, val = NULL;
1445 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode),
1446 debugstr_a(szProductCode), debugstr_a(szUserSid), dwContext,
1447 debugstr_a(szProperty), lpValue, pcchValue);
1449 if (lpValue && !pcchValue)
1450 return ERROR_INVALID_PARAMETER;
1452 if (szPatchCode) patch = strdupAtoW(szPatchCode);
1453 if (szProductCode) product = strdupAtoW(szProductCode);
1454 if (szUserSid) usersid = strdupAtoW(szUserSid);
1455 if (szProperty) property = strdupAtoW(szProperty);
1458 r = MsiGetPatchInfoExW(patch, product, usersid, dwContext, property,
1460 if (r != ERROR_SUCCESS)
1463 val = msi_alloc(++len * sizeof(WCHAR));
1466 r = ERROR_OUTOFMEMORY;
1470 r = MsiGetPatchInfoExW(patch, product, usersid, dwContext, property,
1472 if (r != ERROR_SUCCESS || !pcchValue)
1476 WideCharToMultiByte(CP_ACP, 0, val, -1, lpValue,
1477 *pcchValue - 1, NULL, NULL);
1479 len = lstrlenW(val);
1480 if ((*val && *pcchValue < len + 1) || !lpValue)
1484 r = ERROR_MORE_DATA;
1485 lpValue[*pcchValue - 1] = '\0';
1488 *pcchValue = len * sizeof(WCHAR);
1503 UINT WINAPI MsiGetPatchInfoExW(LPCWSTR szPatchCode, LPCWSTR szProductCode,
1504 LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1505 LPCWSTR szProperty, LPWSTR lpValue, DWORD *pcchValue)
1507 WCHAR squished_pc[GUID_SIZE];
1508 WCHAR squished_patch[GUID_SIZE];
1509 HKEY udprod = 0, prod = 0, props = 0;
1510 HKEY patch = 0, patches = 0;
1511 HKEY udpatch = 0, datakey = 0;
1512 HKEY prodpatches = 0;
1514 UINT r = ERROR_UNKNOWN_PRODUCT;
1518 static const WCHAR szManagedPackage[] = {'M','a','n','a','g','e','d',
1519 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1521 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode),
1522 debugstr_w(szProductCode), debugstr_w(szUserSid), dwContext,
1523 debugstr_w(szProperty), lpValue, pcchValue);
1525 if (!szProductCode || !squash_guid(szProductCode, squished_pc))
1526 return ERROR_INVALID_PARAMETER;
1528 if (!szPatchCode || !squash_guid(szPatchCode, squished_patch))
1529 return ERROR_INVALID_PARAMETER;
1532 return ERROR_INVALID_PARAMETER;
1534 if (lpValue && !pcchValue)
1535 return ERROR_INVALID_PARAMETER;
1537 if (dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
1538 dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
1539 dwContext != MSIINSTALLCONTEXT_MACHINE)
1540 return ERROR_INVALID_PARAMETER;
1542 if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
1543 return ERROR_INVALID_PARAMETER;
1545 if (!lstrcmpW(szUserSid, szLocalSid))
1546 return ERROR_INVALID_PARAMETER;
1548 if (MSIREG_OpenUserDataProductKey(szProductCode, dwContext, NULL,
1549 &udprod, FALSE) != ERROR_SUCCESS)
1552 if (MSIREG_OpenInstallProps(szProductCode, dwContext, NULL,
1553 &props, FALSE) != ERROR_SUCCESS)
1556 r = ERROR_UNKNOWN_PATCH;
1558 res = RegOpenKeyExW(udprod, szPatches, 0, KEY_READ, &patches);
1559 if (res != ERROR_SUCCESS)
1562 res = RegOpenKeyExW(patches, squished_patch, 0, KEY_READ, &patch);
1563 if (res != ERROR_SUCCESS)
1566 if (!lstrcmpW(szProperty, INSTALLPROPERTY_TRANSFORMSW))
1568 if (MSIREG_OpenProductKey(szProductCode, NULL, dwContext,
1569 &prod, FALSE) != ERROR_SUCCESS)
1572 res = RegOpenKeyExW(prod, szPatches, 0, KEY_ALL_ACCESS, &prodpatches);
1573 if (res != ERROR_SUCCESS)
1576 datakey = prodpatches;
1577 szProperty = squished_patch;
1581 if (MSIREG_OpenUserDataPatchKey(szPatchCode, dwContext,
1582 &udpatch, FALSE) != ERROR_SUCCESS)
1585 if (!lstrcmpW(szProperty, INSTALLPROPERTY_LOCALPACKAGEW))
1587 if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1588 szProperty = szManagedPackage;
1591 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_INSTALLDATEW))
1594 szProperty = szInstalled;
1596 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_LOCALPACKAGEW))
1600 else if (!lstrcmpW(szProperty, INSTALLPROPERTY_UNINSTALLABLEW) ||
1601 !lstrcmpW(szProperty, INSTALLPROPERTY_PATCHSTATEW) ||
1602 !lstrcmpW(szProperty, INSTALLPROPERTY_DISPLAYNAMEW) ||
1603 !lstrcmpW(szProperty, INSTALLPROPERTY_MOREINFOURLW))
1609 r = ERROR_UNKNOWN_PROPERTY;
1614 val = msi_reg_get_val_str(datakey, szProperty);
1616 val = strdupW(szEmpty);
1624 lstrcpynW(lpValue, val, *pcchValue);
1626 len = lstrlenW(val);
1627 if ((*val && *pcchValue < len + 1) || !lpValue)
1630 r = ERROR_MORE_DATA;
1632 *pcchValue = len * sizeof(WCHAR);
1639 RegCloseKey(prodpatches);
1642 RegCloseKey(patches);
1643 RegCloseKey(udpatch);
1645 RegCloseKey(udprod);
1650 UINT WINAPI MsiGetPatchInfoA( LPCSTR patch, LPCSTR attr, LPSTR buffer, LPDWORD buflen )
1652 UINT r = ERROR_OUTOFMEMORY;
1654 LPWSTR patchW = NULL, attrW = NULL, bufferW = NULL;
1656 TRACE("%s %s %p %p\n", debugstr_a(patch), debugstr_a(attr), buffer, buflen);
1658 if (!patch || !attr)
1659 return ERROR_INVALID_PARAMETER;
1661 if (!(patchW = strdupAtoW( patch )))
1664 if (!(attrW = strdupAtoW( attr )))
1668 r = MsiGetPatchInfoW( patchW, attrW, NULL, &size );
1669 if (r != ERROR_SUCCESS)
1673 if (!(bufferW = msi_alloc( size * sizeof(WCHAR) )))
1675 r = ERROR_OUTOFMEMORY;
1679 r = MsiGetPatchInfoW( patchW, attrW, bufferW, &size );
1680 if (r == ERROR_SUCCESS)
1682 int len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
1684 r = ERROR_MORE_DATA;
1686 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *buflen, NULL, NULL );
1694 msi_free( bufferW );
1698 UINT WINAPI MsiGetPatchInfoW( LPCWSTR patch, LPCWSTR attr, LPWSTR buffer, LPDWORD buflen )
1701 WCHAR product[GUID_SIZE];
1704 TRACE("%s %s %p %p\n", debugstr_w(patch), debugstr_w(attr), buffer, buflen);
1706 if (!patch || !attr)
1707 return ERROR_INVALID_PARAMETER;
1709 if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW, attr ))
1710 return ERROR_UNKNOWN_PROPERTY;
1715 r = MsiEnumProductsW( index, product );
1716 if (r != ERROR_SUCCESS)
1719 r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERMANAGED, attr, buffer, buflen );
1720 if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
1723 r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, attr, buffer, buflen );
1724 if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
1727 r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_MACHINE, attr, buffer, buflen );
1728 if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
1734 return ERROR_UNKNOWN_PRODUCT;
1737 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
1739 LPWSTR szwLogFile = NULL;
1742 TRACE("%08x %s %08x\n", dwLogMode, debugstr_a(szLogFile), attributes);
1746 szwLogFile = strdupAtoW( szLogFile );
1748 return ERROR_OUTOFMEMORY;
1750 r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
1751 msi_free( szwLogFile );
1755 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
1757 HANDLE file = INVALID_HANDLE_VALUE;
1759 TRACE("%08x %s %08x\n", dwLogMode, debugstr_w(szLogFile), attributes);
1763 lstrcpyW(gszLogFile,szLogFile);
1764 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
1765 DeleteFileW(szLogFile);
1766 file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
1767 FILE_ATTRIBUTE_NORMAL, NULL);
1768 if (file != INVALID_HANDLE_VALUE)
1771 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
1774 gszLogFile[0] = '\0';
1776 return ERROR_SUCCESS;
1779 UINT WINAPI MsiEnumComponentCostsW(MSIHANDLE hInstall, LPCWSTR szComponent,
1780 DWORD dwIndex, INSTALLSTATE iState,
1781 LPWSTR lpDriveBuf, DWORD *pcchDriveBuf,
1782 int *piCost, int *pTempCost)
1784 FIXME("(%d, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall,
1785 debugstr_w(szComponent), dwIndex, iState, lpDriveBuf,
1786 pcchDriveBuf, piCost, pTempCost);
1788 return ERROR_NO_MORE_ITEMS;
1791 UINT WINAPI MsiQueryComponentStateA(LPCSTR szProductCode,
1792 LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1793 LPCSTR szComponent, INSTALLSTATE *pdwState)
1795 LPWSTR prodcode = NULL, usersid = NULL, comp = NULL;
1798 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode),
1799 debugstr_a(szUserSid), dwContext, debugstr_a(szComponent), pdwState);
1801 if (szProductCode && !(prodcode = strdupAtoW(szProductCode)))
1802 return ERROR_OUTOFMEMORY;
1804 if (szUserSid && !(usersid = strdupAtoW(szUserSid)))
1805 return ERROR_OUTOFMEMORY;
1807 if (szComponent && !(comp = strdupAtoW(szComponent)))
1808 return ERROR_OUTOFMEMORY;
1810 r = MsiQueryComponentStateW(prodcode, usersid, dwContext, comp, pdwState);
1819 static BOOL msi_comp_find_prod_key(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
1824 r = MSIREG_OpenProductKey(prodcode, NULL, context, &hkey, FALSE);
1826 return (r == ERROR_SUCCESS);
1829 static BOOL msi_comp_find_package(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
1837 static const WCHAR local_package[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
1838 static const WCHAR managed_local_package[] = {
1839 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
1842 r = MSIREG_OpenInstallProps(prodcode, context, NULL, &hkey, FALSE);
1843 if (r != ERROR_SUCCESS)
1846 if (context == MSIINSTALLCONTEXT_USERMANAGED)
1847 package = managed_local_package;
1849 package = local_package;
1852 res = RegQueryValueExW(hkey, package, NULL, NULL, NULL, &sz);
1855 return (res == ERROR_SUCCESS);
1858 static BOOL msi_comp_find_prodcode(LPWSTR squished_pc,
1859 MSIINSTALLCONTEXT context,
1860 LPCWSTR comp, LPWSTR val, DWORD *sz)
1866 if (context == MSIINSTALLCONTEXT_MACHINE)
1867 r = MSIREG_OpenUserDataComponentKey(comp, szLocalSid, &hkey, FALSE);
1869 r = MSIREG_OpenUserDataComponentKey(comp, NULL, &hkey, FALSE);
1871 if (r != ERROR_SUCCESS)
1874 res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, (BYTE *)val, sz);
1875 if (res != ERROR_SUCCESS)
1882 UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
1883 LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1884 LPCWSTR szComponent, INSTALLSTATE *pdwState)
1886 WCHAR squished_pc[GUID_SIZE];
1887 WCHAR val[MAX_PATH];
1891 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode),
1892 debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState);
1894 if (!pdwState || !szComponent)
1895 return ERROR_INVALID_PARAMETER;
1897 if (!szProductCode || !*szProductCode || lstrlenW(szProductCode) != GUID_SIZE - 1)
1898 return ERROR_INVALID_PARAMETER;
1900 if (!squash_guid(szProductCode, squished_pc))
1901 return ERROR_INVALID_PARAMETER;
1903 found = msi_comp_find_prod_key(szProductCode, dwContext);
1905 if (!msi_comp_find_package(szProductCode, dwContext))
1909 *pdwState = INSTALLSTATE_UNKNOWN;
1910 return ERROR_UNKNOWN_COMPONENT;
1913 return ERROR_UNKNOWN_PRODUCT;
1916 *pdwState = INSTALLSTATE_UNKNOWN;
1919 if (!msi_comp_find_prodcode(squished_pc, dwContext, szComponent, val, &sz))
1920 return ERROR_UNKNOWN_COMPONENT;
1923 *pdwState = INSTALLSTATE_NOTUSED;
1926 if (lstrlenW(val) > 2 &&
1927 val[0] >= '0' && val[0] <= '9' && val[1] >= '0' && val[1] <= '9')
1929 *pdwState = INSTALLSTATE_SOURCE;
1932 *pdwState = INSTALLSTATE_LOCAL;
1935 return ERROR_SUCCESS;
1938 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
1940 LPWSTR szwProduct = NULL;
1945 szwProduct = strdupAtoW( szProduct );
1947 return ERROR_OUTOFMEMORY;
1949 r = MsiQueryProductStateW( szwProduct );
1950 msi_free( szwProduct );
1954 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
1956 MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
1957 INSTALLSTATE state = INSTALLSTATE_ADVERTISED;
1958 HKEY prodkey = 0, userdata = 0;
1962 static const WCHAR szWindowsInstaller[] = {
1963 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1965 TRACE("%s\n", debugstr_w(szProduct));
1967 if (!szProduct || !*szProduct)
1968 return INSTALLSTATE_INVALIDARG;
1970 if (lstrlenW(szProduct) != GUID_SIZE - 1)
1971 return INSTALLSTATE_INVALIDARG;
1973 if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
1974 &prodkey, FALSE) != ERROR_SUCCESS &&
1975 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1976 &prodkey, FALSE) != ERROR_SUCCESS &&
1977 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
1978 &prodkey, FALSE) == ERROR_SUCCESS)
1980 context = MSIINSTALLCONTEXT_MACHINE;
1983 r = MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE);
1984 if (r != ERROR_SUCCESS)
1987 if (!msi_reg_get_val_dword(userdata, szWindowsInstaller, &val))
1991 state = INSTALLSTATE_DEFAULT;
1993 state = INSTALLSTATE_UNKNOWN;
1998 state = INSTALLSTATE_UNKNOWN;
2001 state = INSTALLSTATE_ABSENT;
2004 RegCloseKey(prodkey);
2005 RegCloseKey(userdata);
2009 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
2011 INSTALLUILEVEL old = gUILevel;
2012 HWND oldwnd = gUIhwnd;
2014 TRACE("%08x %p\n", dwUILevel, phWnd);
2016 gUILevel = dwUILevel;
2025 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
2026 DWORD dwMessageFilter, LPVOID pvContext)
2028 INSTALLUI_HANDLERA prev = gUIHandlerA;
2030 TRACE("%p %08x %p\n", puiHandler, dwMessageFilter, pvContext);
2032 gUIHandlerA = puiHandler;
2034 gUIFilter = dwMessageFilter;
2035 gUIContext = pvContext;
2040 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
2041 DWORD dwMessageFilter, LPVOID pvContext)
2043 INSTALLUI_HANDLERW prev = gUIHandlerW;
2045 TRACE("%p %08x %p\n", puiHandler, dwMessageFilter, pvContext);
2048 gUIHandlerW = puiHandler;
2049 gUIFilter = dwMessageFilter;
2050 gUIContext = pvContext;
2055 /******************************************************************
2056 * MsiLoadStringW [MSI.@]
2058 * Loads a string from MSI's string resources.
2062 * handle [I] only -1 is handled currently
2063 * id [I] id of the string to be loaded
2064 * lpBuffer [O] buffer for the string to be written to
2065 * nBufferMax [I] maximum size of the buffer in characters
2066 * lang [I] the preferred language for the string
2070 * If successful, this function returns the language id of the string loaded
2071 * If the function fails, the function returns zero.
2075 * The type of the first parameter is unknown. LoadString's prototype
2076 * suggests that it might be a module handle. I have made it an MSI handle
2077 * for starters, as -1 is an invalid MSI handle, but not an invalid module
2078 * handle. Maybe strings can be stored in an MSI database somehow.
2080 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
2081 int nBufferMax, LANGID lang )
2088 TRACE("%d %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
2091 FIXME("don't know how to deal with handle = %08x\n", handle);
2094 lang = GetUserDefaultLangID();
2096 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
2100 hResData = LoadResource( msi_hInstance, hres );
2103 p = LockResource( hResData );
2107 for (i = 0; i < (id&0xf); i++)
2111 if( nBufferMax <= len )
2114 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
2115 lpBuffer[ len ] = 0;
2117 TRACE("found -> %s\n", debugstr_w(lpBuffer));
2122 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
2123 int nBufferMax, LANGID lang )
2129 bufW = msi_alloc(nBufferMax*sizeof(WCHAR));
2130 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
2133 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
2134 if( len <= nBufferMax )
2135 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
2136 lpBuffer, nBufferMax, NULL, NULL );
2144 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
2147 char szProduct[GUID_SIZE];
2149 TRACE("%s %p %p\n", debugstr_a(szComponent), lpPathBuf, pcchBuf);
2151 if (MsiGetProductCodeA( szComponent, szProduct ) != ERROR_SUCCESS)
2152 return INSTALLSTATE_UNKNOWN;
2154 return MsiGetComponentPathA( szProduct, szComponent, lpPathBuf, pcchBuf );
2157 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
2160 WCHAR szProduct[GUID_SIZE];
2162 TRACE("%s %p %p\n", debugstr_w(szComponent), lpPathBuf, pcchBuf);
2164 if (MsiGetProductCodeW( szComponent, szProduct ) != ERROR_SUCCESS)
2165 return INSTALLSTATE_UNKNOWN;
2167 return MsiGetComponentPathW( szProduct, szComponent, lpPathBuf, pcchBuf );
2170 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
2171 WORD wLanguageId, DWORD f)
2173 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_a(lpText), debugstr_a(lpCaption),
2174 uType, wLanguageId, f);
2175 return MessageBoxExA(hWnd,lpText,lpCaption,uType,wLanguageId);
2178 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
2179 WORD wLanguageId, DWORD f)
2181 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_w(lpText), debugstr_w(lpCaption),
2182 uType, wLanguageId, f);
2183 return MessageBoxExW(hWnd,lpText,lpCaption,uType,wLanguageId);
2186 UINT WINAPI MsiMessageBoxExA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
2187 DWORD unknown, WORD wLanguageId, DWORD f)
2189 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd, debugstr_a(lpText),
2190 debugstr_a(lpCaption), uType, unknown, wLanguageId, f);
2191 return MessageBoxExA(hWnd, lpText, lpCaption, uType, wLanguageId);
2194 UINT WINAPI MsiMessageBoxExW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
2195 DWORD unknown, WORD wLanguageId, DWORD f)
2197 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd, debugstr_w(lpText),
2198 debugstr_w(lpCaption), uType, unknown, wLanguageId, f);
2199 return MessageBoxExW(hWnd, lpText, lpCaption, uType, wLanguageId);
2202 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
2203 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
2204 LPDWORD pcchPathBuf )
2206 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName),
2207 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
2209 return ERROR_CALL_NOT_IMPLEMENTED;
2212 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
2213 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
2214 LPDWORD pcchPathBuf )
2216 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName),
2217 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
2219 return ERROR_CALL_NOT_IMPLEMENTED;
2222 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
2223 LPSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
2225 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
2226 return ERROR_CALL_NOT_IMPLEMENTED;
2229 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
2230 LPWSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
2232 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
2233 return ERROR_CALL_NOT_IMPLEMENTED;
2236 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
2237 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
2238 LPDWORD pcbHashData)
2240 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
2241 ppcCertContext, pbHashData, pcbHashData);
2242 return ERROR_CALL_NOT_IMPLEMENTED;
2245 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
2246 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
2247 LPDWORD pcbHashData)
2249 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
2250 ppcCertContext, pbHashData, pcbHashData);
2251 return ERROR_CALL_NOT_IMPLEMENTED;
2254 /******************************************************************
2255 * MsiGetProductPropertyA [MSI.@]
2257 UINT WINAPI MsiGetProductPropertyA(MSIHANDLE hProduct, LPCSTR szProperty,
2258 LPSTR szValue, LPDWORD pccbValue)
2260 LPWSTR prop = NULL, val = NULL;
2264 TRACE("(%d, %s, %p, %p)\n", hProduct, debugstr_a(szProperty),
2265 szValue, pccbValue);
2267 if (szValue && !pccbValue)
2268 return ERROR_INVALID_PARAMETER;
2270 if (szProperty) prop = strdupAtoW(szProperty);
2273 r = MsiGetProductPropertyW(hProduct, prop, NULL, &len);
2274 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
2277 if (r == ERROR_SUCCESS)
2279 if (szValue) *szValue = '\0';
2280 if (pccbValue) *pccbValue = 0;
2284 val = msi_alloc(++len * sizeof(WCHAR));
2287 r = ERROR_OUTOFMEMORY;
2291 r = MsiGetProductPropertyW(hProduct, prop, val, &len);
2292 if (r != ERROR_SUCCESS)
2295 len = WideCharToMultiByte(CP_ACP, 0, val, -1, NULL, 0, NULL, NULL);
2298 WideCharToMultiByte(CP_ACP, 0, val, -1, szValue,
2299 *pccbValue, NULL, NULL);
2303 if (len > *pccbValue)
2304 r = ERROR_MORE_DATA;
2306 *pccbValue = len - 1;
2316 /******************************************************************
2317 * MsiGetProductPropertyW [MSI.@]
2319 UINT WINAPI MsiGetProductPropertyW(MSIHANDLE hProduct, LPCWSTR szProperty,
2320 LPWSTR szValue, LPDWORD pccbValue)
2322 MSIPACKAGE *package;
2323 MSIQUERY *view = NULL;
2324 MSIRECORD *rec = NULL;
2328 static const WCHAR query[] = {
2329 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2330 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2331 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2333 TRACE("(%d, %s, %p, %p)\n", hProduct, debugstr_w(szProperty),
2334 szValue, pccbValue);
2337 return ERROR_INVALID_PARAMETER;
2339 if (szValue && !pccbValue)
2340 return ERROR_INVALID_PARAMETER;
2342 package = msihandle2msiinfo(hProduct, MSIHANDLETYPE_PACKAGE);
2344 return ERROR_INVALID_HANDLE;
2346 r = MSI_OpenQuery(package->db, &view, query, szProperty);
2347 if (r != ERROR_SUCCESS)
2350 r = MSI_ViewExecute(view, 0);
2351 if (r != ERROR_SUCCESS)
2354 r = MSI_ViewFetch(view, &rec);
2355 if (r != ERROR_SUCCESS)
2358 val = MSI_RecordGetString(rec, 2);
2362 if (lstrlenW(val) >= *pccbValue)
2364 lstrcpynW(szValue, val, *pccbValue);
2365 *pccbValue = lstrlenW(val);
2366 r = ERROR_MORE_DATA;
2370 lstrcpyW(szValue, val);
2371 *pccbValue = lstrlenW(val);
2378 MSI_ViewClose(view);
2379 msiobj_release(&view->hdr);
2380 if (rec) msiobj_release(&rec->hdr);
2385 if (szValue) *szValue = '\0';
2386 if (pccbValue) *pccbValue = 0;
2390 msiobj_release(&package->hdr);
2394 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
2397 LPWSTR szPack = NULL;
2399 TRACE("%s\n", debugstr_a(szPackage) );
2403 szPack = strdupAtoW( szPackage );
2405 return ERROR_OUTOFMEMORY;
2408 r = MsiVerifyPackageW( szPack );
2415 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
2420 TRACE("%s\n", debugstr_w(szPackage) );
2422 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
2423 MsiCloseHandle( handle );
2428 static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
2429 awstring* lpPathBuf, LPDWORD pcchBuf)
2431 WCHAR squished_pc[GUID_SIZE];
2432 WCHAR squished_comp[GUID_SIZE];
2438 static const WCHAR wininstaller[] = {
2439 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2441 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
2442 debugstr_w(szComponent), lpPathBuf->str.w, pcchBuf);
2444 if (!szProduct || !szComponent)
2445 return INSTALLSTATE_INVALIDARG;
2447 if (lpPathBuf->str.w && !pcchBuf)
2448 return INSTALLSTATE_INVALIDARG;
2450 if (!squash_guid(szProduct, squished_pc) ||
2451 !squash_guid(szComponent, squished_comp))
2452 return INSTALLSTATE_INVALIDARG;
2454 state = INSTALLSTATE_UNKNOWN;
2456 if (MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &hkey, FALSE) == ERROR_SUCCESS ||
2457 MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkey, FALSE) == ERROR_SUCCESS)
2459 path = msi_reg_get_val_str(hkey, squished_pc);
2462 state = INSTALLSTATE_ABSENT;
2464 if ((MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE, NULL,
2465 &hkey, FALSE) == ERROR_SUCCESS ||
2466 MSIREG_OpenUserDataProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
2467 NULL, &hkey, FALSE) == ERROR_SUCCESS) &&
2468 msi_reg_get_val_dword(hkey, wininstaller, &version) &&
2469 GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
2472 state = INSTALLSTATE_LOCAL;
2476 if (state != INSTALLSTATE_LOCAL &&
2477 (MSIREG_OpenProductKey(szProduct, NULL,
2478 MSIINSTALLCONTEXT_USERUNMANAGED,
2479 &hkey, FALSE) == ERROR_SUCCESS ||
2480 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
2481 &hkey, FALSE) == ERROR_SUCCESS))
2485 if (MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &hkey, FALSE) == ERROR_SUCCESS ||
2486 MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkey, FALSE) == ERROR_SUCCESS)
2489 path = msi_reg_get_val_str(hkey, squished_pc);
2492 state = INSTALLSTATE_ABSENT;
2494 if (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
2495 state = INSTALLSTATE_LOCAL;
2500 return INSTALLSTATE_UNKNOWN;
2502 if (state == INSTALLSTATE_LOCAL && !*path)
2503 state = INSTALLSTATE_NOTUSED;
2505 msi_strcpy_to_awstring(path, lpPathBuf, pcchBuf);
2510 /******************************************************************
2511 * MsiGetComponentPathW [MSI.@]
2513 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
2514 LPWSTR lpPathBuf, LPDWORD pcchBuf)
2518 path.unicode = TRUE;
2519 path.str.w = lpPathBuf;
2521 return MSI_GetComponentPath( szProduct, szComponent, &path, pcchBuf );
2524 /******************************************************************
2525 * MsiGetComponentPathA [MSI.@]
2527 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
2528 LPSTR lpPathBuf, LPDWORD pcchBuf)
2530 LPWSTR szwProduct, szwComponent = NULL;
2531 INSTALLSTATE r = INSTALLSTATE_UNKNOWN;
2534 szwProduct = strdupAtoW( szProduct );
2535 if( szProduct && !szwProduct)
2538 szwComponent = strdupAtoW( szComponent );
2539 if( szComponent && !szwComponent )
2542 path.unicode = FALSE;
2543 path.str.a = lpPathBuf;
2545 r = MSI_GetComponentPath( szwProduct, szwComponent, &path, pcchBuf );
2548 msi_free( szwProduct );
2549 msi_free( szwComponent );
2554 /******************************************************************
2555 * MsiQueryFeatureStateA [MSI.@]
2557 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
2559 LPWSTR szwProduct = NULL, szwFeature= NULL;
2560 INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
2562 szwProduct = strdupAtoW( szProduct );
2563 if ( szProduct && !szwProduct )
2566 szwFeature = strdupAtoW( szFeature );
2567 if ( szFeature && !szwFeature )
2570 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
2573 msi_free( szwProduct);
2574 msi_free( szwFeature);
2579 /******************************************************************
2580 * MsiQueryFeatureStateW [MSI.@]
2582 * Checks the state of a feature
2585 * szProduct [I] Product's GUID string
2586 * szFeature [I] Feature's GUID string
2589 * INSTALLSTATE_LOCAL Feature is installed and usable
2590 * INSTALLSTATE_ABSENT Feature is absent
2591 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
2592 * INSTALLSTATE_UNKNOWN An error occurred
2593 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
2596 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
2598 WCHAR squishProduct[33], comp[GUID_SIZE];
2600 LPWSTR components, p, parent_feature, path;
2604 BOOL missing = FALSE;
2605 BOOL machine = FALSE;
2606 BOOL source = FALSE;
2608 TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
2610 if (!szProduct || !szFeature)
2611 return INSTALLSTATE_INVALIDARG;
2613 if (!squash_guid( szProduct, squishProduct ))
2614 return INSTALLSTATE_INVALIDARG;
2616 if (MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
2617 &hkey, FALSE) != ERROR_SUCCESS &&
2618 MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
2619 &hkey, FALSE) != ERROR_SUCCESS)
2621 rc = MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
2623 if (rc != ERROR_SUCCESS)
2624 return INSTALLSTATE_UNKNOWN;
2629 parent_feature = msi_reg_get_val_str( hkey, szFeature );
2632 if (!parent_feature)
2633 return INSTALLSTATE_UNKNOWN;
2635 r = (parent_feature[0] == 6) ? INSTALLSTATE_ABSENT : INSTALLSTATE_LOCAL;
2636 msi_free(parent_feature);
2637 if (r == INSTALLSTATE_ABSENT)
2641 rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
2642 MSIINSTALLCONTEXT_MACHINE,
2645 rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
2646 MSIINSTALLCONTEXT_USERUNMANAGED,
2649 if (rc != ERROR_SUCCESS)
2650 return INSTALLSTATE_ADVERTISED;
2652 components = msi_reg_get_val_str( hkey, szFeature );
2655 TRACE("rc = %d buffer = %s\n", rc, debugstr_w(components));
2658 return INSTALLSTATE_ADVERTISED;
2660 for( p = components; *p && *p != 2 ; p += 20)
2662 if (!decode_base85_guid( p, &guid ))
2664 if (p != components)
2667 msi_free(components);
2668 return INSTALLSTATE_BADCONFIG;
2671 StringFromGUID2(&guid, comp, GUID_SIZE);
2674 rc = MSIREG_OpenUserDataComponentKey(comp, szLocalSid, &hkey, FALSE);
2676 rc = MSIREG_OpenUserDataComponentKey(comp, NULL, &hkey, FALSE);
2678 if (rc != ERROR_SUCCESS)
2680 msi_free(components);
2681 return INSTALLSTATE_ADVERTISED;
2684 path = msi_reg_get_val_str(hkey, squishProduct);
2687 else if (lstrlenW(path) > 2 &&
2688 path[0] >= '0' && path[0] <= '9' &&
2689 path[1] >= '0' && path[1] <= '9')
2697 TRACE("%s %s -> %d\n", debugstr_w(szProduct), debugstr_w(szFeature), r);
2698 msi_free(components);
2701 return INSTALLSTATE_ADVERTISED;
2704 return INSTALLSTATE_SOURCE;
2706 return INSTALLSTATE_LOCAL;
2709 /******************************************************************
2710 * MsiGetFileVersionA [MSI.@]
2712 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
2713 LPDWORD pcchVersionBuf, LPSTR lpLangBuf, LPDWORD pcchLangBuf)
2715 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
2716 UINT ret = ERROR_OUTOFMEMORY;
2718 if ((lpVersionBuf && !pcchVersionBuf) ||
2719 (lpLangBuf && !pcchLangBuf))
2720 return ERROR_INVALID_PARAMETER;
2724 szwFilePath = strdupAtoW( szFilePath );
2729 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
2731 lpwVersionBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
2732 if( !lpwVersionBuff )
2736 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
2738 lpwLangBuff = msi_alloc(*pcchLangBuf*sizeof(WCHAR));
2743 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
2744 lpwLangBuff, pcchLangBuf);
2746 if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwVersionBuff )
2747 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
2748 lpVersionBuf, *pcchVersionBuf + 1, NULL, NULL);
2749 if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwLangBuff )
2750 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
2751 lpLangBuf, *pcchLangBuf + 1, NULL, NULL);
2754 msi_free(szwFilePath);
2755 msi_free(lpwVersionBuff);
2756 msi_free(lpwLangBuff);
2761 /******************************************************************
2762 * MsiGetFileVersionW [MSI.@]
2764 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
2765 LPDWORD pcchVersionBuf, LPWSTR lpLangBuf, LPDWORD pcchLangBuf)
2767 static const WCHAR szVersionResource[] = {'\\',0};
2768 static const WCHAR szVersionFormat[] = {
2769 '%','d','.','%','d','.','%','d','.','%','d',0};
2770 static const WCHAR szLangResource[] = {
2771 '\\','V','a','r','F','i','l','e','I','n','f','o','\\',
2772 'T','r','a','n','s','l','a','t','i','o','n',0};
2773 static const WCHAR szLangFormat[] = {'%','d',0};
2775 DWORD dwVerLen, gle;
2776 LPVOID lpVer = NULL;
2777 VS_FIXEDFILEINFO *ffi;
2782 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath),
2783 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
2784 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
2786 if ((lpVersionBuf && !pcchVersionBuf) ||
2787 (lpLangBuf && !pcchLangBuf))
2788 return ERROR_INVALID_PARAMETER;
2790 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
2793 gle = GetLastError();
2794 if (gle == ERROR_BAD_PATHNAME)
2795 return ERROR_FILE_NOT_FOUND;
2796 else if (gle == ERROR_RESOURCE_DATA_NOT_FOUND)
2797 return ERROR_FILE_INVALID;
2802 lpVer = msi_alloc(dwVerLen);
2805 ret = ERROR_OUTOFMEMORY;
2809 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
2811 ret = GetLastError();
2817 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
2820 wsprintfW(tmp, szVersionFormat,
2821 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
2822 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
2823 if (lpVersionBuf) lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
2825 if (strlenW(tmp) >= *pcchVersionBuf)
2826 ret = ERROR_MORE_DATA;
2828 *pcchVersionBuf = lstrlenW(tmp);
2832 if (lpVersionBuf) *lpVersionBuf = 0;
2833 *pcchVersionBuf = 0;
2839 if (VerQueryValueW(lpVer, szLangResource, (LPVOID*)&lang, &puLen) &&
2842 wsprintfW(tmp, szLangFormat, *lang);
2843 if (lpLangBuf) lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
2845 if (strlenW(tmp) >= *pcchLangBuf)
2846 ret = ERROR_MORE_DATA;
2848 *pcchLangBuf = lstrlenW(tmp);
2852 if (lpLangBuf) *lpLangBuf = 0;
2862 /***********************************************************************
2863 * MsiGetFeatureUsageW [MSI.@]
2865 UINT WINAPI MsiGetFeatureUsageW( LPCWSTR szProduct, LPCWSTR szFeature,
2866 LPDWORD pdwUseCount, LPWORD pwDateUsed )
2868 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
2869 pdwUseCount, pwDateUsed);
2870 return ERROR_CALL_NOT_IMPLEMENTED;
2873 /***********************************************************************
2874 * MsiGetFeatureUsageA [MSI.@]
2876 UINT WINAPI MsiGetFeatureUsageA( LPCSTR szProduct, LPCSTR szFeature,
2877 LPDWORD pdwUseCount, LPWORD pwDateUsed )
2879 LPWSTR prod = NULL, feat = NULL;
2880 UINT ret = ERROR_OUTOFMEMORY;
2882 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
2883 pdwUseCount, pwDateUsed);
2885 prod = strdupAtoW( szProduct );
2886 if (szProduct && !prod)
2889 feat = strdupAtoW( szFeature );
2890 if (szFeature && !feat)
2893 ret = MsiGetFeatureUsageW( prod, feat, pdwUseCount, pwDateUsed );
2902 /***********************************************************************
2903 * MsiUseFeatureExW [MSI.@]
2905 INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
2906 DWORD dwInstallMode, DWORD dwReserved )
2910 TRACE("%s %s %i %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
2911 dwInstallMode, dwReserved);
2913 state = MsiQueryFeatureStateW( szProduct, szFeature );
2916 return INSTALLSTATE_INVALIDARG;
2918 if (state == INSTALLSTATE_LOCAL && dwInstallMode != INSTALLMODE_NODETECTION)
2920 FIXME("mark product %s feature %s as used\n",
2921 debugstr_w(szProduct), debugstr_w(szFeature) );
2927 /***********************************************************************
2928 * MsiUseFeatureExA [MSI.@]
2930 INSTALLSTATE WINAPI MsiUseFeatureExA( LPCSTR szProduct, LPCSTR szFeature,
2931 DWORD dwInstallMode, DWORD dwReserved )
2933 INSTALLSTATE ret = INSTALLSTATE_UNKNOWN;
2934 LPWSTR prod = NULL, feat = NULL;
2936 TRACE("%s %s %i %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
2937 dwInstallMode, dwReserved);
2939 prod = strdupAtoW( szProduct );
2940 if (szProduct && !prod)
2943 feat = strdupAtoW( szFeature );
2944 if (szFeature && !feat)
2947 ret = MsiUseFeatureExW( prod, feat, dwInstallMode, dwReserved );
2956 /***********************************************************************
2957 * MsiUseFeatureW [MSI.@]
2959 INSTALLSTATE WINAPI MsiUseFeatureW( LPCWSTR szProduct, LPCWSTR szFeature )
2961 return MsiUseFeatureExW(szProduct, szFeature, 0, 0);
2964 /***********************************************************************
2965 * MsiUseFeatureA [MSI.@]
2967 INSTALLSTATE WINAPI MsiUseFeatureA( LPCSTR szProduct, LPCSTR szFeature )
2969 return MsiUseFeatureExA(szProduct, szFeature, 0, 0);
2972 /***********************************************************************
2973 * MSI_ProvideQualifiedComponentEx [internal]
2975 static UINT MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent,
2976 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
2977 DWORD Unused1, DWORD Unused2, awstring *lpPathBuf,
2978 LPDWORD pcchPathBuf)
2980 WCHAR product[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1],
2981 feature[MAX_FEATURE_CHARS+1];
2987 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent),
2988 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
2989 Unused1, Unused2, lpPathBuf, pcchPathBuf);
2991 rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE);
2992 if (rc != ERROR_SUCCESS)
2993 return ERROR_INDEX_ABSENT;
2995 info = msi_reg_get_val_str( hkey, szQualifier );
2999 return ERROR_INDEX_ABSENT;
3001 MsiDecomposeDescriptorW(info, product, feature, component, &sz);
3004 rc = MSI_GetComponentPath(product, component, lpPathBuf, pcchPathBuf);
3006 rc = MSI_GetComponentPath(szProduct, component, lpPathBuf, pcchPathBuf);
3010 if (rc != INSTALLSTATE_LOCAL)
3011 return ERROR_FILE_NOT_FOUND;
3013 return ERROR_SUCCESS;
3016 /***********************************************************************
3017 * MsiProvideQualifiedComponentExW [MSI.@]
3019 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
3020 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
3021 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
3022 LPDWORD pcchPathBuf)
3026 path.unicode = TRUE;
3027 path.str.w = lpPathBuf;
3029 return MSI_ProvideQualifiedComponentEx(szComponent, szQualifier,
3030 dwInstallMode, szProduct, Unused1, Unused2, &path, pcchPathBuf);
3033 /***********************************************************************
3034 * MsiProvideQualifiedComponentExA [MSI.@]
3036 UINT WINAPI MsiProvideQualifiedComponentExA(LPCSTR szComponent,
3037 LPCSTR szQualifier, DWORD dwInstallMode, LPCSTR szProduct,
3038 DWORD Unused1, DWORD Unused2, LPSTR lpPathBuf,
3039 LPDWORD pcchPathBuf)
3041 LPWSTR szwComponent, szwQualifier = NULL, szwProduct = NULL;
3042 UINT r = ERROR_OUTOFMEMORY;
3045 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent),
3046 debugstr_a(szQualifier), dwInstallMode, debugstr_a(szProduct),
3047 Unused1, Unused2, lpPathBuf, pcchPathBuf);
3049 szwComponent = strdupAtoW( szComponent );
3050 if (szComponent && !szwComponent)
3053 szwQualifier = strdupAtoW( szQualifier );
3054 if (szQualifier && !szwQualifier)
3057 szwProduct = strdupAtoW( szProduct );
3058 if (szProduct && !szwProduct)
3061 path.unicode = FALSE;
3062 path.str.a = lpPathBuf;
3064 r = MSI_ProvideQualifiedComponentEx(szwComponent, szwQualifier,
3065 dwInstallMode, szwProduct, Unused1,
3066 Unused2, &path, pcchPathBuf);
3068 msi_free(szwProduct);
3069 msi_free(szwComponent);
3070 msi_free(szwQualifier);
3075 /***********************************************************************
3076 * MsiProvideQualifiedComponentW [MSI.@]
3078 UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
3079 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
3080 LPDWORD pcchPathBuf)
3082 return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
3083 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
3086 /***********************************************************************
3087 * MsiProvideQualifiedComponentA [MSI.@]
3089 UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
3090 LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
3091 LPDWORD pcchPathBuf)
3093 return MsiProvideQualifiedComponentExA(szComponent, szQualifier,
3094 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
3097 /***********************************************************************
3098 * MSI_GetUserInfo [internal]
3100 static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
3101 awstring *lpUserNameBuf, LPDWORD pcchUserNameBuf,
3102 awstring *lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
3103 awstring *lpSerialBuf, LPDWORD pcchSerialBuf)
3105 WCHAR squished_pc[SQUISH_GUID_SIZE];
3106 LPWSTR user, org, serial;
3107 USERINFOSTATE state;
3112 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct), lpUserNameBuf,
3113 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
3116 if (!szProduct || !squash_guid(szProduct, squished_pc))
3117 return USERINFOSTATE_INVALIDARG;
3119 if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
3120 &hkey, FALSE) != ERROR_SUCCESS &&
3121 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3122 &hkey, FALSE) != ERROR_SUCCESS &&
3123 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
3124 &hkey, FALSE) != ERROR_SUCCESS)
3126 return USERINFOSTATE_UNKNOWN;
3129 if (MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
3130 NULL, &props, FALSE) != ERROR_SUCCESS &&
3131 MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE,
3132 NULL, &props, FALSE) != ERROR_SUCCESS)
3135 return USERINFOSTATE_ABSENT;
3138 user = msi_reg_get_val_str(props, INSTALLPROPERTY_REGOWNERW);
3139 org = msi_reg_get_val_str(props, INSTALLPROPERTY_REGCOMPANYW);
3140 serial = msi_reg_get_val_str(props, INSTALLPROPERTY_PRODUCTIDW);
3141 state = USERINFOSTATE_ABSENT;
3147 state = USERINFOSTATE_PRESENT;
3149 if (pcchUserNameBuf)
3151 if (lpUserNameBuf && !user)
3153 (*pcchUserNameBuf)--;
3157 r = msi_strcpy_to_awstring(user, lpUserNameBuf, pcchUserNameBuf);
3158 if (r == ERROR_MORE_DATA)
3160 state = USERINFOSTATE_MOREDATA;
3168 if (!orgptr) orgptr = szEmpty;
3170 r = msi_strcpy_to_awstring(orgptr, lpOrgNameBuf, pcchOrgNameBuf);
3171 if (r == ERROR_MORE_DATA)
3173 state = USERINFOSTATE_MOREDATA;
3186 r = msi_strcpy_to_awstring(serial, lpSerialBuf, pcchSerialBuf);
3187 if (r == ERROR_MORE_DATA)
3188 state = USERINFOSTATE_MOREDATA;
3199 /***********************************************************************
3200 * MsiGetUserInfoW [MSI.@]
3202 USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct,
3203 LPWSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
3204 LPWSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
3205 LPWSTR lpSerialBuf, LPDWORD pcchSerialBuf)
3207 awstring user, org, serial;
3209 if ((lpUserNameBuf && !pcchUserNameBuf) ||
3210 (lpOrgNameBuf && !pcchOrgNameBuf) ||
3211 (lpSerialBuf && !pcchSerialBuf))
3212 return USERINFOSTATE_INVALIDARG;
3214 user.unicode = TRUE;
3215 user.str.w = lpUserNameBuf;
3217 org.str.w = lpOrgNameBuf;
3218 serial.unicode = TRUE;
3219 serial.str.w = lpSerialBuf;
3221 return MSI_GetUserInfo( szProduct, &user, pcchUserNameBuf,
3222 &org, pcchOrgNameBuf,
3223 &serial, pcchSerialBuf );
3226 USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct,
3227 LPSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
3228 LPSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
3229 LPSTR lpSerialBuf, LPDWORD pcchSerialBuf)
3231 awstring user, org, serial;
3235 if ((lpUserNameBuf && !pcchUserNameBuf) ||
3236 (lpOrgNameBuf && !pcchOrgNameBuf) ||
3237 (lpSerialBuf && !pcchSerialBuf))
3238 return USERINFOSTATE_INVALIDARG;
3240 prod = strdupAtoW( szProduct );
3241 if (szProduct && !prod)
3242 return ERROR_OUTOFMEMORY;
3244 user.unicode = FALSE;
3245 user.str.a = lpUserNameBuf;
3246 org.unicode = FALSE;
3247 org.str.a = lpOrgNameBuf;
3248 serial.unicode = FALSE;
3249 serial.str.a = lpSerialBuf;
3251 r = MSI_GetUserInfo( prod, &user, pcchUserNameBuf,
3252 &org, pcchOrgNameBuf,
3253 &serial, pcchSerialBuf );
3260 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
3264 MSIPACKAGE *package;
3265 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
3267 TRACE("(%s)\n",debugstr_w(szProduct));
3269 rc = MsiOpenProductW(szProduct,&handle);
3270 if (rc != ERROR_SUCCESS)
3271 return ERROR_INVALID_PARAMETER;
3273 /* MsiCollectUserInfo cannot be called from a custom action. */
3274 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
3276 return ERROR_CALL_NOT_IMPLEMENTED;
3278 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
3279 msiobj_release( &package->hdr );
3281 MsiCloseHandle(handle);
3286 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
3290 MSIPACKAGE *package;
3291 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
3293 TRACE("(%s)\n",debugstr_a(szProduct));
3295 rc = MsiOpenProductA(szProduct,&handle);
3296 if (rc != ERROR_SUCCESS)
3297 return ERROR_INVALID_PARAMETER;
3299 /* MsiCollectUserInfo cannot be called from a custom action. */
3300 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
3302 return ERROR_CALL_NOT_IMPLEMENTED;
3304 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
3305 msiobj_release( &package->hdr );
3307 MsiCloseHandle(handle);
3312 /***********************************************************************
3313 * MsiConfigureFeatureA [MSI.@]
3315 UINT WINAPI MsiConfigureFeatureA(LPCSTR szProduct, LPCSTR szFeature, INSTALLSTATE eInstallState)
3317 LPWSTR prod, feat = NULL;
3318 UINT r = ERROR_OUTOFMEMORY;
3320 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature), eInstallState);
3322 prod = strdupAtoW( szProduct );
3323 if (szProduct && !prod)
3326 feat = strdupAtoW( szFeature );
3327 if (szFeature && !feat)
3330 r = MsiConfigureFeatureW(prod, feat, eInstallState);
3339 /***********************************************************************
3340 * MsiConfigureFeatureW [MSI.@]
3342 UINT WINAPI MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLSTATE eInstallState)
3344 static const WCHAR szCostInit[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
3345 MSIPACKAGE *package = NULL;
3347 WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
3350 TRACE("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature), eInstallState);
3352 if (!szProduct || !szFeature)
3353 return ERROR_INVALID_PARAMETER;
3355 switch (eInstallState)
3357 case INSTALLSTATE_DEFAULT:
3358 /* FIXME: how do we figure out the default location? */
3359 eInstallState = INSTALLSTATE_LOCAL;
3361 case INSTALLSTATE_LOCAL:
3362 case INSTALLSTATE_SOURCE:
3363 case INSTALLSTATE_ABSENT:
3364 case INSTALLSTATE_ADVERTISED:
3367 return ERROR_INVALID_PARAMETER;
3370 r = MSI_OpenProductW( szProduct, &package );
3371 if (r != ERROR_SUCCESS)
3374 sz = sizeof(sourcepath);
3375 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3376 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
3378 sz = sizeof(filename);
3379 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3380 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
3382 lstrcatW( sourcepath, filename );
3384 MsiSetInternalUI( INSTALLUILEVEL_BASIC, NULL );
3386 r = ACTION_PerformUIAction( package, szCostInit, -1 );
3387 if (r != ERROR_SUCCESS)
3390 r = MSI_SetFeatureStateW( package, szFeature, eInstallState);
3391 if (r != ERROR_SUCCESS)
3394 r = MSI_InstallPackage( package, sourcepath, NULL );
3397 msiobj_release( &package->hdr );
3402 /***********************************************************************
3403 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3405 * Notes: undocumented
3407 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
3409 WCHAR path[MAX_PATH];
3411 TRACE("%d\n", dwReserved);
3415 FIXME("dwReserved=%d\n", dwReserved);
3416 return ERROR_INVALID_PARAMETER;
3419 if (!GetWindowsDirectoryW(path, MAX_PATH))
3420 return ERROR_FUNCTION_FAILED;
3422 lstrcatW(path, installerW);
3424 if (!CreateDirectoryW(path, NULL))
3425 return ERROR_FUNCTION_FAILED;
3427 return ERROR_SUCCESS;
3430 /***********************************************************************
3431 * MsiGetShortcutTargetA [MSI.@]
3433 UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
3434 LPSTR szProductCode, LPSTR szFeatureId,
3435 LPSTR szComponentCode )
3438 const int len = MAX_FEATURE_CHARS+1;
3439 WCHAR product[MAX_FEATURE_CHARS+1], feature[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1];
3442 target = strdupAtoW( szShortcutTarget );
3443 if (szShortcutTarget && !target )
3444 return ERROR_OUTOFMEMORY;
3448 r = MsiGetShortcutTargetW( target, product, feature, component );
3450 if (r == ERROR_SUCCESS)
3452 WideCharToMultiByte( CP_ACP, 0, product, -1, szProductCode, len, NULL, NULL );
3453 WideCharToMultiByte( CP_ACP, 0, feature, -1, szFeatureId, len, NULL, NULL );
3454 WideCharToMultiByte( CP_ACP, 0, component, -1, szComponentCode, len, NULL, NULL );
3459 /***********************************************************************
3460 * MsiGetShortcutTargetW [MSI.@]
3462 UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
3463 LPWSTR szProductCode, LPWSTR szFeatureId,
3464 LPWSTR szComponentCode )
3466 IShellLinkDataList *dl = NULL;
3467 IPersistFile *pf = NULL;
3468 LPEXP_DARWIN_LINK darwin = NULL;
3471 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget),
3472 szProductCode, szFeatureId, szComponentCode );
3474 init = CoInitialize(NULL);
3476 r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
3477 &IID_IPersistFile, (LPVOID*) &pf );
3478 if( SUCCEEDED( r ) )
3480 r = IPersistFile_Load( pf, szShortcutTarget,
3481 STGM_READ | STGM_SHARE_DENY_WRITE );
3482 if( SUCCEEDED( r ) )
3484 r = IPersistFile_QueryInterface( pf, &IID_IShellLinkDataList,
3486 if( SUCCEEDED( r ) )
3488 IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG,
3490 IShellLinkDataList_Release( dl );
3493 IPersistFile_Release( pf );
3496 if (SUCCEEDED(init))
3499 TRACE("darwin = %p\n", darwin);
3506 ret = MsiDecomposeDescriptorW( darwin->szwDarwinID,
3507 szProductCode, szFeatureId, szComponentCode, &sz );
3508 LocalFree( darwin );
3512 return ERROR_FUNCTION_FAILED;
3515 UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
3516 DWORD dwReinstallMode )
3518 MSIPACKAGE* package = NULL;
3520 WCHAR sourcepath[MAX_PATH];
3521 WCHAR filename[MAX_PATH];
3522 static const WCHAR szLogVerbose[] = {
3523 ' ','L','O','G','V','E','R','B','O','S','E',0 };
3524 WCHAR reinstallmode[11];
3528 FIXME("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
3531 ptr = reinstallmode;
3533 if (dwReinstallMode & REINSTALLMODE_FILEMISSING)
3535 if (dwReinstallMode & REINSTALLMODE_FILEOLDERVERSION)
3537 if (dwReinstallMode & REINSTALLMODE_FILEEQUALVERSION)
3539 if (dwReinstallMode & REINSTALLMODE_FILEEXACT)
3541 if (dwReinstallMode & REINSTALLMODE_FILEVERIFY)
3543 if (dwReinstallMode & REINSTALLMODE_FILEREPLACE)
3545 if (dwReinstallMode & REINSTALLMODE_USERDATA)
3547 if (dwReinstallMode & REINSTALLMODE_MACHINEDATA)
3549 if (dwReinstallMode & REINSTALLMODE_SHORTCUT)
3551 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
3555 sz = sizeof(sourcepath);
3556 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3557 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
3559 sz = sizeof(filename);
3560 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3561 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
3563 lstrcatW( sourcepath, filename );
3565 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
3566 r = MSI_OpenPackageW( sourcepath, &package );
3568 r = MSI_OpenProductW( szProduct, &package );
3570 if (r != ERROR_SUCCESS)
3573 msi_set_property( package->db, szReinstallMode, reinstallmode );
3574 msi_set_property( package->db, szInstalled, szOne );
3575 msi_set_property( package->db, szLogVerbose, szOne );
3576 msi_set_property( package->db, szReinstall, szFeature );
3578 r = MSI_InstallPackage( package, sourcepath, NULL );
3580 msiobj_release( &package->hdr );
3585 UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
3586 DWORD dwReinstallMode )
3592 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
3595 wszProduct = strdupAtoW(szProduct);
3596 wszFeature = strdupAtoW(szFeature);
3598 rc = MsiReinstallFeatureW(wszProduct, wszFeature, dwReinstallMode);
3600 msi_free(wszProduct);
3601 msi_free(wszFeature);
3608 unsigned int buf[4];
3609 unsigned char in[64];
3610 unsigned char digest[16];
3613 extern VOID WINAPI MD5Init( MD5_CTX *);
3614 extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int );
3615 extern VOID WINAPI MD5Final( MD5_CTX *);
3617 /***********************************************************************
3618 * MsiGetFileHashW [MSI.@]
3620 UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
3621 PMSIFILEHASHINFO pHash )
3623 HANDLE handle, mapping;
3626 UINT r = ERROR_FUNCTION_FAILED;
3628 TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
3631 return ERROR_INVALID_PARAMETER;
3634 return ERROR_PATH_NOT_FOUND;
3637 return ERROR_INVALID_PARAMETER;
3639 return ERROR_INVALID_PARAMETER;
3640 if (pHash->dwFileHashInfoSize < sizeof *pHash)
3641 return ERROR_INVALID_PARAMETER;
3643 handle = CreateFileW( szFilePath, GENERIC_READ,
3644 FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
3645 if (handle == INVALID_HANDLE_VALUE)
3646 return ERROR_FILE_NOT_FOUND;
3648 length = GetFileSize( handle, NULL );
3650 mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL );
3653 p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length );
3659 MD5Update( &ctx, p, length );
3661 UnmapViewOfFile( p );
3663 memcpy( pHash->dwData, ctx.digest, sizeof pHash->dwData );
3666 CloseHandle( mapping );
3668 CloseHandle( handle );
3673 /***********************************************************************
3674 * MsiGetFileHashA [MSI.@]
3676 UINT WINAPI MsiGetFileHashA( LPCSTR szFilePath, DWORD dwOptions,
3677 PMSIFILEHASHINFO pHash )
3682 TRACE("%s %08x %p\n", debugstr_a(szFilePath), dwOptions, pHash );
3684 file = strdupAtoW( szFilePath );
3685 if (szFilePath && !file)
3686 return ERROR_OUTOFMEMORY;
3688 r = MsiGetFileHashW( file, dwOptions, pHash );
3693 /***********************************************************************
3694 * MsiAdvertiseScriptW [MSI.@]
3696 UINT WINAPI MsiAdvertiseScriptW( LPCWSTR szScriptFile, DWORD dwFlags,
3697 PHKEY phRegData, BOOL fRemoveItems )
3699 FIXME("%s %08x %p %d\n",
3700 debugstr_w( szScriptFile ), dwFlags, phRegData, fRemoveItems );
3701 return ERROR_CALL_NOT_IMPLEMENTED;
3704 /***********************************************************************
3705 * MsiAdvertiseScriptA [MSI.@]
3707 UINT WINAPI MsiAdvertiseScriptA( LPCSTR szScriptFile, DWORD dwFlags,
3708 PHKEY phRegData, BOOL fRemoveItems )
3710 FIXME("%s %08x %p %d\n",
3711 debugstr_a( szScriptFile ), dwFlags, phRegData, fRemoveItems );
3712 return ERROR_CALL_NOT_IMPLEMENTED;
3715 /***********************************************************************
3716 * MsiIsProductElevatedW [MSI.@]
3718 UINT WINAPI MsiIsProductElevatedW( LPCWSTR szProduct, BOOL *pfElevated )
3720 FIXME("%s %p - stub\n",
3721 debugstr_w( szProduct ), pfElevated );
3723 return ERROR_SUCCESS;
3726 /***********************************************************************
3727 * MsiIsProductElevatedA [MSI.@]
3729 UINT WINAPI MsiIsProductElevatedA( LPCSTR szProduct, BOOL *pfElevated )
3731 FIXME("%s %p - stub\n",
3732 debugstr_a( szProduct ), pfElevated );
3734 return ERROR_SUCCESS;
3737 /***********************************************************************
3738 * MsiSetExternalUIRecord [MSI.@]
3740 UINT WINAPI MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler,
3741 DWORD filter, LPVOID context,
3742 PINSTALLUI_HANDLER_RECORD prev )
3744 TRACE("%p %08x %p %p\n", handler, filter, context, prev);
3747 *prev = gUIHandlerRecord;
3749 gUIHandlerRecord = handler;
3751 gUIContext = context;
3753 return ERROR_SUCCESS;
3756 /***********************************************************************
3757 * MsiInstallMissingComponentW [MSI.@]
3759 UINT WINAPI MsiInstallMissingComponentW(LPCWSTR szProduct, LPCWSTR szComponent, INSTALLSTATE eInstallState)
3761 FIXME("(%s %s %d\n", debugstr_w(szProduct), debugstr_w(szComponent), eInstallState);
3762 return ERROR_SUCCESS;