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 get_patch_product_codes( LPCWSTR szPatchPackage, WCHAR **product_codes )
304 MSIHANDLE patch, info = 0;
307 static WCHAR empty[] = {0};
310 r = MsiOpenDatabaseW( szPatchPackage, MSIDBOPEN_READONLY, &patch );
311 if (r != ERROR_SUCCESS)
314 r = MsiGetSummaryInformationW( patch, NULL, 0, &info );
315 if (r != ERROR_SUCCESS)
319 r = MsiSummaryInfoGetPropertyW( info, PID_TEMPLATE, &type, NULL, NULL, empty, &size );
320 if (r != ERROR_MORE_DATA || !size || type != VT_LPSTR)
322 ERR("Failed to read product codes from patch\n");
323 r = ERROR_FUNCTION_FAILED;
327 codes = msi_alloc( ++size * sizeof(WCHAR) );
330 r = ERROR_OUTOFMEMORY;
334 r = MsiSummaryInfoGetPropertyW( info, PID_TEMPLATE, &type, NULL, NULL, codes, &size );
335 if (r != ERROR_SUCCESS)
338 *product_codes = codes;
341 MsiCloseHandle( info );
342 MsiCloseHandle( patch );
346 static UINT MSI_ApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szProductCode, LPCWSTR szCommandLine)
350 LPCWSTR cmd_ptr = szCommandLine;
351 LPWSTR beg, end, cmd, codes = NULL;
352 BOOL succeeded = FALSE;
354 static const WCHAR patcheq[] = {'P','A','T','C','H','=',0};
355 static WCHAR empty[] = {0};
357 if (!szPatchPackage || !szPatchPackage[0])
358 return ERROR_INVALID_PARAMETER;
360 if (!szProductCode && (r = get_patch_product_codes( szPatchPackage, &codes )))
366 size = lstrlenW(cmd_ptr) + lstrlenW(patcheq) + lstrlenW(szPatchPackage) + 1;
367 cmd = msi_alloc(size * sizeof(WCHAR));
371 return ERROR_OUTOFMEMORY;
374 lstrcpyW(cmd, cmd_ptr);
375 if (szCommandLine) lstrcatW(cmd, szSpace);
376 lstrcatW(cmd, patcheq);
377 lstrcatW(cmd, szPatchPackage);
380 r = MsiConfigureProductExW(szProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
384 while ((end = strchrW(beg, '}')))
387 r = MsiConfigureProductExW(beg, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
388 if (r == ERROR_SUCCESS)
390 TRACE("patch applied\n");
405 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
406 INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
408 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
409 eInstallType, debugstr_w(szCommandLine));
411 if (szInstallPackage || eInstallType == INSTALLTYPE_NETWORK_IMAGE ||
412 eInstallType == INSTALLTYPE_SINGLE_INSTANCE)
414 FIXME("Only reading target products from patch\n");
415 return ERROR_CALL_NOT_IMPLEMENTED;
418 return MSI_ApplyPatchW(szPatchPackage, NULL, szCommandLine);
421 UINT WINAPI MsiApplyMultiplePatchesA(LPCSTR szPatchPackages,
422 LPCSTR szProductCode, LPCSTR szPropertiesList)
424 LPWSTR patch_packages = NULL;
425 LPWSTR product_code = NULL;
426 LPWSTR properties_list = NULL;
427 UINT r = ERROR_OUTOFMEMORY;
429 TRACE("%s %s %s\n", debugstr_a(szPatchPackages), debugstr_a(szProductCode),
430 debugstr_a(szPropertiesList));
432 if (!szPatchPackages || !szPatchPackages[0])
433 return ERROR_INVALID_PARAMETER;
435 if (!(patch_packages = strdupAtoW(szPatchPackages)))
436 return ERROR_OUTOFMEMORY;
438 if (szProductCode && !(product_code = strdupAtoW(szProductCode)))
441 if (szPropertiesList && !(properties_list = strdupAtoW(szPropertiesList)))
444 r = MsiApplyMultiplePatchesW(patch_packages, product_code, properties_list);
447 msi_free(patch_packages);
448 msi_free(product_code);
449 msi_free(properties_list);
454 UINT WINAPI MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages,
455 LPCWSTR szProductCode, LPCWSTR szPropertiesList)
457 UINT r = ERROR_SUCCESS;
460 TRACE("%s %s %s\n", debugstr_w(szPatchPackages), debugstr_w(szProductCode),
461 debugstr_w(szPropertiesList));
463 if (!szPatchPackages || !szPatchPackages[0])
464 return ERROR_INVALID_PARAMETER;
466 beg = end = szPatchPackages;
472 while (*beg == ' ') beg++;
473 while (*end && *end != ';') end++;
476 while (len && beg[len - 1] == ' ') len--;
478 if (!len) return ERROR_INVALID_NAME;
480 patch = msi_alloc((len + 1) * sizeof(WCHAR));
482 return ERROR_OUTOFMEMORY;
484 memcpy(patch, beg, len * sizeof(WCHAR));
487 r = MSI_ApplyPatchW(patch, szProductCode, szPropertiesList);
490 if (r != ERROR_SUCCESS)
498 UINT WINAPI MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath,
499 DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOA pPatchInfo)
502 WCHAR *package_path = NULL;
503 MSIPATCHSEQUENCEINFOW *psi;
505 TRACE("(%s, %d, %p)\n", debugstr_a(szProductPackagePath), cPatchInfo, pPatchInfo);
507 if (szProductPackagePath && !(package_path = strdupAtoW( szProductPackagePath )))
508 return ERROR_OUTOFMEMORY;
510 psi = msi_alloc( cPatchInfo * sizeof(*psi) );
513 msi_free( package_path );
514 return ERROR_OUTOFMEMORY;
517 for (i = 0; i < cPatchInfo; i++)
519 psi[i].szPatchData = strdupAtoW( pPatchInfo[i].szPatchData );
520 psi[i].ePatchDataType = pPatchInfo[i].ePatchDataType;
523 r = MsiDetermineApplicablePatchesW( package_path, cPatchInfo, psi );
524 if (r == ERROR_SUCCESS)
526 for (i = 0; i < cPatchInfo; i++)
528 pPatchInfo[i].dwOrder = psi[i].dwOrder;
529 pPatchInfo[i].uStatus = psi[i].uStatus;
533 msi_free( package_path );
534 for (i = 0; i < cPatchInfo; i++)
535 msi_free( (WCHAR *)psi[i].szPatchData );
540 static UINT MSI_ApplicablePatchW( MSIPACKAGE *package, LPCWSTR patch )
543 MSIDATABASE *patch_db;
544 UINT r = ERROR_SUCCESS;
546 r = MSI_OpenDatabaseW( patch, MSIDBOPEN_READONLY, &patch_db );
547 if (r != ERROR_SUCCESS)
549 WARN("failed to open patch file %s\n", debugstr_w(patch));
553 si = MSI_GetSummaryInformationW( patch_db->storage, 0 );
556 msiobj_release( &patch_db->hdr );
557 return ERROR_FUNCTION_FAILED;
560 r = msi_check_patch_applicable( package, si );
561 if (r != ERROR_SUCCESS)
562 TRACE("patch not applicable\n");
564 msiobj_release( &patch_db->hdr );
565 msiobj_release( &si->hdr );
569 UINT WINAPI MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath,
570 DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOW pPatchInfo)
572 UINT i, r, ret = ERROR_FUNCTION_FAILED;
575 TRACE("(%s, %d, %p)\n", debugstr_w(szProductPackagePath), cPatchInfo, pPatchInfo);
577 r = MSI_OpenPackageW( szProductPackagePath, &package );
578 if (r != ERROR_SUCCESS)
580 ERR("failed to open package %u\n", r);
584 for (i = 0; i < cPatchInfo; i++)
586 switch (pPatchInfo[i].ePatchDataType)
588 case MSIPATCH_DATATYPE_PATCHFILE:
590 FIXME("patch ordering not supported\n");
591 r = MSI_ApplicablePatchW( package, pPatchInfo[i].szPatchData );
592 if (r != ERROR_SUCCESS)
594 pPatchInfo[i].dwOrder = ~0u;
595 pPatchInfo[i].uStatus = ERROR_PATCH_TARGET_NOT_FOUND;
599 pPatchInfo[i].dwOrder = i;
600 pPatchInfo[i].uStatus = ret = ERROR_SUCCESS;
606 FIXME("patch data type %u not supported\n", pPatchInfo[i].ePatchDataType);
607 pPatchInfo[i].dwOrder = ~0u;
608 pPatchInfo[i].uStatus = ERROR_PATCH_TARGET_NOT_FOUND;
613 TRACE(" szPatchData: %s\n", debugstr_w(pPatchInfo[i].szPatchData));
614 TRACE("ePatchDataType: %u\n", pPatchInfo[i].ePatchDataType);
615 TRACE(" dwOrder: %u\n", pPatchInfo[i].dwOrder);
616 TRACE(" uStatus: %u\n", pPatchInfo[i].uStatus);
621 UINT WINAPI MsiDeterminePatchSequenceA(LPCSTR szProductCode, LPCSTR szUserSid,
622 MSIINSTALLCONTEXT dwContext, DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOA pPatchInfo)
624 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_a(szProductCode),
625 debugstr_a(szUserSid), dwContext, cPatchInfo, pPatchInfo);
627 return ERROR_CALL_NOT_IMPLEMENTED;
630 UINT WINAPI MsiDeterminePatchSequenceW(LPCWSTR szProductCode, LPCWSTR szUserSid,
631 MSIINSTALLCONTEXT dwContext, DWORD cPatchInfo, PMSIPATCHSEQUENCEINFOW pPatchInfo)
633 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_w(szProductCode),
634 debugstr_w(szUserSid), dwContext, cPatchInfo, pPatchInfo);
636 return ERROR_CALL_NOT_IMPLEMENTED;
639 static UINT msi_open_package(LPCWSTR product, MSIINSTALLCONTEXT context,
640 MSIPACKAGE **package)
646 WCHAR sourcepath[MAX_PATH];
647 WCHAR filename[MAX_PATH];
649 r = MSIREG_OpenInstallProps(product, context, NULL, &props, FALSE);
650 if (r != ERROR_SUCCESS)
651 return ERROR_BAD_CONFIGURATION;
653 localpack = msi_reg_get_val_str(props, szLocalPackage);
656 lstrcpyW(sourcepath, localpack);
660 if (!localpack || GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES)
662 sz = sizeof(sourcepath);
663 MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT,
664 INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
666 sz = sizeof(filename);
667 MsiSourceListGetInfoW(product, NULL, context, MSICODE_PRODUCT,
668 INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
670 lstrcatW(sourcepath, filename);
673 if (GetFileAttributesW(sourcepath) == INVALID_FILE_ATTRIBUTES)
674 return ERROR_INSTALL_SOURCE_ABSENT;
676 return MSI_OpenPackageW(sourcepath, package);
679 UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
680 INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
682 MSIPACKAGE* package = NULL;
683 MSIINSTALLCONTEXT context;
686 WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
689 static const WCHAR szInstalled[] = {
690 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
691 static const WCHAR szRemoveAll[] = {
692 ' ','R','E','M','O','V','E','=','A','L','L',0};
693 static const WCHAR szMachine[] = {
694 ' ','A','L','L','U','S','E','R','S','=','1',0};
696 TRACE("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
697 debugstr_w(szCommandLine));
699 if (!szProduct || lstrlenW(szProduct) != GUID_SIZE - 1)
700 return ERROR_INVALID_PARAMETER;
702 if (eInstallState == INSTALLSTATE_ADVERTISED ||
703 eInstallState == INSTALLSTATE_SOURCE)
705 FIXME("State %d not implemented\n", eInstallState);
706 return ERROR_CALL_NOT_IMPLEMENTED;
709 r = msi_locate_product(szProduct, &context);
710 if (r != ERROR_SUCCESS)
713 r = msi_open_package(szProduct, context, &package);
714 if (r != ERROR_SUCCESS)
717 sz = lstrlenW(szInstalled) + 1;
720 sz += lstrlenW(szCommandLine);
722 if (eInstallState == INSTALLSTATE_ABSENT)
723 sz += lstrlenW(szRemoveAll);
725 if (context == MSIINSTALLCONTEXT_MACHINE)
726 sz += lstrlenW(szMachine);
728 commandline = msi_alloc(sz * sizeof(WCHAR));
731 r = ERROR_OUTOFMEMORY;
737 lstrcpyW(commandline,szCommandLine);
739 if (eInstallState == INSTALLSTATE_ABSENT)
740 lstrcatW(commandline, szRemoveAll);
742 if (context == MSIINSTALLCONTEXT_MACHINE)
743 lstrcatW(commandline, szMachine);
745 sz = sizeof(sourcepath);
746 MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT,
747 INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
749 sz = sizeof(filename);
750 MsiSourceListGetInfoW(szProduct, NULL, context, MSICODE_PRODUCT,
751 INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
753 strcatW(sourcepath, filename);
755 r = MSI_InstallPackage( package, sourcepath, commandline );
757 msi_free(commandline);
760 msiobj_release( &package->hdr );
765 UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
766 INSTALLSTATE eInstallState, LPCSTR szCommandLine)
768 LPWSTR szwProduct = NULL;
769 LPWSTR szwCommandLine = NULL;
770 UINT r = ERROR_OUTOFMEMORY;
774 szwProduct = strdupAtoW( szProduct );
781 szwCommandLine = strdupAtoW( szCommandLine );
786 r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
789 msi_free( szwProduct );
790 msi_free( szwCommandLine);
795 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
796 INSTALLSTATE eInstallState)
798 LPWSTR szwProduct = NULL;
801 TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
805 szwProduct = strdupAtoW( szProduct );
807 return ERROR_OUTOFMEMORY;
810 r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
811 msi_free( szwProduct );
816 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
817 INSTALLSTATE eInstallState)
819 return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
822 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
824 LPWSTR szwComponent = NULL;
826 WCHAR szwBuffer[GUID_SIZE];
828 TRACE("%s %p\n", debugstr_a(szComponent), szBuffer);
832 szwComponent = strdupAtoW( szComponent );
834 return ERROR_OUTOFMEMORY;
838 r = MsiGetProductCodeW( szwComponent, szwBuffer );
841 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
843 msi_free( szwComponent );
848 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
851 HKEY compkey, prodkey;
852 WCHAR squished_comp[GUID_SIZE];
853 WCHAR squished_prod[GUID_SIZE];
854 DWORD sz = GUID_SIZE;
856 TRACE("%s %p\n", debugstr_w(szComponent), szBuffer);
858 if (!szComponent || !*szComponent)
859 return ERROR_INVALID_PARAMETER;
861 if (!squash_guid(szComponent, squished_comp))
862 return ERROR_INVALID_PARAMETER;
864 if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &compkey, FALSE) != ERROR_SUCCESS &&
865 MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &compkey, FALSE) != ERROR_SUCCESS)
867 return ERROR_UNKNOWN_COMPONENT;
870 rc = RegEnumValueW(compkey, 0, squished_prod, &sz, NULL, NULL, NULL, NULL);
871 if (rc != ERROR_SUCCESS)
873 RegCloseKey(compkey);
874 return ERROR_UNKNOWN_COMPONENT;
877 /* check simple case, only one product */
878 rc = RegEnumValueW(compkey, 1, squished_prod, &sz, NULL, NULL, NULL, NULL);
879 if (rc == ERROR_NO_MORE_ITEMS)
886 while ((rc = RegEnumValueW(compkey, index, squished_prod, &sz,
887 NULL, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS)
891 unsquash_guid(squished_prod, szBuffer);
893 if (MSIREG_OpenProductKey(szBuffer, NULL,
894 MSIINSTALLCONTEXT_USERMANAGED,
895 &prodkey, FALSE) == ERROR_SUCCESS ||
896 MSIREG_OpenProductKey(szBuffer, NULL,
897 MSIINSTALLCONTEXT_USERUNMANAGED,
898 &prodkey, FALSE) == ERROR_SUCCESS ||
899 MSIREG_OpenProductKey(szBuffer, NULL,
900 MSIINSTALLCONTEXT_MACHINE,
901 &prodkey, FALSE) == ERROR_SUCCESS)
903 RegCloseKey(prodkey);
909 rc = ERROR_INSTALL_FAILURE;
912 RegCloseKey(compkey);
913 unsquash_guid(squished_prod, szBuffer);
917 static LPWSTR msi_reg_get_value(HKEY hkey, LPCWSTR name, DWORD *type)
923 static const WCHAR format[] = {'%','d',0};
925 res = RegQueryValueExW(hkey, name, NULL, type, NULL, NULL);
926 if (res != ERROR_SUCCESS)
930 return msi_reg_get_val_str(hkey, name);
932 if (!msi_reg_get_val_dword(hkey, name, &dval))
935 sprintfW(temp, format, dval);
936 return strdupW(temp);
939 static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
940 awstring *szValue, LPDWORD pcchValueBuf)
942 MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
943 UINT r = ERROR_UNKNOWN_PROPERTY;
944 HKEY prodkey, userdata, source;
946 WCHAR squished_pc[GUID_SIZE];
947 WCHAR packagecode[GUID_SIZE];
948 BOOL badconfig = FALSE;
950 DWORD type = REG_NONE;
952 static WCHAR empty[] = {0};
953 static const WCHAR sourcelist[] = {
954 'S','o','u','r','c','e','L','i','s','t',0};
955 static const WCHAR display_name[] = {
956 'D','i','s','p','l','a','y','N','a','m','e',0};
957 static const WCHAR display_version[] = {
958 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
959 static const WCHAR assignment[] = {
960 'A','s','s','i','g','n','m','e','n','t',0};
962 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
963 debugstr_w(szAttribute), szValue, pcchValueBuf);
965 if ((szValue->str.w && !pcchValueBuf) || !szProduct || !szAttribute)
966 return ERROR_INVALID_PARAMETER;
968 if (!squash_guid(szProduct, squished_pc))
969 return ERROR_INVALID_PARAMETER;
971 if ((r = MSIREG_OpenProductKey(szProduct, NULL,
972 MSIINSTALLCONTEXT_USERMANAGED,
973 &prodkey, FALSE)) != ERROR_SUCCESS &&
974 (r = MSIREG_OpenProductKey(szProduct, NULL,
975 MSIINSTALLCONTEXT_USERUNMANAGED,
976 &prodkey, FALSE)) != ERROR_SUCCESS &&
977 (r = MSIREG_OpenProductKey(szProduct, NULL,
978 MSIINSTALLCONTEXT_MACHINE,
979 &prodkey, FALSE)) == ERROR_SUCCESS)
981 context = MSIINSTALLCONTEXT_MACHINE;
984 MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE);
986 if (!strcmpW( szAttribute, INSTALLPROPERTY_HELPLINKW ) ||
987 !strcmpW( szAttribute, INSTALLPROPERTY_HELPTELEPHONEW ) ||
988 !strcmpW( szAttribute, INSTALLPROPERTY_INSTALLDATEW ) ||
989 !strcmpW( szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ) ||
990 !strcmpW( szAttribute, INSTALLPROPERTY_INSTALLLOCATIONW ) ||
991 !strcmpW( szAttribute, INSTALLPROPERTY_INSTALLSOURCEW ) ||
992 !strcmpW( szAttribute, INSTALLPROPERTY_LOCALPACKAGEW ) ||
993 !strcmpW( szAttribute, INSTALLPROPERTY_PUBLISHERW ) ||
994 !strcmpW( szAttribute, INSTALLPROPERTY_URLINFOABOUTW ) ||
995 !strcmpW( szAttribute, INSTALLPROPERTY_URLUPDATEINFOW ) ||
996 !strcmpW( szAttribute, INSTALLPROPERTY_VERSIONMINORW ) ||
997 !strcmpW( szAttribute, INSTALLPROPERTY_VERSIONMAJORW ) ||
998 !strcmpW( szAttribute, INSTALLPROPERTY_VERSIONSTRINGW ) ||
999 !strcmpW( szAttribute, INSTALLPROPERTY_PRODUCTIDW ) ||
1000 !strcmpW( szAttribute, INSTALLPROPERTY_REGCOMPANYW ) ||
1001 !strcmpW( szAttribute, INSTALLPROPERTY_REGOWNERW ))
1005 r = ERROR_UNKNOWN_PRODUCT;
1010 return ERROR_UNKNOWN_PROPERTY;
1012 if (!strcmpW( szAttribute, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ))
1013 szAttribute = display_name;
1014 else if (!strcmpW( szAttribute, INSTALLPROPERTY_VERSIONSTRINGW ))
1015 szAttribute = display_version;
1017 val = msi_reg_get_value(userdata, szAttribute, &type);
1021 else if (!strcmpW( szAttribute, INSTALLPROPERTY_INSTANCETYPEW ) ||
1022 !strcmpW( szAttribute, INSTALLPROPERTY_TRANSFORMSW ) ||
1023 !strcmpW( szAttribute, INSTALLPROPERTY_LANGUAGEW ) ||
1024 !strcmpW( szAttribute, INSTALLPROPERTY_PRODUCTNAMEW ) ||
1025 !strcmpW( szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW ) ||
1026 !strcmpW( szAttribute, INSTALLPROPERTY_PACKAGECODEW ) ||
1027 !strcmpW( szAttribute, INSTALLPROPERTY_VERSIONW ) ||
1028 !strcmpW( szAttribute, INSTALLPROPERTY_PRODUCTICONW ) ||
1029 !strcmpW( szAttribute, INSTALLPROPERTY_PACKAGENAMEW ) ||
1030 !strcmpW( szAttribute, INSTALLPROPERTY_AUTHORIZED_LUA_APPW ))
1034 r = ERROR_UNKNOWN_PRODUCT;
1038 if (!strcmpW( szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW ))
1039 szAttribute = assignment;
1041 if (!strcmpW( szAttribute, INSTALLPROPERTY_PACKAGENAMEW ))
1043 res = RegOpenKeyW(prodkey, sourcelist, &source);
1044 if (res != ERROR_SUCCESS)
1046 r = ERROR_UNKNOWN_PRODUCT;
1050 val = msi_reg_get_value(source, szAttribute, &type);
1054 RegCloseKey(source);
1058 val = msi_reg_get_value(prodkey, szAttribute, &type);
1063 if (val != empty && type != REG_DWORD &&
1064 !strcmpW( szAttribute, INSTALLPROPERTY_PACKAGECODEW ))
1066 if (lstrlenW(val) != SQUISH_GUID_SIZE - 1)
1070 unsquash_guid(val, packagecode);
1072 val = strdupW(packagecode);
1079 r = ERROR_UNKNOWN_PROPERTY;
1085 /* If szBuffer (szValue->str) is NULL, there's no need to copy the value
1086 * out. Also, *pcchValueBuf may be uninitialized in this case, so we
1087 * can't rely on its value.
1089 if (szValue->str.a || szValue->str.w)
1091 DWORD size = *pcchValueBuf;
1092 if (strlenW(val) < size)
1093 r = msi_strcpy_to_awstring(val, szValue, &size);
1096 r = ERROR_MORE_DATA;
1101 *pcchValueBuf = lstrlenW(val);
1105 r = ERROR_BAD_CONFIGURATION;
1111 RegCloseKey(prodkey);
1112 RegCloseKey(userdata);
1116 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
1117 LPSTR szBuffer, LPDWORD pcchValueBuf)
1119 LPWSTR szwProduct, szwAttribute = NULL;
1120 UINT r = ERROR_OUTOFMEMORY;
1123 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
1124 szBuffer, pcchValueBuf);
1126 szwProduct = strdupAtoW( szProduct );
1127 if( szProduct && !szwProduct )
1130 szwAttribute = strdupAtoW( szAttribute );
1131 if( szAttribute && !szwAttribute )
1134 buffer.unicode = FALSE;
1135 buffer.str.a = szBuffer;
1137 r = MSI_GetProductInfo( szwProduct, szwAttribute,
1138 &buffer, pcchValueBuf );
1141 msi_free( szwProduct );
1142 msi_free( szwAttribute );
1147 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
1148 LPWSTR szBuffer, LPDWORD pcchValueBuf)
1152 TRACE("%s %s %p %p\n", debugstr_w(szProduct), debugstr_w(szAttribute),
1153 szBuffer, pcchValueBuf);
1155 buffer.unicode = TRUE;
1156 buffer.str.w = szBuffer;
1158 return MSI_GetProductInfo( szProduct, szAttribute,
1159 &buffer, pcchValueBuf );
1162 UINT WINAPI MsiGetProductInfoExA(LPCSTR szProductCode, LPCSTR szUserSid,
1163 MSIINSTALLCONTEXT dwContext, LPCSTR szProperty,
1164 LPSTR szValue, LPDWORD pcchValue)
1166 LPWSTR product = NULL;
1167 LPWSTR usersid = NULL;
1168 LPWSTR property = NULL;
1169 LPWSTR value = NULL;
1173 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode),
1174 debugstr_a(szUserSid), dwContext, debugstr_a(szProperty),
1175 szValue, pcchValue);
1177 if (szValue && !pcchValue)
1178 return ERROR_INVALID_PARAMETER;
1180 if (szProductCode) product = strdupAtoW(szProductCode);
1181 if (szUserSid) usersid = strdupAtoW(szUserSid);
1182 if (szProperty) property = strdupAtoW(szProperty);
1184 r = MsiGetProductInfoExW(product, usersid, dwContext, property,
1186 if (r != ERROR_SUCCESS)
1189 value = msi_alloc(++len * sizeof(WCHAR));
1192 r = ERROR_OUTOFMEMORY;
1196 r = MsiGetProductInfoExW(product, usersid, dwContext, property,
1198 if (r != ERROR_SUCCESS)
1204 len = WideCharToMultiByte(CP_ACP, 0, value, -1, NULL, 0, NULL, NULL);
1205 if (*pcchValue >= len)
1206 WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, len, NULL, NULL);
1209 r = ERROR_MORE_DATA;
1214 if (*pcchValue <= len || !szValue)
1215 len = len * sizeof(WCHAR) - 1;
1217 *pcchValue = len - 1;
1228 static UINT msi_copy_outval(LPWSTR val, LPWSTR out, LPDWORD size)
1230 UINT r = ERROR_SUCCESS;
1233 return ERROR_UNKNOWN_PROPERTY;
1237 if (strlenW(val) >= *size)
1239 r = ERROR_MORE_DATA;
1248 *size = lstrlenW(val);
1253 UINT WINAPI MsiGetProductInfoExW(LPCWSTR szProductCode, LPCWSTR szUserSid,
1254 MSIINSTALLCONTEXT dwContext, LPCWSTR szProperty,
1255 LPWSTR szValue, LPDWORD pcchValue)
1257 WCHAR squished_pc[GUID_SIZE];
1259 LPCWSTR package = NULL;
1260 HKEY props = NULL, prod;
1261 HKEY classes = NULL, managed;
1264 UINT r = ERROR_UNKNOWN_PRODUCT;
1266 static const WCHAR five[] = {'5',0};
1267 static const WCHAR displayname[] = {
1268 'D','i','s','p','l','a','y','N','a','m','e',0};
1269 static const WCHAR displayversion[] = {
1270 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1271 static const WCHAR managed_local_package[] = {
1272 'M','a','n','a','g','e','d','L','o','c','a','l',
1273 'P','a','c','k','a','g','e',0};
1275 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode),
1276 debugstr_w(szUserSid), dwContext, debugstr_w(szProperty),
1277 szValue, pcchValue);
1279 if (!szProductCode || !squash_guid(szProductCode, squished_pc))
1280 return ERROR_INVALID_PARAMETER;
1282 if (szValue && !pcchValue)
1283 return ERROR_INVALID_PARAMETER;
1285 if (dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
1286 dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
1287 dwContext != MSIINSTALLCONTEXT_MACHINE)
1288 return ERROR_INVALID_PARAMETER;
1290 if (!szProperty || !*szProperty)
1291 return ERROR_INVALID_PARAMETER;
1293 if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
1294 return ERROR_INVALID_PARAMETER;
1296 /* FIXME: dwContext is provided, no need to search for it */
1297 MSIREG_OpenProductKey(szProductCode, NULL,MSIINSTALLCONTEXT_USERMANAGED,
1299 MSIREG_OpenProductKey(szProductCode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1302 MSIREG_OpenInstallProps(szProductCode, dwContext, NULL, &props, FALSE);
1304 if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
1306 package = INSTALLPROPERTY_LOCALPACKAGEW;
1308 if (!props && !prod)
1311 else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1313 package = managed_local_package;
1315 if (!props && !managed)
1318 else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1320 package = INSTALLPROPERTY_LOCALPACKAGEW;
1321 MSIREG_OpenProductKey(szProductCode, NULL, dwContext, &classes, FALSE);
1323 if (!props && !classes)
1327 if (!strcmpW( szProperty, INSTALLPROPERTY_HELPLINKW ) ||
1328 !strcmpW( szProperty, INSTALLPROPERTY_HELPTELEPHONEW ) ||
1329 !strcmpW( szProperty, INSTALLPROPERTY_INSTALLDATEW ) ||
1330 !strcmpW( szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ) ||
1331 !strcmpW( szProperty, INSTALLPROPERTY_INSTALLLOCATIONW ) ||
1332 !strcmpW( szProperty, INSTALLPROPERTY_INSTALLSOURCEW ) ||
1333 !strcmpW( szProperty, INSTALLPROPERTY_LOCALPACKAGEW ) ||
1334 !strcmpW( szProperty, INSTALLPROPERTY_PUBLISHERW ) ||
1335 !strcmpW( szProperty, INSTALLPROPERTY_URLINFOABOUTW ) ||
1336 !strcmpW( szProperty, INSTALLPROPERTY_URLUPDATEINFOW ) ||
1337 !strcmpW( szProperty, INSTALLPROPERTY_VERSIONMINORW ) ||
1338 !strcmpW( szProperty, INSTALLPROPERTY_VERSIONMAJORW ) ||
1339 !strcmpW( szProperty, INSTALLPROPERTY_VERSIONSTRINGW ) ||
1340 !strcmpW( szProperty, INSTALLPROPERTY_PRODUCTIDW ) ||
1341 !strcmpW( szProperty, INSTALLPROPERTY_REGCOMPANYW ) ||
1342 !strcmpW( szProperty, INSTALLPROPERTY_REGOWNERW ) ||
1343 !strcmpW( szProperty, INSTALLPROPERTY_INSTANCETYPEW ))
1345 val = msi_reg_get_value(props, package, &type);
1348 if (prod || classes)
1349 r = ERROR_UNKNOWN_PROPERTY;
1356 if (!strcmpW( szProperty, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW ))
1357 szProperty = displayname;
1358 else if (!strcmpW( szProperty, INSTALLPROPERTY_VERSIONSTRINGW ))
1359 szProperty = displayversion;
1361 val = msi_reg_get_value(props, szProperty, &type);
1363 val = strdupW(szEmpty);
1365 r = msi_copy_outval(val, szValue, pcchValue);
1367 else if (!strcmpW( szProperty, INSTALLPROPERTY_TRANSFORMSW ) ||
1368 !strcmpW( szProperty, INSTALLPROPERTY_LANGUAGEW ) ||
1369 !strcmpW( szProperty, INSTALLPROPERTY_PRODUCTNAMEW ) ||
1370 !strcmpW( szProperty, INSTALLPROPERTY_PACKAGECODEW ) ||
1371 !strcmpW( szProperty, INSTALLPROPERTY_VERSIONW ) ||
1372 !strcmpW( szProperty, INSTALLPROPERTY_PRODUCTICONW ) ||
1373 !strcmpW( szProperty, INSTALLPROPERTY_PACKAGENAMEW ) ||
1374 !strcmpW( szProperty, INSTALLPROPERTY_AUTHORIZED_LUA_APPW ))
1376 if (!prod && !classes)
1379 if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED)
1381 else if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1383 else if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1386 val = msi_reg_get_value(hkey, szProperty, &type);
1388 val = strdupW(szEmpty);
1390 r = msi_copy_outval(val, szValue, pcchValue);
1392 else if (!strcmpW( szProperty, INSTALLPROPERTY_PRODUCTSTATEW ))
1394 if (dwContext == MSIINSTALLCONTEXT_MACHINE)
1398 val = msi_reg_get_value(props, package, &type);
1403 val = strdupW(five);
1406 val = strdupW(szOne);
1408 r = msi_copy_outval(val, szValue, pcchValue);
1411 else if (props && (val = msi_reg_get_value(props, package, &type)))
1414 val = strdupW(five);
1415 r = msi_copy_outval(val, szValue, pcchValue);
1419 if (prod || managed)
1420 val = strdupW(szOne);
1424 r = msi_copy_outval(val, szValue, pcchValue);
1426 else if (!strcmpW( szProperty, INSTALLPROPERTY_ASSIGNMENTTYPEW ))
1428 if (!prod && !classes)
1432 val = strdupW(szEmpty);
1433 r = msi_copy_outval(val, szValue, pcchValue);
1436 r = ERROR_UNKNOWN_PROPERTY;
1441 RegCloseKey(managed);
1442 RegCloseKey(classes);
1448 UINT WINAPI MsiGetPatchInfoExA(LPCSTR szPatchCode, LPCSTR szProductCode,
1449 LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1450 LPCSTR szProperty, LPSTR lpValue, DWORD *pcchValue)
1452 LPWSTR patch = NULL, product = NULL, usersid = NULL;
1453 LPWSTR property = NULL, val = NULL;
1457 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode),
1458 debugstr_a(szProductCode), debugstr_a(szUserSid), dwContext,
1459 debugstr_a(szProperty), lpValue, pcchValue);
1461 if (lpValue && !pcchValue)
1462 return ERROR_INVALID_PARAMETER;
1464 if (szPatchCode) patch = strdupAtoW(szPatchCode);
1465 if (szProductCode) product = strdupAtoW(szProductCode);
1466 if (szUserSid) usersid = strdupAtoW(szUserSid);
1467 if (szProperty) property = strdupAtoW(szProperty);
1470 r = MsiGetPatchInfoExW(patch, product, usersid, dwContext, property,
1472 if (r != ERROR_SUCCESS)
1475 val = msi_alloc(++len * sizeof(WCHAR));
1478 r = ERROR_OUTOFMEMORY;
1482 r = MsiGetPatchInfoExW(patch, product, usersid, dwContext, property,
1484 if (r != ERROR_SUCCESS || !pcchValue)
1488 WideCharToMultiByte(CP_ACP, 0, val, -1, lpValue,
1489 *pcchValue - 1, NULL, NULL);
1491 len = lstrlenW(val);
1492 if ((*val && *pcchValue < len + 1) || !lpValue)
1496 r = ERROR_MORE_DATA;
1497 lpValue[*pcchValue - 1] = '\0';
1500 *pcchValue = len * sizeof(WCHAR);
1515 UINT WINAPI MsiGetPatchInfoExW(LPCWSTR szPatchCode, LPCWSTR szProductCode,
1516 LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1517 LPCWSTR szProperty, LPWSTR lpValue, DWORD *pcchValue)
1519 WCHAR squished_pc[GUID_SIZE];
1520 WCHAR squished_patch[GUID_SIZE];
1521 HKEY udprod = 0, prod = 0, props = 0;
1522 HKEY patch = 0, patches = 0;
1523 HKEY udpatch = 0, datakey = 0;
1524 HKEY prodpatches = 0;
1526 UINT r = ERROR_UNKNOWN_PRODUCT;
1530 static const WCHAR szManagedPackage[] = {'M','a','n','a','g','e','d',
1531 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1533 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode),
1534 debugstr_w(szProductCode), debugstr_w(szUserSid), dwContext,
1535 debugstr_w(szProperty), lpValue, pcchValue);
1537 if (!szProductCode || !squash_guid(szProductCode, squished_pc))
1538 return ERROR_INVALID_PARAMETER;
1540 if (!szPatchCode || !squash_guid(szPatchCode, squished_patch))
1541 return ERROR_INVALID_PARAMETER;
1544 return ERROR_INVALID_PARAMETER;
1546 if (lpValue && !pcchValue)
1547 return ERROR_INVALID_PARAMETER;
1549 if (dwContext != MSIINSTALLCONTEXT_USERMANAGED &&
1550 dwContext != MSIINSTALLCONTEXT_USERUNMANAGED &&
1551 dwContext != MSIINSTALLCONTEXT_MACHINE)
1552 return ERROR_INVALID_PARAMETER;
1554 if (dwContext == MSIINSTALLCONTEXT_MACHINE && szUserSid)
1555 return ERROR_INVALID_PARAMETER;
1557 if (szUserSid && !strcmpW( szUserSid, szLocalSid ))
1558 return ERROR_INVALID_PARAMETER;
1560 if (MSIREG_OpenUserDataProductKey(szProductCode, dwContext, NULL,
1561 &udprod, FALSE) != ERROR_SUCCESS)
1564 if (MSIREG_OpenInstallProps(szProductCode, dwContext, NULL,
1565 &props, FALSE) != ERROR_SUCCESS)
1568 r = ERROR_UNKNOWN_PATCH;
1570 res = RegOpenKeyExW(udprod, szPatches, 0, KEY_READ, &patches);
1571 if (res != ERROR_SUCCESS)
1574 res = RegOpenKeyExW(patches, squished_patch, 0, KEY_READ, &patch);
1575 if (res != ERROR_SUCCESS)
1578 if (!strcmpW( szProperty, INSTALLPROPERTY_TRANSFORMSW ))
1580 if (MSIREG_OpenProductKey(szProductCode, NULL, dwContext,
1581 &prod, FALSE) != ERROR_SUCCESS)
1584 res = RegOpenKeyExW(prod, szPatches, 0, KEY_ALL_ACCESS, &prodpatches);
1585 if (res != ERROR_SUCCESS)
1588 datakey = prodpatches;
1589 szProperty = squished_patch;
1593 if (MSIREG_OpenUserDataPatchKey(szPatchCode, dwContext,
1594 &udpatch, FALSE) != ERROR_SUCCESS)
1597 if (!strcmpW( szProperty, INSTALLPROPERTY_LOCALPACKAGEW ))
1599 if (dwContext == MSIINSTALLCONTEXT_USERMANAGED)
1600 szProperty = szManagedPackage;
1603 else if (!strcmpW( szProperty, INSTALLPROPERTY_INSTALLDATEW ))
1606 szProperty = szInstalled;
1608 else if (!strcmpW( szProperty, INSTALLPROPERTY_LOCALPACKAGEW ))
1612 else if (!strcmpW( szProperty, INSTALLPROPERTY_UNINSTALLABLEW ) ||
1613 !strcmpW( szProperty, INSTALLPROPERTY_PATCHSTATEW ) ||
1614 !strcmpW( szProperty, INSTALLPROPERTY_DISPLAYNAMEW ) ||
1615 !strcmpW( szProperty, INSTALLPROPERTY_MOREINFOURLW ))
1621 r = ERROR_UNKNOWN_PROPERTY;
1626 val = msi_reg_get_val_str(datakey, szProperty);
1628 val = strdupW(szEmpty);
1636 lstrcpynW(lpValue, val, *pcchValue);
1638 len = lstrlenW(val);
1639 if ((*val && *pcchValue < len + 1) || !lpValue)
1642 r = ERROR_MORE_DATA;
1644 *pcchValue = len * sizeof(WCHAR);
1651 RegCloseKey(prodpatches);
1654 RegCloseKey(patches);
1655 RegCloseKey(udpatch);
1657 RegCloseKey(udprod);
1662 UINT WINAPI MsiGetPatchInfoA( LPCSTR patch, LPCSTR attr, LPSTR buffer, LPDWORD buflen )
1664 UINT r = ERROR_OUTOFMEMORY;
1666 LPWSTR patchW = NULL, attrW = NULL, bufferW = NULL;
1668 TRACE("%s %s %p %p\n", debugstr_a(patch), debugstr_a(attr), buffer, buflen);
1670 if (!patch || !attr)
1671 return ERROR_INVALID_PARAMETER;
1673 if (!(patchW = strdupAtoW( patch )))
1676 if (!(attrW = strdupAtoW( attr )))
1680 r = MsiGetPatchInfoW( patchW, attrW, NULL, &size );
1681 if (r != ERROR_SUCCESS)
1685 if (!(bufferW = msi_alloc( size * sizeof(WCHAR) )))
1687 r = ERROR_OUTOFMEMORY;
1691 r = MsiGetPatchInfoW( patchW, attrW, bufferW, &size );
1692 if (r == ERROR_SUCCESS)
1694 int len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
1696 r = ERROR_MORE_DATA;
1698 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *buflen, NULL, NULL );
1706 msi_free( bufferW );
1710 UINT WINAPI MsiGetPatchInfoW( LPCWSTR patch, LPCWSTR attr, LPWSTR buffer, LPDWORD buflen )
1713 WCHAR product[GUID_SIZE];
1716 TRACE("%s %s %p %p\n", debugstr_w(patch), debugstr_w(attr), buffer, buflen);
1718 if (!patch || !attr)
1719 return ERROR_INVALID_PARAMETER;
1721 if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW, attr ))
1722 return ERROR_UNKNOWN_PROPERTY;
1727 r = MsiEnumProductsW( index, product );
1728 if (r != ERROR_SUCCESS)
1731 r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERMANAGED, attr, buffer, buflen );
1732 if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
1735 r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, attr, buffer, buflen );
1736 if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
1739 r = MsiGetPatchInfoExW( patch, product, NULL, MSIINSTALLCONTEXT_MACHINE, attr, buffer, buflen );
1740 if (r == ERROR_SUCCESS || r == ERROR_MORE_DATA)
1746 return ERROR_UNKNOWN_PRODUCT;
1749 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
1751 LPWSTR szwLogFile = NULL;
1754 TRACE("%08x %s %08x\n", dwLogMode, debugstr_a(szLogFile), attributes);
1758 szwLogFile = strdupAtoW( szLogFile );
1760 return ERROR_OUTOFMEMORY;
1762 r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
1763 msi_free( szwLogFile );
1767 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
1769 TRACE("%08x %s %08x\n", dwLogMode, debugstr_w(szLogFile), attributes);
1771 msi_free(gszLogFile);
1777 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
1778 DeleteFileW(szLogFile);
1779 file = CreateFileW(szLogFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
1780 FILE_ATTRIBUTE_NORMAL, NULL);
1781 if (file != INVALID_HANDLE_VALUE)
1783 gszLogFile = strdupW(szLogFile);
1787 ERR("Unable to enable log %s (%u)\n", debugstr_w(szLogFile), GetLastError());
1790 return ERROR_SUCCESS;
1793 UINT WINAPI MsiEnumComponentCostsW(MSIHANDLE hInstall, LPCWSTR szComponent,
1794 DWORD dwIndex, INSTALLSTATE iState,
1795 LPWSTR lpDriveBuf, DWORD *pcchDriveBuf,
1796 int *piCost, int *pTempCost)
1798 FIXME("(%d, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall,
1799 debugstr_w(szComponent), dwIndex, iState, lpDriveBuf,
1800 pcchDriveBuf, piCost, pTempCost);
1802 return ERROR_NO_MORE_ITEMS;
1805 UINT WINAPI MsiQueryComponentStateA(LPCSTR szProductCode,
1806 LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1807 LPCSTR szComponent, INSTALLSTATE *pdwState)
1809 LPWSTR prodcode = NULL, usersid = NULL, comp = NULL;
1812 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode),
1813 debugstr_a(szUserSid), dwContext, debugstr_a(szComponent), pdwState);
1815 if (szProductCode && !(prodcode = strdupAtoW(szProductCode)))
1816 return ERROR_OUTOFMEMORY;
1818 if (szUserSid && !(usersid = strdupAtoW(szUserSid)))
1819 return ERROR_OUTOFMEMORY;
1821 if (szComponent && !(comp = strdupAtoW(szComponent)))
1822 return ERROR_OUTOFMEMORY;
1824 r = MsiQueryComponentStateW(prodcode, usersid, dwContext, comp, pdwState);
1833 static BOOL msi_comp_find_prod_key(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
1838 r = MSIREG_OpenProductKey(prodcode, NULL, context, &hkey, FALSE);
1840 return (r == ERROR_SUCCESS);
1843 static BOOL msi_comp_find_package(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
1851 static const WCHAR local_package[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
1852 static const WCHAR managed_local_package[] = {
1853 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
1856 r = MSIREG_OpenInstallProps(prodcode, context, NULL, &hkey, FALSE);
1857 if (r != ERROR_SUCCESS)
1860 if (context == MSIINSTALLCONTEXT_USERMANAGED)
1861 package = managed_local_package;
1863 package = local_package;
1866 res = RegQueryValueExW(hkey, package, NULL, NULL, NULL, &sz);
1869 return (res == ERROR_SUCCESS);
1872 static BOOL msi_comp_find_prodcode(LPWSTR squished_pc,
1873 MSIINSTALLCONTEXT context,
1874 LPCWSTR comp, LPWSTR val, DWORD *sz)
1880 if (context == MSIINSTALLCONTEXT_MACHINE)
1881 r = MSIREG_OpenUserDataComponentKey(comp, szLocalSid, &hkey, FALSE);
1883 r = MSIREG_OpenUserDataComponentKey(comp, NULL, &hkey, FALSE);
1885 if (r != ERROR_SUCCESS)
1888 res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, (BYTE *)val, sz);
1889 if (res != ERROR_SUCCESS)
1896 UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
1897 LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
1898 LPCWSTR szComponent, INSTALLSTATE *pdwState)
1900 WCHAR squished_pc[GUID_SIZE];
1901 WCHAR val[MAX_PATH];
1905 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode),
1906 debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState);
1908 if (!pdwState || !szComponent)
1909 return ERROR_INVALID_PARAMETER;
1911 if (!szProductCode || !*szProductCode || lstrlenW(szProductCode) != GUID_SIZE - 1)
1912 return ERROR_INVALID_PARAMETER;
1914 if (!squash_guid(szProductCode, squished_pc))
1915 return ERROR_INVALID_PARAMETER;
1917 found = msi_comp_find_prod_key(szProductCode, dwContext);
1919 if (!msi_comp_find_package(szProductCode, dwContext))
1923 *pdwState = INSTALLSTATE_UNKNOWN;
1924 return ERROR_UNKNOWN_COMPONENT;
1927 return ERROR_UNKNOWN_PRODUCT;
1930 *pdwState = INSTALLSTATE_UNKNOWN;
1933 if (!msi_comp_find_prodcode(squished_pc, dwContext, szComponent, val, &sz))
1934 return ERROR_UNKNOWN_COMPONENT;
1937 *pdwState = INSTALLSTATE_NOTUSED;
1940 if (lstrlenW(val) > 2 &&
1941 val[0] >= '0' && val[0] <= '9' && val[1] >= '0' && val[1] <= '9')
1943 *pdwState = INSTALLSTATE_SOURCE;
1946 *pdwState = INSTALLSTATE_LOCAL;
1949 return ERROR_SUCCESS;
1952 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
1954 LPWSTR szwProduct = NULL;
1959 szwProduct = strdupAtoW( szProduct );
1961 return ERROR_OUTOFMEMORY;
1963 r = MsiQueryProductStateW( szwProduct );
1964 msi_free( szwProduct );
1968 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
1970 MSIINSTALLCONTEXT context = MSIINSTALLCONTEXT_USERUNMANAGED;
1971 INSTALLSTATE state = INSTALLSTATE_ADVERTISED;
1972 HKEY prodkey = 0, userdata = 0;
1976 static const WCHAR szWindowsInstaller[] = {
1977 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1979 TRACE("%s\n", debugstr_w(szProduct));
1981 if (!szProduct || !*szProduct)
1982 return INSTALLSTATE_INVALIDARG;
1984 if (lstrlenW(szProduct) != GUID_SIZE - 1)
1985 return INSTALLSTATE_INVALIDARG;
1987 if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
1988 &prodkey, FALSE) != ERROR_SUCCESS &&
1989 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1990 &prodkey, FALSE) != ERROR_SUCCESS &&
1991 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
1992 &prodkey, FALSE) == ERROR_SUCCESS)
1994 context = MSIINSTALLCONTEXT_MACHINE;
1997 r = MSIREG_OpenInstallProps(szProduct, context, NULL, &userdata, FALSE);
1998 if (r != ERROR_SUCCESS)
2001 if (!msi_reg_get_val_dword(userdata, szWindowsInstaller, &val))
2005 state = INSTALLSTATE_DEFAULT;
2007 state = INSTALLSTATE_UNKNOWN;
2012 state = INSTALLSTATE_UNKNOWN;
2015 state = INSTALLSTATE_ABSENT;
2018 RegCloseKey(prodkey);
2019 RegCloseKey(userdata);
2023 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
2025 INSTALLUILEVEL old = gUILevel;
2026 HWND oldwnd = gUIhwnd;
2028 TRACE("%08x %p\n", dwUILevel, phWnd);
2030 gUILevel = dwUILevel;
2039 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
2040 DWORD dwMessageFilter, LPVOID pvContext)
2042 INSTALLUI_HANDLERA prev = gUIHandlerA;
2044 TRACE("%p %08x %p\n", puiHandler, dwMessageFilter, pvContext);
2046 gUIHandlerA = puiHandler;
2048 gUIFilter = dwMessageFilter;
2049 gUIContext = pvContext;
2054 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
2055 DWORD dwMessageFilter, LPVOID pvContext)
2057 INSTALLUI_HANDLERW prev = gUIHandlerW;
2059 TRACE("%p %08x %p\n", puiHandler, dwMessageFilter, pvContext);
2062 gUIHandlerW = puiHandler;
2063 gUIFilter = dwMessageFilter;
2064 gUIContext = pvContext;
2069 /******************************************************************
2070 * MsiLoadStringW [MSI.@]
2072 * Loads a string from MSI's string resources.
2076 * handle [I] only -1 is handled currently
2077 * id [I] id of the string to be loaded
2078 * lpBuffer [O] buffer for the string to be written to
2079 * nBufferMax [I] maximum size of the buffer in characters
2080 * lang [I] the preferred language for the string
2084 * If successful, this function returns the language id of the string loaded
2085 * If the function fails, the function returns zero.
2089 * The type of the first parameter is unknown. LoadString's prototype
2090 * suggests that it might be a module handle. I have made it an MSI handle
2091 * for starters, as -1 is an invalid MSI handle, but not an invalid module
2092 * handle. Maybe strings can be stored in an MSI database somehow.
2094 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
2095 int nBufferMax, LANGID lang )
2102 TRACE("%d %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
2105 FIXME("don't know how to deal with handle = %08x\n", handle);
2108 lang = GetUserDefaultLangID();
2110 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
2114 hResData = LoadResource( msi_hInstance, hres );
2117 p = LockResource( hResData );
2121 for (i = 0; i < (id&0xf); i++)
2125 if( nBufferMax <= len )
2128 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
2129 lpBuffer[ len ] = 0;
2131 TRACE("found -> %s\n", debugstr_w(lpBuffer));
2136 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
2137 int nBufferMax, LANGID lang )
2143 bufW = msi_alloc(nBufferMax*sizeof(WCHAR));
2144 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
2147 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
2148 if( len <= nBufferMax )
2149 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
2150 lpBuffer, nBufferMax, NULL, NULL );
2158 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
2161 char szProduct[GUID_SIZE];
2163 TRACE("%s %p %p\n", debugstr_a(szComponent), lpPathBuf, pcchBuf);
2165 if (!szComponent || !pcchBuf)
2166 return INSTALLSTATE_INVALIDARG;
2168 if (MsiGetProductCodeA( szComponent, szProduct ) != ERROR_SUCCESS)
2169 return INSTALLSTATE_UNKNOWN;
2171 return MsiGetComponentPathA( szProduct, szComponent, lpPathBuf, pcchBuf );
2174 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
2177 WCHAR szProduct[GUID_SIZE];
2179 TRACE("%s %p %p\n", debugstr_w(szComponent), lpPathBuf, pcchBuf);
2181 if (!szComponent || !pcchBuf)
2182 return INSTALLSTATE_INVALIDARG;
2184 if (MsiGetProductCodeW( szComponent, szProduct ) != ERROR_SUCCESS)
2185 return INSTALLSTATE_UNKNOWN;
2187 return MsiGetComponentPathW( szProduct, szComponent, lpPathBuf, pcchBuf );
2190 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
2191 WORD wLanguageId, DWORD f)
2193 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_a(lpText), debugstr_a(lpCaption),
2194 uType, wLanguageId, f);
2195 return MessageBoxExA(hWnd,lpText,lpCaption,uType,wLanguageId);
2198 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
2199 WORD wLanguageId, DWORD f)
2201 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_w(lpText), debugstr_w(lpCaption),
2202 uType, wLanguageId, f);
2203 return MessageBoxExW(hWnd,lpText,lpCaption,uType,wLanguageId);
2206 UINT WINAPI MsiMessageBoxExA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
2207 DWORD unknown, WORD wLanguageId, DWORD f)
2209 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd, debugstr_a(lpText),
2210 debugstr_a(lpCaption), uType, unknown, wLanguageId, f);
2211 return MessageBoxExA(hWnd, lpText, lpCaption, uType, wLanguageId);
2214 UINT WINAPI MsiMessageBoxExW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
2215 DWORD unknown, WORD wLanguageId, DWORD f)
2217 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd, debugstr_w(lpText),
2218 debugstr_w(lpCaption), uType, unknown, wLanguageId, f);
2219 return MessageBoxExW(hWnd, lpText, lpCaption, uType, wLanguageId);
2222 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
2223 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
2224 LPDWORD pcchPathBuf )
2226 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName),
2227 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
2229 return ERROR_CALL_NOT_IMPLEMENTED;
2232 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
2233 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
2234 LPDWORD pcchPathBuf )
2236 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName),
2237 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
2239 return ERROR_CALL_NOT_IMPLEMENTED;
2242 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
2243 LPSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
2245 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
2246 return ERROR_CALL_NOT_IMPLEMENTED;
2249 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
2250 LPWSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
2252 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
2253 return ERROR_CALL_NOT_IMPLEMENTED;
2256 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
2257 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
2258 LPDWORD pcbHashData)
2260 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
2261 ppcCertContext, pbHashData, pcbHashData);
2262 return ERROR_CALL_NOT_IMPLEMENTED;
2265 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
2266 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
2267 LPDWORD pcbHashData)
2269 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
2270 ppcCertContext, pbHashData, pcbHashData);
2271 return ERROR_CALL_NOT_IMPLEMENTED;
2274 /******************************************************************
2275 * MsiGetProductPropertyA [MSI.@]
2277 UINT WINAPI MsiGetProductPropertyA(MSIHANDLE hProduct, LPCSTR szProperty,
2278 LPSTR szValue, LPDWORD pccbValue)
2280 LPWSTR prop = NULL, val = NULL;
2284 TRACE("(%d, %s, %p, %p)\n", hProduct, debugstr_a(szProperty),
2285 szValue, pccbValue);
2287 if (szValue && !pccbValue)
2288 return ERROR_INVALID_PARAMETER;
2290 if (szProperty) prop = strdupAtoW(szProperty);
2293 r = MsiGetProductPropertyW(hProduct, prop, NULL, &len);
2294 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
2297 if (r == ERROR_SUCCESS)
2299 if (szValue) *szValue = '\0';
2300 if (pccbValue) *pccbValue = 0;
2304 val = msi_alloc(++len * sizeof(WCHAR));
2307 r = ERROR_OUTOFMEMORY;
2311 r = MsiGetProductPropertyW(hProduct, prop, val, &len);
2312 if (r != ERROR_SUCCESS)
2315 len = WideCharToMultiByte(CP_ACP, 0, val, -1, NULL, 0, NULL, NULL);
2318 WideCharToMultiByte(CP_ACP, 0, val, -1, szValue,
2319 *pccbValue, NULL, NULL);
2323 if (len > *pccbValue)
2324 r = ERROR_MORE_DATA;
2326 *pccbValue = len - 1;
2336 /******************************************************************
2337 * MsiGetProductPropertyW [MSI.@]
2339 UINT WINAPI MsiGetProductPropertyW(MSIHANDLE hProduct, LPCWSTR szProperty,
2340 LPWSTR szValue, LPDWORD pccbValue)
2342 MSIPACKAGE *package;
2343 MSIQUERY *view = NULL;
2344 MSIRECORD *rec = NULL;
2348 static const WCHAR query[] = {
2349 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2350 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2351 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2353 TRACE("(%d, %s, %p, %p)\n", hProduct, debugstr_w(szProperty),
2354 szValue, pccbValue);
2357 return ERROR_INVALID_PARAMETER;
2359 if (szValue && !pccbValue)
2360 return ERROR_INVALID_PARAMETER;
2362 package = msihandle2msiinfo(hProduct, MSIHANDLETYPE_PACKAGE);
2364 return ERROR_INVALID_HANDLE;
2366 r = MSI_OpenQuery(package->db, &view, query, szProperty);
2367 if (r != ERROR_SUCCESS)
2370 r = MSI_ViewExecute(view, 0);
2371 if (r != ERROR_SUCCESS)
2374 r = MSI_ViewFetch(view, &rec);
2375 if (r != ERROR_SUCCESS)
2378 val = MSI_RecordGetString(rec, 2);
2382 if (lstrlenW(val) >= *pccbValue)
2384 lstrcpynW(szValue, val, *pccbValue);
2385 *pccbValue = lstrlenW(val);
2386 r = ERROR_MORE_DATA;
2390 lstrcpyW(szValue, val);
2391 *pccbValue = lstrlenW(val);
2398 MSI_ViewClose(view);
2399 msiobj_release(&view->hdr);
2400 if (rec) msiobj_release(&rec->hdr);
2405 if (szValue) *szValue = '\0';
2406 if (pccbValue) *pccbValue = 0;
2410 msiobj_release(&package->hdr);
2414 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
2417 LPWSTR szPack = NULL;
2419 TRACE("%s\n", debugstr_a(szPackage) );
2423 szPack = strdupAtoW( szPackage );
2425 return ERROR_OUTOFMEMORY;
2428 r = MsiVerifyPackageW( szPack );
2435 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
2440 TRACE("%s\n", debugstr_w(szPackage) );
2442 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
2443 MsiCloseHandle( handle );
2448 static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
2449 awstring* lpPathBuf, LPDWORD pcchBuf)
2451 WCHAR squished_pc[GUID_SIZE];
2452 WCHAR squished_comp[GUID_SIZE];
2458 static const WCHAR wininstaller[] = {
2459 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2461 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
2462 debugstr_w(szComponent), lpPathBuf->str.w, pcchBuf);
2464 if (!szProduct || !szComponent)
2465 return INSTALLSTATE_INVALIDARG;
2467 if (lpPathBuf->str.w && !pcchBuf)
2468 return INSTALLSTATE_INVALIDARG;
2470 if (!squash_guid(szProduct, squished_pc) ||
2471 !squash_guid(szComponent, squished_comp))
2472 return INSTALLSTATE_INVALIDARG;
2474 state = INSTALLSTATE_UNKNOWN;
2476 if (MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &hkey, FALSE) == ERROR_SUCCESS ||
2477 MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkey, FALSE) == ERROR_SUCCESS)
2479 path = msi_reg_get_val_str(hkey, squished_pc);
2482 state = INSTALLSTATE_ABSENT;
2484 if ((MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE, NULL,
2485 &hkey, FALSE) == ERROR_SUCCESS ||
2486 MSIREG_OpenUserDataProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
2487 NULL, &hkey, FALSE) == ERROR_SUCCESS) &&
2488 msi_reg_get_val_dword(hkey, wininstaller, &version) &&
2489 GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
2492 state = INSTALLSTATE_LOCAL;
2496 if (state != INSTALLSTATE_LOCAL &&
2497 (MSIREG_OpenProductKey(szProduct, NULL,
2498 MSIINSTALLCONTEXT_USERUNMANAGED,
2499 &hkey, FALSE) == ERROR_SUCCESS ||
2500 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
2501 &hkey, FALSE) == ERROR_SUCCESS))
2505 if (MSIREG_OpenUserDataComponentKey(szComponent, szLocalSid, &hkey, FALSE) == ERROR_SUCCESS ||
2506 MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkey, FALSE) == ERROR_SUCCESS)
2509 path = msi_reg_get_val_str(hkey, squished_pc);
2512 state = INSTALLSTATE_ABSENT;
2514 if (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
2515 state = INSTALLSTATE_LOCAL;
2520 return INSTALLSTATE_UNKNOWN;
2522 if (state == INSTALLSTATE_LOCAL && !*path)
2523 state = INSTALLSTATE_NOTUSED;
2525 msi_strcpy_to_awstring(path, lpPathBuf, pcchBuf);
2530 /******************************************************************
2531 * MsiGetComponentPathW [MSI.@]
2533 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
2534 LPWSTR lpPathBuf, LPDWORD pcchBuf)
2538 path.unicode = TRUE;
2539 path.str.w = lpPathBuf;
2541 return MSI_GetComponentPath( szProduct, szComponent, &path, pcchBuf );
2544 /******************************************************************
2545 * MsiGetComponentPathA [MSI.@]
2547 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
2548 LPSTR lpPathBuf, LPDWORD pcchBuf)
2550 LPWSTR szwProduct, szwComponent = NULL;
2551 INSTALLSTATE r = INSTALLSTATE_UNKNOWN;
2554 szwProduct = strdupAtoW( szProduct );
2555 if( szProduct && !szwProduct)
2558 szwComponent = strdupAtoW( szComponent );
2559 if( szComponent && !szwComponent )
2562 path.unicode = FALSE;
2563 path.str.a = lpPathBuf;
2565 r = MSI_GetComponentPath( szwProduct, szwComponent, &path, pcchBuf );
2568 msi_free( szwProduct );
2569 msi_free( szwComponent );
2574 /******************************************************************
2575 * MsiQueryFeatureStateA [MSI.@]
2577 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
2579 LPWSTR szwProduct = NULL, szwFeature= NULL;
2580 INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
2582 szwProduct = strdupAtoW( szProduct );
2583 if ( szProduct && !szwProduct )
2586 szwFeature = strdupAtoW( szFeature );
2587 if ( szFeature && !szwFeature )
2590 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
2593 msi_free( szwProduct);
2594 msi_free( szwFeature);
2599 /******************************************************************
2600 * MsiQueryFeatureStateW [MSI.@]
2602 * Checks the state of a feature
2605 * szProduct [I] Product's GUID string
2606 * szFeature [I] Feature's GUID string
2609 * INSTALLSTATE_LOCAL Feature is installed and usable
2610 * INSTALLSTATE_ABSENT Feature is absent
2611 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
2612 * INSTALLSTATE_UNKNOWN An error occurred
2613 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
2616 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
2618 WCHAR squishProduct[33], comp[GUID_SIZE];
2620 LPWSTR components, p, parent_feature, path;
2624 BOOL missing = FALSE;
2625 BOOL machine = FALSE;
2626 BOOL source = FALSE;
2628 TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
2630 if (!szProduct || !szFeature)
2631 return INSTALLSTATE_INVALIDARG;
2633 if (!squash_guid( szProduct, squishProduct ))
2634 return INSTALLSTATE_INVALIDARG;
2636 if (MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
2637 &hkey, FALSE) != ERROR_SUCCESS &&
2638 MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
2639 &hkey, FALSE) != ERROR_SUCCESS)
2641 rc = MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
2643 if (rc != ERROR_SUCCESS)
2644 return INSTALLSTATE_UNKNOWN;
2649 parent_feature = msi_reg_get_val_str( hkey, szFeature );
2652 if (!parent_feature)
2653 return INSTALLSTATE_UNKNOWN;
2655 r = (parent_feature[0] == 6) ? INSTALLSTATE_ABSENT : INSTALLSTATE_LOCAL;
2656 msi_free(parent_feature);
2657 if (r == INSTALLSTATE_ABSENT)
2661 rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
2662 MSIINSTALLCONTEXT_MACHINE,
2665 rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
2666 MSIINSTALLCONTEXT_USERUNMANAGED,
2669 if (rc != ERROR_SUCCESS)
2670 return INSTALLSTATE_ADVERTISED;
2672 components = msi_reg_get_val_str( hkey, szFeature );
2675 TRACE("rc = %d buffer = %s\n", rc, debugstr_w(components));
2678 return INSTALLSTATE_ADVERTISED;
2680 for( p = components; *p && *p != 2 ; p += 20)
2682 if (!decode_base85_guid( p, &guid ))
2684 if (p != components)
2687 msi_free(components);
2688 return INSTALLSTATE_BADCONFIG;
2691 StringFromGUID2(&guid, comp, GUID_SIZE);
2694 rc = MSIREG_OpenUserDataComponentKey(comp, szLocalSid, &hkey, FALSE);
2696 rc = MSIREG_OpenUserDataComponentKey(comp, NULL, &hkey, FALSE);
2698 if (rc != ERROR_SUCCESS)
2700 msi_free(components);
2701 return INSTALLSTATE_ADVERTISED;
2704 path = msi_reg_get_val_str(hkey, squishProduct);
2707 else if (lstrlenW(path) > 2 &&
2708 path[0] >= '0' && path[0] <= '9' &&
2709 path[1] >= '0' && path[1] <= '9')
2717 TRACE("%s %s -> %d\n", debugstr_w(szProduct), debugstr_w(szFeature), r);
2718 msi_free(components);
2721 return INSTALLSTATE_ADVERTISED;
2724 return INSTALLSTATE_SOURCE;
2726 return INSTALLSTATE_LOCAL;
2729 /******************************************************************
2730 * MsiGetFileVersionA [MSI.@]
2732 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
2733 LPDWORD pcchVersionBuf, LPSTR lpLangBuf, LPDWORD pcchLangBuf)
2735 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
2736 UINT ret = ERROR_OUTOFMEMORY;
2738 if ((lpVersionBuf && !pcchVersionBuf) ||
2739 (lpLangBuf && !pcchLangBuf))
2740 return ERROR_INVALID_PARAMETER;
2744 szwFilePath = strdupAtoW( szFilePath );
2749 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
2751 lpwVersionBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
2752 if( !lpwVersionBuff )
2756 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
2758 lpwLangBuff = msi_alloc(*pcchLangBuf*sizeof(WCHAR));
2763 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
2764 lpwLangBuff, pcchLangBuf);
2766 if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwVersionBuff )
2767 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
2768 lpVersionBuf, *pcchVersionBuf + 1, NULL, NULL);
2769 if( (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && lpwLangBuff )
2770 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
2771 lpLangBuf, *pcchLangBuf + 1, NULL, NULL);
2774 msi_free(szwFilePath);
2775 msi_free(lpwVersionBuff);
2776 msi_free(lpwLangBuff);
2781 /******************************************************************
2782 * MsiGetFileVersionW [MSI.@]
2784 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
2785 LPDWORD pcchVersionBuf, LPWSTR lpLangBuf, LPDWORD pcchLangBuf)
2787 static const WCHAR szVersionResource[] = {'\\',0};
2788 static const WCHAR szVersionFormat[] = {
2789 '%','d','.','%','d','.','%','d','.','%','d',0};
2790 static const WCHAR szLangResource[] = {
2791 '\\','V','a','r','F','i','l','e','I','n','f','o','\\',
2792 'T','r','a','n','s','l','a','t','i','o','n',0};
2793 static const WCHAR szLangFormat[] = {'%','d',0};
2795 DWORD dwVerLen, gle;
2796 LPVOID lpVer = NULL;
2797 VS_FIXEDFILEINFO *ffi;
2802 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath),
2803 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
2804 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
2806 if ((lpVersionBuf && !pcchVersionBuf) ||
2807 (lpLangBuf && !pcchLangBuf))
2808 return ERROR_INVALID_PARAMETER;
2810 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
2813 gle = GetLastError();
2814 if (gle == ERROR_BAD_PATHNAME)
2815 return ERROR_FILE_NOT_FOUND;
2816 else if (gle == ERROR_RESOURCE_DATA_NOT_FOUND)
2817 return ERROR_FILE_INVALID;
2822 lpVer = msi_alloc(dwVerLen);
2825 ret = ERROR_OUTOFMEMORY;
2829 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
2831 ret = GetLastError();
2837 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
2840 wsprintfW(tmp, szVersionFormat,
2841 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
2842 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
2843 if (lpVersionBuf) lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
2845 if (strlenW(tmp) >= *pcchVersionBuf)
2846 ret = ERROR_MORE_DATA;
2848 *pcchVersionBuf = lstrlenW(tmp);
2852 if (lpVersionBuf) *lpVersionBuf = 0;
2853 *pcchVersionBuf = 0;
2859 if (VerQueryValueW(lpVer, szLangResource, (LPVOID*)&lang, &puLen) &&
2862 wsprintfW(tmp, szLangFormat, *lang);
2863 if (lpLangBuf) lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
2865 if (strlenW(tmp) >= *pcchLangBuf)
2866 ret = ERROR_MORE_DATA;
2868 *pcchLangBuf = lstrlenW(tmp);
2872 if (lpLangBuf) *lpLangBuf = 0;
2882 /***********************************************************************
2883 * MsiGetFeatureUsageW [MSI.@]
2885 UINT WINAPI MsiGetFeatureUsageW( LPCWSTR szProduct, LPCWSTR szFeature,
2886 LPDWORD pdwUseCount, LPWORD pwDateUsed )
2888 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
2889 pdwUseCount, pwDateUsed);
2890 return ERROR_CALL_NOT_IMPLEMENTED;
2893 /***********************************************************************
2894 * MsiGetFeatureUsageA [MSI.@]
2896 UINT WINAPI MsiGetFeatureUsageA( LPCSTR szProduct, LPCSTR szFeature,
2897 LPDWORD pdwUseCount, LPWORD pwDateUsed )
2899 LPWSTR prod = NULL, feat = NULL;
2900 UINT ret = ERROR_OUTOFMEMORY;
2902 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
2903 pdwUseCount, pwDateUsed);
2905 prod = strdupAtoW( szProduct );
2906 if (szProduct && !prod)
2909 feat = strdupAtoW( szFeature );
2910 if (szFeature && !feat)
2913 ret = MsiGetFeatureUsageW( prod, feat, pdwUseCount, pwDateUsed );
2922 /***********************************************************************
2923 * MsiUseFeatureExW [MSI.@]
2925 INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
2926 DWORD dwInstallMode, DWORD dwReserved )
2930 TRACE("%s %s %i %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
2931 dwInstallMode, dwReserved);
2933 state = MsiQueryFeatureStateW( szProduct, szFeature );
2936 return INSTALLSTATE_INVALIDARG;
2938 if (state == INSTALLSTATE_LOCAL && dwInstallMode != INSTALLMODE_NODETECTION)
2940 FIXME("mark product %s feature %s as used\n",
2941 debugstr_w(szProduct), debugstr_w(szFeature) );
2947 /***********************************************************************
2948 * MsiUseFeatureExA [MSI.@]
2950 INSTALLSTATE WINAPI MsiUseFeatureExA( LPCSTR szProduct, LPCSTR szFeature,
2951 DWORD dwInstallMode, DWORD dwReserved )
2953 INSTALLSTATE ret = INSTALLSTATE_UNKNOWN;
2954 LPWSTR prod = NULL, feat = NULL;
2956 TRACE("%s %s %i %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
2957 dwInstallMode, dwReserved);
2959 prod = strdupAtoW( szProduct );
2960 if (szProduct && !prod)
2963 feat = strdupAtoW( szFeature );
2964 if (szFeature && !feat)
2967 ret = MsiUseFeatureExW( prod, feat, dwInstallMode, dwReserved );
2976 /***********************************************************************
2977 * MsiUseFeatureW [MSI.@]
2979 INSTALLSTATE WINAPI MsiUseFeatureW( LPCWSTR szProduct, LPCWSTR szFeature )
2981 return MsiUseFeatureExW(szProduct, szFeature, 0, 0);
2984 /***********************************************************************
2985 * MsiUseFeatureA [MSI.@]
2987 INSTALLSTATE WINAPI MsiUseFeatureA( LPCSTR szProduct, LPCSTR szFeature )
2989 return MsiUseFeatureExA(szProduct, szFeature, 0, 0);
2992 /***********************************************************************
2993 * MSI_ProvideQualifiedComponentEx [internal]
2995 static UINT MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent,
2996 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
2997 DWORD Unused1, DWORD Unused2, awstring *lpPathBuf,
2998 LPDWORD pcchPathBuf)
3000 WCHAR product[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1],
3001 feature[MAX_FEATURE_CHARS+1];
3007 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent),
3008 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
3009 Unused1, Unused2, lpPathBuf, pcchPathBuf);
3011 rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE);
3012 if (rc != ERROR_SUCCESS)
3013 return ERROR_INDEX_ABSENT;
3015 info = msi_reg_get_val_str( hkey, szQualifier );
3019 return ERROR_INDEX_ABSENT;
3021 MsiDecomposeDescriptorW(info, product, feature, component, &sz);
3024 rc = MSI_GetComponentPath(product, component, lpPathBuf, pcchPathBuf);
3026 rc = MSI_GetComponentPath(szProduct, component, lpPathBuf, pcchPathBuf);
3030 if (rc != INSTALLSTATE_LOCAL)
3031 return ERROR_FILE_NOT_FOUND;
3033 return ERROR_SUCCESS;
3036 /***********************************************************************
3037 * MsiProvideQualifiedComponentExW [MSI.@]
3039 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
3040 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
3041 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
3042 LPDWORD pcchPathBuf)
3046 path.unicode = TRUE;
3047 path.str.w = lpPathBuf;
3049 return MSI_ProvideQualifiedComponentEx(szComponent, szQualifier,
3050 dwInstallMode, szProduct, Unused1, Unused2, &path, pcchPathBuf);
3053 /***********************************************************************
3054 * MsiProvideQualifiedComponentExA [MSI.@]
3056 UINT WINAPI MsiProvideQualifiedComponentExA(LPCSTR szComponent,
3057 LPCSTR szQualifier, DWORD dwInstallMode, LPCSTR szProduct,
3058 DWORD Unused1, DWORD Unused2, LPSTR lpPathBuf,
3059 LPDWORD pcchPathBuf)
3061 LPWSTR szwComponent, szwQualifier = NULL, szwProduct = NULL;
3062 UINT r = ERROR_OUTOFMEMORY;
3065 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent),
3066 debugstr_a(szQualifier), dwInstallMode, debugstr_a(szProduct),
3067 Unused1, Unused2, lpPathBuf, pcchPathBuf);
3069 szwComponent = strdupAtoW( szComponent );
3070 if (szComponent && !szwComponent)
3073 szwQualifier = strdupAtoW( szQualifier );
3074 if (szQualifier && !szwQualifier)
3077 szwProduct = strdupAtoW( szProduct );
3078 if (szProduct && !szwProduct)
3081 path.unicode = FALSE;
3082 path.str.a = lpPathBuf;
3084 r = MSI_ProvideQualifiedComponentEx(szwComponent, szwQualifier,
3085 dwInstallMode, szwProduct, Unused1,
3086 Unused2, &path, pcchPathBuf);
3088 msi_free(szwProduct);
3089 msi_free(szwComponent);
3090 msi_free(szwQualifier);
3095 /***********************************************************************
3096 * MsiProvideQualifiedComponentW [MSI.@]
3098 UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
3099 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
3100 LPDWORD pcchPathBuf)
3102 return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
3103 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
3106 /***********************************************************************
3107 * MsiProvideQualifiedComponentA [MSI.@]
3109 UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
3110 LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
3111 LPDWORD pcchPathBuf)
3113 return MsiProvideQualifiedComponentExA(szComponent, szQualifier,
3114 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
3117 /***********************************************************************
3118 * MSI_GetUserInfo [internal]
3120 static USERINFOSTATE MSI_GetUserInfo(LPCWSTR szProduct,
3121 awstring *lpUserNameBuf, LPDWORD pcchUserNameBuf,
3122 awstring *lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
3123 awstring *lpSerialBuf, LPDWORD pcchSerialBuf)
3125 WCHAR squished_pc[SQUISH_GUID_SIZE];
3126 LPWSTR user, org, serial;
3127 USERINFOSTATE state;
3132 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct), lpUserNameBuf,
3133 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
3136 if (!szProduct || !squash_guid(szProduct, squished_pc))
3137 return USERINFOSTATE_INVALIDARG;
3139 if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
3140 &hkey, FALSE) != ERROR_SUCCESS &&
3141 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3142 &hkey, FALSE) != ERROR_SUCCESS &&
3143 MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_MACHINE,
3144 &hkey, FALSE) != ERROR_SUCCESS)
3146 return USERINFOSTATE_UNKNOWN;
3149 if (MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
3150 NULL, &props, FALSE) != ERROR_SUCCESS &&
3151 MSIREG_OpenInstallProps(szProduct, MSIINSTALLCONTEXT_MACHINE,
3152 NULL, &props, FALSE) != ERROR_SUCCESS)
3155 return USERINFOSTATE_ABSENT;
3158 user = msi_reg_get_val_str(props, INSTALLPROPERTY_REGOWNERW);
3159 org = msi_reg_get_val_str(props, INSTALLPROPERTY_REGCOMPANYW);
3160 serial = msi_reg_get_val_str(props, INSTALLPROPERTY_PRODUCTIDW);
3161 state = USERINFOSTATE_ABSENT;
3167 state = USERINFOSTATE_PRESENT;
3169 if (pcchUserNameBuf)
3171 if (lpUserNameBuf && !user)
3173 (*pcchUserNameBuf)--;
3177 r = msi_strcpy_to_awstring(user, lpUserNameBuf, pcchUserNameBuf);
3178 if (r == ERROR_MORE_DATA)
3180 state = USERINFOSTATE_MOREDATA;
3188 if (!orgptr) orgptr = szEmpty;
3190 r = msi_strcpy_to_awstring(orgptr, lpOrgNameBuf, pcchOrgNameBuf);
3191 if (r == ERROR_MORE_DATA)
3193 state = USERINFOSTATE_MOREDATA;
3206 r = msi_strcpy_to_awstring(serial, lpSerialBuf, pcchSerialBuf);
3207 if (r == ERROR_MORE_DATA)
3208 state = USERINFOSTATE_MOREDATA;
3219 /***********************************************************************
3220 * MsiGetUserInfoW [MSI.@]
3222 USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct,
3223 LPWSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
3224 LPWSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
3225 LPWSTR lpSerialBuf, LPDWORD pcchSerialBuf)
3227 awstring user, org, serial;
3229 if ((lpUserNameBuf && !pcchUserNameBuf) ||
3230 (lpOrgNameBuf && !pcchOrgNameBuf) ||
3231 (lpSerialBuf && !pcchSerialBuf))
3232 return USERINFOSTATE_INVALIDARG;
3234 user.unicode = TRUE;
3235 user.str.w = lpUserNameBuf;
3237 org.str.w = lpOrgNameBuf;
3238 serial.unicode = TRUE;
3239 serial.str.w = lpSerialBuf;
3241 return MSI_GetUserInfo( szProduct, &user, pcchUserNameBuf,
3242 &org, pcchOrgNameBuf,
3243 &serial, pcchSerialBuf );
3246 USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct,
3247 LPSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
3248 LPSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
3249 LPSTR lpSerialBuf, LPDWORD pcchSerialBuf)
3251 awstring user, org, serial;
3255 if ((lpUserNameBuf && !pcchUserNameBuf) ||
3256 (lpOrgNameBuf && !pcchOrgNameBuf) ||
3257 (lpSerialBuf && !pcchSerialBuf))
3258 return USERINFOSTATE_INVALIDARG;
3260 prod = strdupAtoW( szProduct );
3261 if (szProduct && !prod)
3262 return ERROR_OUTOFMEMORY;
3264 user.unicode = FALSE;
3265 user.str.a = lpUserNameBuf;
3266 org.unicode = FALSE;
3267 org.str.a = lpOrgNameBuf;
3268 serial.unicode = FALSE;
3269 serial.str.a = lpSerialBuf;
3271 r = MSI_GetUserInfo( prod, &user, pcchUserNameBuf,
3272 &org, pcchOrgNameBuf,
3273 &serial, pcchSerialBuf );
3280 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
3284 MSIPACKAGE *package;
3285 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
3287 TRACE("(%s)\n",debugstr_w(szProduct));
3289 rc = MsiOpenProductW(szProduct,&handle);
3290 if (rc != ERROR_SUCCESS)
3291 return ERROR_INVALID_PARAMETER;
3293 /* MsiCollectUserInfo cannot be called from a custom action. */
3294 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
3296 return ERROR_CALL_NOT_IMPLEMENTED;
3298 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
3299 msiobj_release( &package->hdr );
3301 MsiCloseHandle(handle);
3306 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
3310 MSIPACKAGE *package;
3311 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
3313 TRACE("(%s)\n",debugstr_a(szProduct));
3315 rc = MsiOpenProductA(szProduct,&handle);
3316 if (rc != ERROR_SUCCESS)
3317 return ERROR_INVALID_PARAMETER;
3319 /* MsiCollectUserInfo cannot be called from a custom action. */
3320 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
3322 return ERROR_CALL_NOT_IMPLEMENTED;
3324 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
3325 msiobj_release( &package->hdr );
3327 MsiCloseHandle(handle);
3332 /***********************************************************************
3333 * MsiConfigureFeatureA [MSI.@]
3335 UINT WINAPI MsiConfigureFeatureA(LPCSTR szProduct, LPCSTR szFeature, INSTALLSTATE eInstallState)
3337 LPWSTR prod, feat = NULL;
3338 UINT r = ERROR_OUTOFMEMORY;
3340 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature), eInstallState);
3342 prod = strdupAtoW( szProduct );
3343 if (szProduct && !prod)
3346 feat = strdupAtoW( szFeature );
3347 if (szFeature && !feat)
3350 r = MsiConfigureFeatureW(prod, feat, eInstallState);
3359 /***********************************************************************
3360 * MsiConfigureFeatureW [MSI.@]
3362 UINT WINAPI MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLSTATE eInstallState)
3364 static const WCHAR szCostInit[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
3365 MSIPACKAGE *package = NULL;
3367 WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
3370 TRACE("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature), eInstallState);
3372 if (!szProduct || !szFeature)
3373 return ERROR_INVALID_PARAMETER;
3375 switch (eInstallState)
3377 case INSTALLSTATE_DEFAULT:
3378 /* FIXME: how do we figure out the default location? */
3379 eInstallState = INSTALLSTATE_LOCAL;
3381 case INSTALLSTATE_LOCAL:
3382 case INSTALLSTATE_SOURCE:
3383 case INSTALLSTATE_ABSENT:
3384 case INSTALLSTATE_ADVERTISED:
3387 return ERROR_INVALID_PARAMETER;
3390 r = MSI_OpenProductW( szProduct, &package );
3391 if (r != ERROR_SUCCESS)
3394 sz = sizeof(sourcepath);
3395 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3396 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
3398 sz = sizeof(filename);
3399 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3400 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
3402 lstrcatW( sourcepath, filename );
3404 MsiSetInternalUI( INSTALLUILEVEL_BASIC, NULL );
3406 r = ACTION_PerformUIAction( package, szCostInit, -1 );
3407 if (r != ERROR_SUCCESS)
3410 r = MSI_SetFeatureStateW( package, szFeature, eInstallState);
3411 if (r != ERROR_SUCCESS)
3414 r = MSI_InstallPackage( package, sourcepath, NULL );
3417 msiobj_release( &package->hdr );
3422 /***********************************************************************
3423 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3425 * Notes: undocumented
3427 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
3429 WCHAR path[MAX_PATH];
3431 TRACE("%d\n", dwReserved);
3435 FIXME("dwReserved=%d\n", dwReserved);
3436 return ERROR_INVALID_PARAMETER;
3439 if (!GetWindowsDirectoryW(path, MAX_PATH))
3440 return ERROR_FUNCTION_FAILED;
3442 lstrcatW(path, installerW);
3444 if (!CreateDirectoryW(path, NULL))
3445 return ERROR_FUNCTION_FAILED;
3447 return ERROR_SUCCESS;
3450 /***********************************************************************
3451 * MsiGetShortcutTargetA [MSI.@]
3453 UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
3454 LPSTR szProductCode, LPSTR szFeatureId,
3455 LPSTR szComponentCode )
3458 const int len = MAX_FEATURE_CHARS+1;
3459 WCHAR product[MAX_FEATURE_CHARS+1], feature[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1];
3462 target = strdupAtoW( szShortcutTarget );
3463 if (szShortcutTarget && !target )
3464 return ERROR_OUTOFMEMORY;
3468 r = MsiGetShortcutTargetW( target, product, feature, component );
3470 if (r == ERROR_SUCCESS)
3472 WideCharToMultiByte( CP_ACP, 0, product, -1, szProductCode, len, NULL, NULL );
3473 WideCharToMultiByte( CP_ACP, 0, feature, -1, szFeatureId, len, NULL, NULL );
3474 WideCharToMultiByte( CP_ACP, 0, component, -1, szComponentCode, len, NULL, NULL );
3479 /***********************************************************************
3480 * MsiGetShortcutTargetW [MSI.@]
3482 UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
3483 LPWSTR szProductCode, LPWSTR szFeatureId,
3484 LPWSTR szComponentCode )
3486 IShellLinkDataList *dl = NULL;
3487 IPersistFile *pf = NULL;
3488 LPEXP_DARWIN_LINK darwin = NULL;
3491 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget),
3492 szProductCode, szFeatureId, szComponentCode );
3494 init = CoInitialize(NULL);
3496 r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
3497 &IID_IPersistFile, (LPVOID*) &pf );
3498 if( SUCCEEDED( r ) )
3500 r = IPersistFile_Load( pf, szShortcutTarget,
3501 STGM_READ | STGM_SHARE_DENY_WRITE );
3502 if( SUCCEEDED( r ) )
3504 r = IPersistFile_QueryInterface( pf, &IID_IShellLinkDataList,
3506 if( SUCCEEDED( r ) )
3508 IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG,
3510 IShellLinkDataList_Release( dl );
3513 IPersistFile_Release( pf );
3516 if (SUCCEEDED(init))
3519 TRACE("darwin = %p\n", darwin);
3526 ret = MsiDecomposeDescriptorW( darwin->szwDarwinID,
3527 szProductCode, szFeatureId, szComponentCode, &sz );
3528 LocalFree( darwin );
3532 return ERROR_FUNCTION_FAILED;
3535 UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
3536 DWORD dwReinstallMode )
3538 MSIPACKAGE* package = NULL;
3540 WCHAR sourcepath[MAX_PATH];
3541 WCHAR filename[MAX_PATH];
3542 static const WCHAR szLogVerbose[] = {
3543 ' ','L','O','G','V','E','R','B','O','S','E',0 };
3544 WCHAR reinstallmode[11];
3548 FIXME("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
3551 ptr = reinstallmode;
3553 if (dwReinstallMode & REINSTALLMODE_FILEMISSING)
3555 if (dwReinstallMode & REINSTALLMODE_FILEOLDERVERSION)
3557 if (dwReinstallMode & REINSTALLMODE_FILEEQUALVERSION)
3559 if (dwReinstallMode & REINSTALLMODE_FILEEXACT)
3561 if (dwReinstallMode & REINSTALLMODE_FILEVERIFY)
3563 if (dwReinstallMode & REINSTALLMODE_FILEREPLACE)
3565 if (dwReinstallMode & REINSTALLMODE_USERDATA)
3567 if (dwReinstallMode & REINSTALLMODE_MACHINEDATA)
3569 if (dwReinstallMode & REINSTALLMODE_SHORTCUT)
3571 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
3575 sz = sizeof(sourcepath);
3576 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3577 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
3579 sz = sizeof(filename);
3580 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3581 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
3583 lstrcatW( sourcepath, filename );
3585 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
3586 r = MSI_OpenPackageW( sourcepath, &package );
3588 r = MSI_OpenProductW( szProduct, &package );
3590 if (r != ERROR_SUCCESS)
3593 msi_set_property( package->db, szReinstallMode, reinstallmode );
3594 msi_set_property( package->db, szInstalled, szOne );
3595 msi_set_property( package->db, szLogVerbose, szOne );
3596 msi_set_property( package->db, szReinstall, szFeature );
3598 r = MSI_InstallPackage( package, sourcepath, NULL );
3600 msiobj_release( &package->hdr );
3605 UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
3606 DWORD dwReinstallMode )
3612 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
3615 wszProduct = strdupAtoW(szProduct);
3616 wszFeature = strdupAtoW(szFeature);
3618 rc = MsiReinstallFeatureW(wszProduct, wszFeature, dwReinstallMode);
3620 msi_free(wszProduct);
3621 msi_free(wszFeature);
3628 unsigned int buf[4];
3629 unsigned char in[64];
3630 unsigned char digest[16];
3633 extern VOID WINAPI MD5Init( MD5_CTX *);
3634 extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int );
3635 extern VOID WINAPI MD5Final( MD5_CTX *);
3637 /***********************************************************************
3638 * MsiGetFileHashW [MSI.@]
3640 UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
3641 PMSIFILEHASHINFO pHash )
3643 HANDLE handle, mapping;
3646 UINT r = ERROR_FUNCTION_FAILED;
3648 TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
3651 return ERROR_INVALID_PARAMETER;
3654 return ERROR_PATH_NOT_FOUND;
3657 return ERROR_INVALID_PARAMETER;
3659 return ERROR_INVALID_PARAMETER;
3660 if (pHash->dwFileHashInfoSize < sizeof *pHash)
3661 return ERROR_INVALID_PARAMETER;
3663 handle = CreateFileW( szFilePath, GENERIC_READ,
3664 FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
3665 if (handle == INVALID_HANDLE_VALUE)
3666 return ERROR_FILE_NOT_FOUND;
3668 length = GetFileSize( handle, NULL );
3670 mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL );
3673 p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length );
3679 MD5Update( &ctx, p, length );
3681 UnmapViewOfFile( p );
3683 memcpy( pHash->dwData, ctx.digest, sizeof pHash->dwData );
3686 CloseHandle( mapping );
3688 CloseHandle( handle );
3693 /***********************************************************************
3694 * MsiGetFileHashA [MSI.@]
3696 UINT WINAPI MsiGetFileHashA( LPCSTR szFilePath, DWORD dwOptions,
3697 PMSIFILEHASHINFO pHash )
3702 TRACE("%s %08x %p\n", debugstr_a(szFilePath), dwOptions, pHash );
3704 file = strdupAtoW( szFilePath );
3705 if (szFilePath && !file)
3706 return ERROR_OUTOFMEMORY;
3708 r = MsiGetFileHashW( file, dwOptions, pHash );
3713 /***********************************************************************
3714 * MsiAdvertiseScriptW [MSI.@]
3716 UINT WINAPI MsiAdvertiseScriptW( LPCWSTR szScriptFile, DWORD dwFlags,
3717 PHKEY phRegData, BOOL fRemoveItems )
3719 FIXME("%s %08x %p %d\n",
3720 debugstr_w( szScriptFile ), dwFlags, phRegData, fRemoveItems );
3721 return ERROR_CALL_NOT_IMPLEMENTED;
3724 /***********************************************************************
3725 * MsiAdvertiseScriptA [MSI.@]
3727 UINT WINAPI MsiAdvertiseScriptA( LPCSTR szScriptFile, DWORD dwFlags,
3728 PHKEY phRegData, BOOL fRemoveItems )
3730 FIXME("%s %08x %p %d\n",
3731 debugstr_a( szScriptFile ), dwFlags, phRegData, fRemoveItems );
3732 return ERROR_CALL_NOT_IMPLEMENTED;
3735 /***********************************************************************
3736 * MsiIsProductElevatedW [MSI.@]
3738 UINT WINAPI MsiIsProductElevatedW( LPCWSTR szProduct, BOOL *pfElevated )
3740 FIXME("%s %p - stub\n",
3741 debugstr_w( szProduct ), pfElevated );
3743 return ERROR_SUCCESS;
3746 /***********************************************************************
3747 * MsiIsProductElevatedA [MSI.@]
3749 UINT WINAPI MsiIsProductElevatedA( LPCSTR szProduct, BOOL *pfElevated )
3751 FIXME("%s %p - stub\n",
3752 debugstr_a( szProduct ), pfElevated );
3754 return ERROR_SUCCESS;
3757 /***********************************************************************
3758 * MsiSetExternalUIRecord [MSI.@]
3760 UINT WINAPI MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler,
3761 DWORD filter, LPVOID context,
3762 PINSTALLUI_HANDLER_RECORD prev )
3764 TRACE("%p %08x %p %p\n", handler, filter, context, prev);
3767 *prev = gUIHandlerRecord;
3769 gUIHandlerRecord = handler;
3771 gUIContext = context;
3773 return ERROR_SUCCESS;
3776 /***********************************************************************
3777 * MsiInstallMissingComponentW [MSI.@]
3779 UINT WINAPI MsiInstallMissingComponentW(LPCWSTR szProduct, LPCWSTR szComponent, INSTALLSTATE eInstallState)
3781 FIXME("(%s %s %d\n", debugstr_w(szProduct), debugstr_w(szComponent), eInstallState);
3782 return ERROR_SUCCESS;
3785 /***********************************************************************
3786 * MsiBeginTransactionA [MSI.@]
3788 UINT WINAPI MsiBeginTransactionA( LPCSTR name, DWORD attrs, MSIHANDLE *id, HANDLE *event )
3793 FIXME("%s %u %p %p\n", debugstr_a(name), attrs, id, event);
3795 nameW = strdupAtoW( name );
3797 return ERROR_OUTOFMEMORY;
3799 r = MsiBeginTransactionW( nameW, attrs, id, event );
3804 /***********************************************************************
3805 * MsiBeginTransactionW [MSI.@]
3807 UINT WINAPI MsiBeginTransactionW( LPCWSTR name, DWORD attrs, MSIHANDLE *id, HANDLE *event )
3809 FIXME("%s %u %p %p\n", debugstr_w(name), attrs, id, event);
3811 *id = (MSIHANDLE)0xdeadbeef;
3812 *event = (HANDLE)0xdeadbeef;
3814 return ERROR_SUCCESS;
3817 /***********************************************************************
3818 * MsiEndTransaction [MSI.@]
3820 UINT WINAPI MsiEndTransaction( DWORD state )
3822 FIXME("%u\n", state);
3823 return ERROR_SUCCESS;