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 UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
51 LPWSTR szwProd = NULL;
53 TRACE("%s %p\n",debugstr_a(szProduct), phProduct);
57 szwProd = strdupAtoW( szProduct );
59 return ERROR_OUTOFMEMORY;
62 r = MsiOpenProductW( szwProd, phProduct );
69 static UINT MSI_OpenProductW( LPCWSTR szProduct, MSIPACKAGE **ppackage )
73 HKEY hKeyProduct = NULL;
76 TRACE("%s %p\n", debugstr_w(szProduct), ppackage );
78 r = MSIREG_OpenUninstallKey(szProduct,&hKeyProduct,FALSE);
79 if( r != ERROR_SUCCESS )
81 r = ERROR_UNKNOWN_PRODUCT;
85 /* find the size of the path */
87 r = RegQueryValueExW( hKeyProduct, INSTALLPROPERTY_LOCALPACKAGEW,
88 NULL, &type, NULL, &count );
89 if( r != ERROR_SUCCESS )
91 r = ERROR_UNKNOWN_PRODUCT;
95 /* now alloc and fetch the path of the database to open */
96 path = msi_alloc( count );
100 r = RegQueryValueExW( hKeyProduct, INSTALLPROPERTY_LOCALPACKAGEW,
101 NULL, &type, (LPBYTE) path, &count );
102 if( r != ERROR_SUCCESS )
104 r = ERROR_UNKNOWN_PRODUCT;
108 r = MSI_OpenPackageW( path, ppackage );
113 RegCloseKey( hKeyProduct );
118 UINT WINAPI MsiOpenProductW( LPCWSTR szProduct, MSIHANDLE *phProduct )
120 MSIPACKAGE *package = NULL;
123 r = MSI_OpenProductW( szProduct, &package );
124 if( r == ERROR_SUCCESS )
126 *phProduct = alloc_msihandle( &package->hdr );
128 r = ERROR_NOT_ENOUGH_MEMORY;
129 msiobj_release( &package->hdr );
134 UINT WINAPI MsiAdvertiseProductA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
135 LPCSTR szTransforms, LANGID lgidLanguage)
137 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath),
138 debugstr_a(szScriptfilePath), debugstr_a(szTransforms), lgidLanguage);
139 return ERROR_CALL_NOT_IMPLEMENTED;
142 UINT WINAPI MsiAdvertiseProductW(LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
143 LPCWSTR szTransforms, LANGID lgidLanguage)
145 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath),
146 debugstr_w(szScriptfilePath), debugstr_w(szTransforms), lgidLanguage);
147 return ERROR_CALL_NOT_IMPLEMENTED;
150 UINT WINAPI MsiAdvertiseProductExA(LPCSTR szPackagePath, LPCSTR szScriptfilePath,
151 LPCSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
153 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath),
154 debugstr_a(szScriptfilePath), debugstr_a(szTransforms),
155 lgidLanguage, dwPlatform, dwOptions);
156 return ERROR_CALL_NOT_IMPLEMENTED;
159 UINT WINAPI MsiAdvertiseProductExW( LPCWSTR szPackagePath, LPCWSTR szScriptfilePath,
160 LPCWSTR szTransforms, LANGID lgidLanguage, DWORD dwPlatform, DWORD dwOptions)
162 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath),
163 debugstr_w(szScriptfilePath), debugstr_w(szTransforms),
164 lgidLanguage, dwPlatform, dwOptions);
165 return ERROR_CALL_NOT_IMPLEMENTED;
168 UINT WINAPI MsiInstallProductA(LPCSTR szPackagePath, LPCSTR szCommandLine)
170 LPWSTR szwPath = NULL, szwCommand = NULL;
171 UINT r = ERROR_OUTOFMEMORY;
173 TRACE("%s %s\n",debugstr_a(szPackagePath), debugstr_a(szCommandLine));
177 szwPath = strdupAtoW( szPackagePath );
184 szwCommand = strdupAtoW( szCommandLine );
189 r = MsiInstallProductW( szwPath, szwCommand );
193 msi_free( szwCommand );
198 UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
200 MSIPACKAGE *package = NULL;
203 TRACE("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
205 r = MSI_OpenPackageW( szPackagePath, &package );
206 if (r == ERROR_SUCCESS)
208 r = MSI_InstallPackage( package, szPackagePath, szCommandLine );
209 msiobj_release( &package->hdr );
215 UINT WINAPI MsiReinstallProductA(LPCSTR szProduct, DWORD dwReinstallMode)
217 FIXME("%s %08x\n", debugstr_a(szProduct), dwReinstallMode);
218 return ERROR_CALL_NOT_IMPLEMENTED;
221 UINT WINAPI MsiReinstallProductW(LPCWSTR szProduct, DWORD dwReinstallMode)
223 FIXME("%s %08x\n", debugstr_w(szProduct), dwReinstallMode);
224 return ERROR_CALL_NOT_IMPLEMENTED;
227 UINT WINAPI MsiApplyPatchA(LPCSTR szPatchPackage, LPCSTR szInstallPackage,
228 INSTALLTYPE eInstallType, LPCSTR szCommandLine)
230 LPWSTR patch_package = NULL;
231 LPWSTR install_package = NULL;
232 LPWSTR command_line = NULL;
233 UINT r = ERROR_OUTOFMEMORY;
235 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage), debugstr_a(szInstallPackage),
236 eInstallType, debugstr_a(szCommandLine));
238 if (szPatchPackage && !(patch_package = strdupAtoW(szPatchPackage)))
241 if (szInstallPackage && !(install_package = strdupAtoW(szInstallPackage)))
244 if (szCommandLine && !(command_line = strdupAtoW(szCommandLine)))
247 r = MsiApplyPatchW(patch_package, install_package, eInstallType, command_line);
250 msi_free(patch_package);
251 msi_free(install_package);
252 msi_free(command_line);
257 UINT WINAPI MsiApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szInstallPackage,
258 INSTALLTYPE eInstallType, LPCWSTR szCommandLine)
260 MSIHANDLE patch, info;
263 LPCWSTR cmd_ptr = szCommandLine;
265 LPWSTR cmd = NULL, codes = NULL;
267 static const WCHAR space[] = {' ',0};
268 static const WCHAR patcheq[] = {'P','A','T','C','H','=',0};
269 static WCHAR empty[] = {0};
271 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage), debugstr_w(szInstallPackage),
272 eInstallType, debugstr_w(szCommandLine));
274 if (szInstallPackage || eInstallType == INSTALLTYPE_NETWORK_IMAGE ||
275 eInstallType == INSTALLTYPE_SINGLE_INSTANCE)
277 FIXME("Only reading target products from patch\n");
278 return ERROR_CALL_NOT_IMPLEMENTED;
281 r = MsiOpenDatabaseW(szPatchPackage, MSIDBOPEN_READONLY, &patch);
282 if (r != ERROR_SUCCESS)
285 r = MsiGetSummaryInformationW(patch, NULL, 0, &info);
286 if (r != ERROR_SUCCESS)
289 r = MsiSummaryInfoGetPropertyW(info, PID_TEMPLATE, &type, NULL, NULL, empty, &size);
290 if (r != ERROR_MORE_DATA || !size || type != VT_LPSTR)
292 ERR("Failed to read product codes from patch\n");
296 codes = msi_alloc(++size * sizeof(WCHAR));
299 r = ERROR_OUTOFMEMORY;
303 r = MsiSummaryInfoGetPropertyW(info, PID_TEMPLATE, &type, NULL, NULL, codes, &size);
304 if (r != ERROR_SUCCESS)
310 size = lstrlenW(cmd_ptr) + lstrlenW(patcheq) + lstrlenW(szPatchPackage) + 1;
311 cmd = msi_alloc(size * sizeof(WCHAR));
314 r = ERROR_OUTOFMEMORY;
318 lstrcpyW(cmd, cmd_ptr);
319 if (szCommandLine) lstrcatW(cmd, space);
320 lstrcatW(cmd, patcheq);
321 lstrcatW(cmd, szPatchPackage);
324 while ((end = strchrW(beg, '}')))
328 r = MsiConfigureProductExW(beg, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
329 if (r != ERROR_SUCCESS)
339 MsiCloseHandle(info);
340 MsiCloseHandle(patch);
345 UINT WINAPI MsiConfigureProductExW(LPCWSTR szProduct, int iInstallLevel,
346 INSTALLSTATE eInstallState, LPCWSTR szCommandLine)
348 MSIPACKAGE* package = NULL;
351 WCHAR sourcepath[MAX_PATH];
352 WCHAR filename[MAX_PATH];
353 static const WCHAR szInstalled[] = {
354 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
357 TRACE("%s %d %d %s\n",debugstr_w(szProduct), iInstallLevel, eInstallState,
358 debugstr_w(szCommandLine));
360 if (eInstallState != INSTALLSTATE_LOCAL &&
361 eInstallState != INSTALLSTATE_DEFAULT)
363 FIXME("Not implemented for anything other than local installs\n");
364 return ERROR_CALL_NOT_IMPLEMENTED;
367 sz = sizeof(sourcepath);
368 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
369 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath,
372 sz = sizeof(filename);
373 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
374 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
376 lstrcatW(sourcepath,filename);
379 * ok 1, we need to find the msi file for this product.
380 * 2, find the source dir for the files
381 * 3, do the configure/install.
382 * 4, cleanupany runonce entry.
385 r = MSI_OpenProductW( szProduct, &package );
386 if (r != ERROR_SUCCESS)
389 sz = lstrlenW(szInstalled) + 1;
392 sz += lstrlenW(szCommandLine);
394 commandline = msi_alloc(sz * sizeof(WCHAR));
397 r = ERROR_OUTOFMEMORY;
403 lstrcpyW(commandline,szCommandLine);
405 if (MsiQueryProductStateW(szProduct) != INSTALLSTATE_UNKNOWN)
406 lstrcatW(commandline,szInstalled);
408 r = MSI_InstallPackage( package, sourcepath, commandline );
410 msi_free(commandline);
413 msiobj_release( &package->hdr );
418 UINT WINAPI MsiConfigureProductExA(LPCSTR szProduct, int iInstallLevel,
419 INSTALLSTATE eInstallState, LPCSTR szCommandLine)
421 LPWSTR szwProduct = NULL;
422 LPWSTR szwCommandLine = NULL;
423 UINT r = ERROR_OUTOFMEMORY;
427 szwProduct = strdupAtoW( szProduct );
434 szwCommandLine = strdupAtoW( szCommandLine );
439 r = MsiConfigureProductExW( szwProduct, iInstallLevel, eInstallState,
442 msi_free( szwProduct );
443 msi_free( szwCommandLine);
448 UINT WINAPI MsiConfigureProductA(LPCSTR szProduct, int iInstallLevel,
449 INSTALLSTATE eInstallState)
451 LPWSTR szwProduct = NULL;
454 TRACE("%s %d %d\n",debugstr_a(szProduct), iInstallLevel, eInstallState);
458 szwProduct = strdupAtoW( szProduct );
460 return ERROR_OUTOFMEMORY;
463 r = MsiConfigureProductW( szwProduct, iInstallLevel, eInstallState );
464 msi_free( szwProduct );
469 UINT WINAPI MsiConfigureProductW(LPCWSTR szProduct, int iInstallLevel,
470 INSTALLSTATE eInstallState)
472 return MsiConfigureProductExW(szProduct, iInstallLevel, eInstallState, NULL);
475 UINT WINAPI MsiGetProductCodeA(LPCSTR szComponent, LPSTR szBuffer)
477 LPWSTR szwComponent = NULL;
479 WCHAR szwBuffer[GUID_SIZE];
481 TRACE("%s %s\n",debugstr_a(szComponent), debugstr_a(szBuffer));
485 szwComponent = strdupAtoW( szComponent );
487 return ERROR_OUTOFMEMORY;
490 r = MsiGetProductCodeW( szwComponent, szwBuffer );
492 if( ERROR_SUCCESS == r )
493 WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, GUID_SIZE, NULL, NULL);
495 msi_free( szwComponent );
500 UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
504 WCHAR szSquished[GUID_SIZE];
505 DWORD sz = GUID_SIZE;
506 static const WCHAR szPermKey[] =
507 { '0','0','0','0','0','0','0','0','0','0','0','0',
508 '0','0','0','0','0','0','0','0','0','0','0','0',
509 '0','0','0','0','0','0','0','0',0};
511 TRACE("%s %p\n",debugstr_w(szComponent), szBuffer);
513 if (NULL == szComponent)
514 return ERROR_INVALID_PARAMETER;
516 rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
517 if (rc != ERROR_SUCCESS)
518 return ERROR_UNKNOWN_COMPONENT;
520 rc = RegEnumValueW(hkey, 0, szSquished, &sz, NULL, NULL, NULL, NULL);
521 if (rc == ERROR_SUCCESS && strcmpW(szSquished,szPermKey)==0)
524 rc = RegEnumValueW(hkey, 1, szSquished, &sz, NULL, NULL, NULL, NULL);
529 if (rc != ERROR_SUCCESS)
530 return ERROR_INSTALL_FAILURE;
532 unsquash_guid(szSquished, szBuffer);
533 return ERROR_SUCCESS;
536 static UINT WINAPI MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
537 awstring *szValue, LPDWORD pcchValueBuf)
543 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
544 debugstr_w(szAttribute), szValue, pcchValueBuf);
547 * FIXME: Values seem scattered/duplicated in the registry. Is there a system?
550 if ((szValue->str.w && !pcchValueBuf) || !szProduct || !szProduct[0] || !szAttribute)
551 return ERROR_INVALID_PARAMETER;
553 /* check for special properties */
554 if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW))
557 WCHAR packagecode[35];
559 r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
560 if (r != ERROR_SUCCESS)
561 return ERROR_UNKNOWN_PRODUCT;
563 regval = msi_reg_get_val_str( hkey, szAttribute );
566 if (unsquash_guid(regval, packagecode))
567 val = strdupW(packagecode);
573 else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW))
575 static const WCHAR one[] = { '1',0 };
577 * FIXME: should be in the Product key (user or system?)
578 * but isn't written yet...
580 val = strdupW( one );
582 else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_LANGUAGEW) ||
583 !lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONW))
585 static const WCHAR fmt[] = { '%','u',0 };
589 r = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE);
590 if (r != ERROR_SUCCESS)
591 return ERROR_UNKNOWN_PRODUCT;
593 if (msi_reg_get_val_dword( hkey, szAttribute, ®val))
595 sprintfW(szVal, fmt, regval);
596 val = strdupW( szVal );
601 else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTNAMEW))
603 r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
604 if (r != ERROR_SUCCESS)
605 return ERROR_UNKNOWN_PRODUCT;
607 val = msi_reg_get_val_str( hkey, szAttribute );
611 else if (!szAttribute[0])
613 return ERROR_UNKNOWN_PROPERTY;
617 static const WCHAR szDisplayVersion[] = {
618 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0 };
620 FIXME("%s\n", debugstr_w(szAttribute));
621 /* FIXME: some attribute values not tested... */
623 if (!lstrcmpW( szAttribute, INSTALLPROPERTY_VERSIONSTRINGW ))
624 szAttribute = szDisplayVersion;
626 r = MSIREG_OpenUninstallKey( szProduct, &hkey, FALSE );
627 if (r != ERROR_SUCCESS)
628 return ERROR_UNKNOWN_PRODUCT;
630 val = msi_reg_get_val_str( hkey, szAttribute );
635 TRACE("returning %s\n", debugstr_w(val));
638 return ERROR_UNKNOWN_PROPERTY;
640 r = msi_strcpy_to_awstring( val, szValue, pcchValueBuf );
647 UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
648 LPSTR szBuffer, LPDWORD pcchValueBuf)
650 LPWSTR szwProduct, szwAttribute = NULL;
651 UINT r = ERROR_OUTOFMEMORY;
654 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
655 szBuffer, pcchValueBuf);
657 szwProduct = strdupAtoW( szProduct );
658 if( szProduct && !szwProduct )
661 szwAttribute = strdupAtoW( szAttribute );
662 if( szAttribute && !szwAttribute )
665 buffer.unicode = FALSE;
666 buffer.str.a = szBuffer;
668 r = MSI_GetProductInfo( szwProduct, szwAttribute,
669 &buffer, pcchValueBuf );
672 msi_free( szwProduct );
673 msi_free( szwAttribute );
678 UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
679 LPWSTR szBuffer, LPDWORD pcchValueBuf)
683 TRACE("%s %s %p %p\n", debugstr_w(szProduct), debugstr_w(szAttribute),
684 szBuffer, pcchValueBuf);
686 buffer.unicode = TRUE;
687 buffer.str.w = szBuffer;
689 return MSI_GetProductInfo( szProduct, szAttribute,
690 &buffer, pcchValueBuf );
693 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
695 LPWSTR szwLogFile = NULL;
698 TRACE("%08x %s %08x\n", dwLogMode, debugstr_a(szLogFile), attributes);
702 szwLogFile = strdupAtoW( szLogFile );
704 return ERROR_OUTOFMEMORY;
706 r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
707 msi_free( szwLogFile );
711 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
713 HANDLE file = INVALID_HANDLE_VALUE;
715 TRACE("%08x %s %08x\n", dwLogMode, debugstr_w(szLogFile), attributes);
719 lstrcpyW(gszLogFile,szLogFile);
720 if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
721 DeleteFileW(szLogFile);
722 file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
723 FILE_ATTRIBUTE_NORMAL, NULL);
724 if (file != INVALID_HANDLE_VALUE)
727 ERR("Unable to enable log %s\n",debugstr_w(szLogFile));
730 gszLogFile[0] = '\0';
732 return ERROR_SUCCESS;
735 UINT WINAPI MsiQueryComponentStateA(LPCSTR szProductCode,
736 LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext,
737 LPCSTR szComponent, INSTALLSTATE *pdwState)
739 LPWSTR prodcode = NULL, usersid = NULL, comp = NULL;
742 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode),
743 debugstr_a(szUserSid), dwContext, debugstr_a(szComponent), pdwState);
745 if (szProductCode && !(prodcode = strdupAtoW(szProductCode)))
746 return ERROR_OUTOFMEMORY;
748 if (szUserSid && !(usersid = strdupAtoW(szUserSid)))
749 return ERROR_OUTOFMEMORY;
751 if (szComponent && !(comp = strdupAtoW(szComponent)))
752 return ERROR_OUTOFMEMORY;
754 r = MsiQueryComponentStateW(prodcode, usersid, dwContext, comp, pdwState);
763 static BOOL msi_comp_find_prod_key(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
768 if (context == MSIINSTALLCONTEXT_MACHINE)
769 r = MSIREG_OpenLocalClassesProductKey(prodcode, &hkey, FALSE);
770 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
771 r = MSIREG_OpenUserProductsKey(prodcode, &hkey, FALSE);
773 r = MSIREG_OpenLocalManagedProductKey(prodcode, &hkey, FALSE);
776 return (r == ERROR_SUCCESS);
779 static BOOL msi_comp_find_package(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
787 static const WCHAR local_package[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
788 static const WCHAR managed_local_package[] = {
789 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
792 if (context == MSIINSTALLCONTEXT_MACHINE)
793 r = MSIREG_OpenLocalSystemProductKey(prodcode, &hkey, FALSE);
795 r = MSIREG_OpenInstallPropertiesKey(prodcode, &hkey, FALSE);
797 if (r != ERROR_SUCCESS)
800 if (context == MSIINSTALLCONTEXT_USERMANAGED)
801 package = managed_local_package;
803 package = local_package;
806 res = RegQueryValueExW(hkey, package, NULL, NULL, NULL, &sz);
809 return (res == ERROR_SUCCESS);
812 static BOOL msi_comp_find_prodcode(LPCWSTR prodcode, LPWSTR squished_pc,
813 MSIINSTALLCONTEXT context,
814 LPCWSTR comp, DWORD *sz)
820 if (context == MSIINSTALLCONTEXT_MACHINE)
821 r = MSIREG_OpenLocalSystemComponentKey(comp, &hkey, FALSE);
823 r = MSIREG_OpenUserDataComponentKey(comp, &hkey, FALSE);
825 if (r != ERROR_SUCCESS)
829 res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, NULL, sz);
830 if (res != ERROR_SUCCESS)
837 UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
838 LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext,
839 LPCWSTR szComponent, INSTALLSTATE *pdwState)
841 WCHAR squished_pc[GUID_SIZE];
845 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode),
846 debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState);
849 return ERROR_INVALID_PARAMETER;
851 if (!szProductCode || !*szProductCode || lstrlenW(szProductCode) != GUID_SIZE - 1)
852 return ERROR_INVALID_PARAMETER;
854 if (!squash_guid(szProductCode, squished_pc))
855 return ERROR_INVALID_PARAMETER;
857 found = msi_comp_find_prod_key(szProductCode, dwContext);
859 if (!msi_comp_find_package(szProductCode, dwContext))
863 *pdwState = INSTALLSTATE_UNKNOWN;
864 return ERROR_UNKNOWN_COMPONENT;
867 return ERROR_UNKNOWN_PRODUCT;
870 *pdwState = INSTALLSTATE_UNKNOWN;
872 if (!msi_comp_find_prodcode(szProductCode, squished_pc, dwContext, szComponent, &sz))
873 return ERROR_UNKNOWN_COMPONENT;
876 *pdwState = INSTALLSTATE_NOTUSED;
878 *pdwState = INSTALLSTATE_LOCAL;
880 return ERROR_SUCCESS;
883 INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
885 LPWSTR szwProduct = NULL;
890 szwProduct = strdupAtoW( szProduct );
892 return ERROR_OUTOFMEMORY;
894 r = MsiQueryProductStateW( szwProduct );
895 msi_free( szwProduct );
899 INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
902 INSTALLSTATE state = INSTALLSTATE_UNKNOWN;
903 HKEY hkey = 0, props = 0;
905 BOOL userkey_exists = FALSE;
907 static const int GUID_LEN = 38;
908 static const WCHAR szInstallProperties[] = {
909 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0
911 static const WCHAR szWindowsInstaller[] = {
912 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0
915 TRACE("%s\n", debugstr_w(szProduct));
917 if (!szProduct || !*szProduct || lstrlenW(szProduct) != GUID_LEN)
918 return INSTALLSTATE_INVALIDARG;
920 rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
921 if (rc == ERROR_SUCCESS)
923 userkey_exists = TRUE;
924 state = INSTALLSTATE_ADVERTISED;
928 rc = MSIREG_OpenUserDataProductKey(szProduct,&hkey,FALSE);
929 if (rc != ERROR_SUCCESS)
932 rc = RegOpenKeyW(hkey, szInstallProperties, &props);
933 if (rc != ERROR_SUCCESS)
937 rc = RegQueryValueExW(props,szWindowsInstaller,NULL,NULL,(LPVOID)&state, &sz);
938 if (rc != ERROR_SUCCESS)
942 state = INSTALLSTATE_DEFAULT;
944 state = INSTALLSTATE_UNKNOWN;
946 if (state == INSTALLSTATE_DEFAULT && !userkey_exists)
947 state = INSTALLSTATE_ABSENT;
955 INSTALLUILEVEL WINAPI MsiSetInternalUI(INSTALLUILEVEL dwUILevel, HWND *phWnd)
957 INSTALLUILEVEL old = gUILevel;
958 HWND oldwnd = gUIhwnd;
960 TRACE("%08x %p\n", dwUILevel, phWnd);
962 gUILevel = dwUILevel;
971 INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler,
972 DWORD dwMessageFilter, LPVOID pvContext)
974 INSTALLUI_HANDLERA prev = gUIHandlerA;
976 TRACE("%p %x %p\n",puiHandler, dwMessageFilter,pvContext);
977 gUIHandlerA = puiHandler;
978 gUIFilter = dwMessageFilter;
979 gUIContext = pvContext;
984 INSTALLUI_HANDLERW WINAPI MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler,
985 DWORD dwMessageFilter, LPVOID pvContext)
987 INSTALLUI_HANDLERW prev = gUIHandlerW;
989 TRACE("%p %x %p\n",puiHandler,dwMessageFilter,pvContext);
990 gUIHandlerW = puiHandler;
991 gUIFilter = dwMessageFilter;
992 gUIContext = pvContext;
997 /******************************************************************
998 * MsiLoadStringW [MSI.@]
1000 * Loads a string from MSI's string resources.
1004 * handle [I] only -1 is handled currently
1005 * id [I] id of the string to be loaded
1006 * lpBuffer [O] buffer for the string to be written to
1007 * nBufferMax [I] maximum size of the buffer in characters
1008 * lang [I] the preferred language for the string
1012 * If successful, this function returns the language id of the string loaded
1013 * If the function fails, the function returns zero.
1017 * The type of the first parameter is unknown. LoadString's prototype
1018 * suggests that it might be a module handle. I have made it an MSI handle
1019 * for starters, as -1 is an invalid MSI handle, but not an invalid module
1020 * handle. Maybe strings can be stored in an MSI database somehow.
1022 LANGID WINAPI MsiLoadStringW( MSIHANDLE handle, UINT id, LPWSTR lpBuffer,
1023 int nBufferMax, LANGID lang )
1030 TRACE("%ld %u %p %d %d\n", handle, id, lpBuffer, nBufferMax, lang);
1033 FIXME("don't know how to deal with handle = %08lx\n", handle);
1036 lang = GetUserDefaultLangID();
1038 hres = FindResourceExW( msi_hInstance, (LPCWSTR) RT_STRING,
1042 hResData = LoadResource( msi_hInstance, hres );
1045 p = LockResource( hResData );
1049 for (i = 0; i < (id&0xf); i++)
1053 if( nBufferMax <= len )
1056 memcpy( lpBuffer, p+1, len * sizeof(WCHAR));
1057 lpBuffer[ len ] = 0;
1059 TRACE("found -> %s\n", debugstr_w(lpBuffer));
1064 LANGID WINAPI MsiLoadStringA( MSIHANDLE handle, UINT id, LPSTR lpBuffer,
1065 int nBufferMax, LANGID lang )
1071 bufW = msi_alloc(nBufferMax*sizeof(WCHAR));
1072 r = MsiLoadStringW(handle, id, bufW, nBufferMax, lang);
1075 len = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL, NULL );
1076 if( len <= nBufferMax )
1077 WideCharToMultiByte( CP_ACP, 0, bufW, -1,
1078 lpBuffer, nBufferMax, NULL, NULL );
1086 INSTALLSTATE WINAPI MsiLocateComponentA(LPCSTR szComponent, LPSTR lpPathBuf,
1089 char szProduct[GUID_SIZE];
1091 TRACE("%s %p %p\n", debugstr_a(szComponent), lpPathBuf, pcchBuf);
1093 if (MsiGetProductCodeA( szComponent, szProduct ) != ERROR_SUCCESS)
1094 return INSTALLSTATE_UNKNOWN;
1096 return MsiGetComponentPathA( szProduct, szComponent, lpPathBuf, pcchBuf );
1099 INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
1102 WCHAR szProduct[GUID_SIZE];
1104 TRACE("%s %p %p\n", debugstr_w(szComponent), lpPathBuf, pcchBuf);
1106 if (MsiGetProductCodeW( szComponent, szProduct ) != ERROR_SUCCESS)
1107 return INSTALLSTATE_UNKNOWN;
1109 return MsiGetComponentPathW( szProduct, szComponent, lpPathBuf, pcchBuf );
1112 UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
1113 WORD wLanguageId, DWORD f)
1115 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_a(lpText), debugstr_a(lpCaption),
1116 uType, wLanguageId, f);
1117 return MessageBoxExA(hWnd,lpText,lpCaption,uType,wLanguageId);
1120 UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
1121 WORD wLanguageId, DWORD f)
1123 FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_w(lpText), debugstr_w(lpCaption),
1124 uType, wLanguageId, f);
1125 return MessageBoxExW(hWnd,lpText,lpCaption,uType,wLanguageId);
1128 UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
1129 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
1130 LPDWORD pcchPathBuf )
1132 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName),
1133 debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
1135 return ERROR_CALL_NOT_IMPLEMENTED;
1138 UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
1139 DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
1140 LPDWORD pcchPathBuf )
1142 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName),
1143 debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
1145 return ERROR_CALL_NOT_IMPLEMENTED;
1148 UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
1149 LPSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
1151 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
1152 return ERROR_CALL_NOT_IMPLEMENTED;
1155 UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
1156 LPWSTR szPath, LPDWORD pcchPath, LPDWORD pcchArgs )
1158 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
1159 return ERROR_CALL_NOT_IMPLEMENTED;
1162 HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
1163 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
1164 LPDWORD pcbHashData)
1166 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
1167 ppcCertContext, pbHashData, pcbHashData);
1168 return ERROR_CALL_NOT_IMPLEMENTED;
1171 HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
1172 DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, LPBYTE pbHashData,
1173 LPDWORD pcbHashData)
1175 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
1176 ppcCertContext, pbHashData, pcbHashData);
1177 return ERROR_CALL_NOT_IMPLEMENTED;
1180 UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
1181 LPSTR szValue, LPDWORD pccbValue )
1183 FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
1184 return ERROR_CALL_NOT_IMPLEMENTED;
1187 UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
1188 LPWSTR szValue, LPDWORD pccbValue )
1190 FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
1191 return ERROR_CALL_NOT_IMPLEMENTED;
1194 UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
1197 LPWSTR szPack = NULL;
1199 TRACE("%s\n", debugstr_a(szPackage) );
1203 szPack = strdupAtoW( szPackage );
1205 return ERROR_OUTOFMEMORY;
1208 r = MsiVerifyPackageW( szPack );
1215 UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
1220 TRACE("%s\n", debugstr_w(szPackage) );
1222 r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
1223 MsiCloseHandle( handle );
1228 static INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
1229 awstring* lpPathBuf, LPDWORD pcchBuf)
1231 WCHAR squished_pc[GUID_SIZE], squished_comp[GUID_SIZE];
1237 TRACE("%s %s %p %p\n", debugstr_w(szProduct),
1238 debugstr_w(szComponent), lpPathBuf->str.w, pcchBuf);
1240 if( !szProduct || !szComponent )
1241 return INSTALLSTATE_INVALIDARG;
1242 if( lpPathBuf->str.w && !pcchBuf )
1243 return INSTALLSTATE_INVALIDARG;
1245 if (!squash_guid( szProduct, squished_pc ) ||
1246 !squash_guid( szComponent, squished_comp ))
1247 return INSTALLSTATE_INVALIDARG;
1249 rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
1250 if( rc != ERROR_SUCCESS )
1251 return INSTALLSTATE_UNKNOWN;
1255 rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
1256 if( rc != ERROR_SUCCESS )
1257 return INSTALLSTATE_UNKNOWN;
1259 path = msi_reg_get_val_str( hkey, squished_pc );
1262 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
1263 debugstr_w(szProduct), debugstr_w(path));
1266 return INSTALLSTATE_UNKNOWN;
1269 r = INSTALLSTATE_LOCAL;
1271 r = INSTALLSTATE_NOTUSED;
1273 msi_strcpy_to_awstring( path, lpPathBuf, pcchBuf );
1279 /******************************************************************
1280 * MsiGetComponentPathW [MSI.@]
1282 INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
1283 LPWSTR lpPathBuf, LPDWORD pcchBuf)
1287 path.unicode = TRUE;
1288 path.str.w = lpPathBuf;
1290 return MSI_GetComponentPath( szProduct, szComponent, &path, pcchBuf );
1293 /******************************************************************
1294 * MsiGetComponentPathA [MSI.@]
1296 INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
1297 LPSTR lpPathBuf, LPDWORD pcchBuf)
1299 LPWSTR szwProduct, szwComponent = NULL;
1300 INSTALLSTATE r = INSTALLSTATE_UNKNOWN;
1303 szwProduct = strdupAtoW( szProduct );
1304 if( szProduct && !szwProduct)
1307 szwComponent = strdupAtoW( szComponent );
1308 if( szComponent && !szwComponent )
1311 path.unicode = FALSE;
1312 path.str.a = lpPathBuf;
1314 r = MSI_GetComponentPath( szwProduct, szwComponent, &path, pcchBuf );
1317 msi_free( szwProduct );
1318 msi_free( szwComponent );
1323 /******************************************************************
1324 * MsiQueryFeatureStateA [MSI.@]
1326 INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
1328 LPWSTR szwProduct = NULL, szwFeature= NULL;
1329 INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
1331 szwProduct = strdupAtoW( szProduct );
1332 if ( szProduct && !szwProduct )
1335 szwFeature = strdupAtoW( szFeature );
1336 if ( szFeature && !szwFeature )
1339 rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
1342 msi_free( szwProduct);
1343 msi_free( szwFeature);
1348 /******************************************************************
1349 * MsiQueryFeatureStateW [MSI.@]
1351 * Checks the state of a feature
1354 * szProduct [I] Product's GUID string
1355 * szFeature [I] Feature's GUID string
1358 * INSTALLSTATE_LOCAL Feature is installed and useable
1359 * INSTALLSTATE_ABSENT Feature is absent
1360 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
1361 * INSTALLSTATE_UNKNOWN An error occurred
1362 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
1365 INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
1367 WCHAR squishProduct[33], comp[GUID_SIZE];
1369 LPWSTR components, p, parent_feature, path;
1373 BOOL missing = FALSE;
1375 TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
1377 if (!szProduct || !szFeature)
1378 return INSTALLSTATE_INVALIDARG;
1380 if (!squash_guid( szProduct, squishProduct ))
1381 return INSTALLSTATE_INVALIDARG;
1383 /* check that it's installed at all */
1384 rc = MSIREG_OpenUserFeaturesKey(szProduct, &hkey, FALSE);
1385 if (rc != ERROR_SUCCESS)
1386 return INSTALLSTATE_UNKNOWN;
1388 parent_feature = msi_reg_get_val_str( hkey, szFeature );
1391 if (!parent_feature)
1392 return INSTALLSTATE_UNKNOWN;
1394 r = (parent_feature[0] == 6) ? INSTALLSTATE_ABSENT : INSTALLSTATE_LOCAL;
1395 msi_free(parent_feature);
1396 if (r == INSTALLSTATE_ABSENT)
1399 /* now check if it's complete or advertised */
1400 rc = MSIREG_OpenUserDataFeaturesKey(szProduct, &hkey, FALSE);
1401 if (rc != ERROR_SUCCESS)
1402 return INSTALLSTATE_ADVERTISED;
1404 components = msi_reg_get_val_str( hkey, szFeature );
1407 TRACE("rc = %d buffer = %s\n", rc, debugstr_w(components));
1410 return INSTALLSTATE_ADVERTISED;
1412 for( p = components; *p && *p != 2 ; p += 20)
1414 if (!decode_base85_guid( p, &guid ))
1416 if (p != components)
1419 msi_free(components);
1420 return INSTALLSTATE_BADCONFIG;
1423 StringFromGUID2(&guid, comp, GUID_SIZE);
1424 rc = MSIREG_OpenUserDataComponentKey(comp, &hkey, FALSE);
1425 if (rc != ERROR_SUCCESS)
1427 msi_free(components);
1428 return INSTALLSTATE_ADVERTISED;
1431 path = msi_reg_get_val_str(hkey, squishProduct);
1438 TRACE("%s %s -> %d\n", debugstr_w(szProduct), debugstr_w(szFeature), r);
1439 msi_free(components);
1442 return INSTALLSTATE_ADVERTISED;
1444 return INSTALLSTATE_LOCAL;
1447 /******************************************************************
1448 * MsiGetFileVersionA [MSI.@]
1450 UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
1451 LPDWORD pcchVersionBuf, LPSTR lpLangBuf, LPDWORD pcchLangBuf)
1453 LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
1454 UINT ret = ERROR_OUTOFMEMORY;
1458 szwFilePath = strdupAtoW( szFilePath );
1463 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1465 lpwVersionBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
1466 if( !lpwVersionBuff )
1470 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1472 lpwLangBuff = msi_alloc(*pcchLangBuf*sizeof(WCHAR));
1477 ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
1478 lpwLangBuff, pcchLangBuf);
1480 if( lpwVersionBuff )
1481 WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
1482 lpVersionBuf, *pcchVersionBuf, NULL, NULL);
1484 WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
1485 lpLangBuf, *pcchLangBuf, NULL, NULL);
1488 msi_free(szwFilePath);
1489 msi_free(lpwVersionBuff);
1490 msi_free(lpwLangBuff);
1495 /******************************************************************
1496 * MsiGetFileVersionW [MSI.@]
1498 UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
1499 LPDWORD pcchVersionBuf, LPWSTR lpLangBuf, LPDWORD pcchLangBuf)
1501 static const WCHAR szVersionResource[] = {'\\',0};
1502 static const WCHAR szVersionFormat[] = {
1503 '%','d','.','%','d','.','%','d','.','%','d',0};
1504 static const WCHAR szLangFormat[] = {'%','d',0};
1507 LPVOID lpVer = NULL;
1508 VS_FIXEDFILEINFO *ffi;
1512 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath),
1513 lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
1514 lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
1516 dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
1518 return GetLastError();
1520 lpVer = msi_alloc(dwVerLen);
1523 ret = ERROR_OUTOFMEMORY;
1527 if( !GetFileVersionInfoW(szFilePath, 0, dwVerLen, lpVer) )
1529 ret = GetLastError();
1532 if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
1534 if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
1537 wsprintfW(tmp, szVersionFormat,
1538 HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
1539 HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
1540 lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
1541 *pcchVersionBuf = lstrlenW(lpVersionBuf);
1546 *pcchVersionBuf = 0;
1550 if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
1552 DWORD lang = GetUserDefaultLangID();
1554 FIXME("Retrieve language from file\n");
1555 wsprintfW(tmp, szLangFormat, lang);
1556 lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
1557 *pcchLangBuf = lstrlenW(lpLangBuf);
1565 /***********************************************************************
1566 * MsiGetFeatureUsageW [MSI.@]
1568 UINT WINAPI MsiGetFeatureUsageW( LPCWSTR szProduct, LPCWSTR szFeature,
1569 LPDWORD pdwUseCount, LPWORD pwDateUsed )
1571 FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szFeature),
1572 pdwUseCount, pwDateUsed);
1573 return ERROR_CALL_NOT_IMPLEMENTED;
1576 /***********************************************************************
1577 * MsiGetFeatureUsageA [MSI.@]
1579 UINT WINAPI MsiGetFeatureUsageA( LPCSTR szProduct, LPCSTR szFeature,
1580 LPDWORD pdwUseCount, LPWORD pwDateUsed )
1582 LPWSTR prod = NULL, feat = NULL;
1583 UINT ret = ERROR_OUTOFMEMORY;
1585 TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szFeature),
1586 pdwUseCount, pwDateUsed);
1588 prod = strdupAtoW( szProduct );
1589 if (szProduct && !prod)
1592 feat = strdupAtoW( szFeature );
1593 if (szFeature && !feat)
1596 ret = MsiGetFeatureUsageW( prod, feat, pdwUseCount, pwDateUsed );
1605 /***********************************************************************
1606 * MsiUseFeatureExW [MSI.@]
1608 INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
1609 DWORD dwInstallMode, DWORD dwReserved )
1613 TRACE("%s %s %i %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
1614 dwInstallMode, dwReserved);
1616 state = MsiQueryFeatureStateW( szProduct, szFeature );
1619 return INSTALLSTATE_INVALIDARG;
1621 if (state == INSTALLSTATE_LOCAL && dwInstallMode != INSTALLMODE_NODETECTION)
1623 FIXME("mark product %s feature %s as used\n",
1624 debugstr_w(szProduct), debugstr_w(szFeature) );
1630 /***********************************************************************
1631 * MsiUseFeatureExA [MSI.@]
1633 INSTALLSTATE WINAPI MsiUseFeatureExA( LPCSTR szProduct, LPCSTR szFeature,
1634 DWORD dwInstallMode, DWORD dwReserved )
1636 INSTALLSTATE ret = INSTALLSTATE_UNKNOWN;
1637 LPWSTR prod = NULL, feat = NULL;
1639 TRACE("%s %s %i %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
1640 dwInstallMode, dwReserved);
1642 prod = strdupAtoW( szProduct );
1643 if (szProduct && !prod)
1646 feat = strdupAtoW( szFeature );
1647 if (szFeature && !feat)
1650 ret = MsiUseFeatureExW( prod, feat, dwInstallMode, dwReserved );
1659 /***********************************************************************
1660 * MsiUseFeatureW [MSI.@]
1662 INSTALLSTATE WINAPI MsiUseFeatureW( LPCWSTR szProduct, LPCWSTR szFeature )
1664 return MsiUseFeatureExW(szProduct, szFeature, 0, 0);
1667 /***********************************************************************
1668 * MsiUseFeatureA [MSI.@]
1670 INSTALLSTATE WINAPI MsiUseFeatureA( LPCSTR szProduct, LPCSTR szFeature )
1672 return MsiUseFeatureExA(szProduct, szFeature, 0, 0);
1675 /***********************************************************************
1676 * MSI_ProvideQualifiedComponentEx [internal]
1678 static UINT WINAPI MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent,
1679 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
1680 DWORD Unused1, DWORD Unused2, awstring *lpPathBuf,
1681 LPDWORD pcchPathBuf)
1683 WCHAR product[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1],
1684 feature[MAX_FEATURE_CHARS+1];
1690 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent),
1691 debugstr_w(szQualifier), dwInstallMode, debugstr_w(szProduct),
1692 Unused1, Unused2, lpPathBuf, pcchPathBuf);
1694 rc = MSIREG_OpenUserComponentsKey(szComponent, &hkey, FALSE);
1695 if (rc != ERROR_SUCCESS)
1696 return ERROR_INDEX_ABSENT;
1698 info = msi_reg_get_val_str( hkey, szQualifier );
1702 return ERROR_INDEX_ABSENT;
1704 MsiDecomposeDescriptorW(info, product, feature, component, &sz);
1707 rc = MSI_GetComponentPath(product, component, lpPathBuf, pcchPathBuf);
1709 rc = MSI_GetComponentPath(szProduct, component, lpPathBuf, pcchPathBuf);
1713 if (rc != INSTALLSTATE_LOCAL)
1714 return ERROR_FILE_NOT_FOUND;
1716 return ERROR_SUCCESS;
1719 /***********************************************************************
1720 * MsiProvideQualifiedComponentExW [MSI.@]
1722 UINT WINAPI MsiProvideQualifiedComponentExW(LPCWSTR szComponent,
1723 LPCWSTR szQualifier, DWORD dwInstallMode, LPCWSTR szProduct,
1724 DWORD Unused1, DWORD Unused2, LPWSTR lpPathBuf,
1725 LPDWORD pcchPathBuf)
1729 path.unicode = TRUE;
1730 path.str.w = lpPathBuf;
1732 return MSI_ProvideQualifiedComponentEx(szComponent, szQualifier,
1733 dwInstallMode, szProduct, Unused1, Unused2, &path, pcchPathBuf);
1736 /***********************************************************************
1737 * MsiProvideQualifiedComponentExA [MSI.@]
1739 UINT WINAPI MsiProvideQualifiedComponentExA(LPCSTR szComponent,
1740 LPCSTR szQualifier, DWORD dwInstallMode, LPCSTR szProduct,
1741 DWORD Unused1, DWORD Unused2, LPSTR lpPathBuf,
1742 LPDWORD pcchPathBuf)
1744 LPWSTR szwComponent, szwQualifier = NULL, szwProduct = NULL;
1745 UINT r = ERROR_OUTOFMEMORY;
1748 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent),
1749 debugstr_a(szQualifier), dwInstallMode, debugstr_a(szProduct),
1750 Unused1, Unused2, lpPathBuf, pcchPathBuf);
1752 szwComponent = strdupAtoW( szComponent );
1753 if (szComponent && !szwComponent)
1756 szwQualifier = strdupAtoW( szQualifier );
1757 if (szQualifier && !szwQualifier)
1760 szwProduct = strdupAtoW( szProduct );
1761 if (szProduct && !szwProduct)
1764 path.unicode = FALSE;
1765 path.str.a = lpPathBuf;
1767 r = MSI_ProvideQualifiedComponentEx(szwComponent, szwQualifier,
1768 dwInstallMode, szwProduct, Unused1,
1769 Unused2, &path, pcchPathBuf);
1771 msi_free(szwProduct);
1772 msi_free(szwComponent);
1773 msi_free(szwQualifier);
1778 /***********************************************************************
1779 * MsiProvideQualifiedComponentW [MSI.@]
1781 UINT WINAPI MsiProvideQualifiedComponentW( LPCWSTR szComponent,
1782 LPCWSTR szQualifier, DWORD dwInstallMode, LPWSTR lpPathBuf,
1783 LPDWORD pcchPathBuf)
1785 return MsiProvideQualifiedComponentExW(szComponent, szQualifier,
1786 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
1789 /***********************************************************************
1790 * MsiProvideQualifiedComponentA [MSI.@]
1792 UINT WINAPI MsiProvideQualifiedComponentA( LPCSTR szComponent,
1793 LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf,
1794 LPDWORD pcchPathBuf)
1796 return MsiProvideQualifiedComponentExA(szComponent, szQualifier,
1797 dwInstallMode, NULL, 0, 0, lpPathBuf, pcchPathBuf);
1800 /***********************************************************************
1801 * MSI_GetUserInfo [internal]
1803 static USERINFOSTATE WINAPI MSI_GetUserInfo(LPCWSTR szProduct,
1804 awstring *lpUserNameBuf, LPDWORD pcchUserNameBuf,
1805 awstring *lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
1806 awstring *lpSerialBuf, LPDWORD pcchSerialBuf)
1809 LPWSTR user, org, serial;
1811 USERINFOSTATE state;
1813 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct), lpUserNameBuf,
1814 pcchUserNameBuf, lpOrgNameBuf, pcchOrgNameBuf, lpSerialBuf,
1818 return USERINFOSTATE_INVALIDARG;
1820 r = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE);
1821 if (r != ERROR_SUCCESS)
1822 return USERINFOSTATE_UNKNOWN;
1824 user = msi_reg_get_val_str( hkey, INSTALLPROPERTY_REGOWNERW );
1825 org = msi_reg_get_val_str( hkey, INSTALLPROPERTY_REGCOMPANYW );
1826 serial = msi_reg_get_val_str( hkey, INSTALLPROPERTY_PRODUCTIDW );
1830 state = USERINFOSTATE_PRESENT;
1834 r = msi_strcpy_to_awstring( user, lpUserNameBuf, pcchUserNameBuf );
1835 if (r == ERROR_MORE_DATA)
1836 state = USERINFOSTATE_MOREDATA;
1839 state = USERINFOSTATE_ABSENT;
1842 r = msi_strcpy_to_awstring( org, lpOrgNameBuf, pcchOrgNameBuf );
1843 if (r == ERROR_MORE_DATA && state == USERINFOSTATE_PRESENT)
1844 state = USERINFOSTATE_MOREDATA;
1846 /* msdn states: The user information is considered to be present even in the absence of a company name. */
1849 r = msi_strcpy_to_awstring( serial, lpSerialBuf, pcchSerialBuf );
1850 if (r == ERROR_MORE_DATA && state == USERINFOSTATE_PRESENT)
1851 state = USERINFOSTATE_MOREDATA;
1854 state = USERINFOSTATE_ABSENT;
1863 /***********************************************************************
1864 * MsiGetUserInfoW [MSI.@]
1866 USERINFOSTATE WINAPI MsiGetUserInfoW(LPCWSTR szProduct,
1867 LPWSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
1868 LPWSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
1869 LPWSTR lpSerialBuf, LPDWORD pcchSerialBuf)
1871 awstring user, org, serial;
1873 user.unicode = TRUE;
1874 user.str.w = lpUserNameBuf;
1876 org.str.w = lpOrgNameBuf;
1877 serial.unicode = TRUE;
1878 serial.str.w = lpSerialBuf;
1880 return MSI_GetUserInfo( szProduct, &user, pcchUserNameBuf,
1881 &org, pcchOrgNameBuf,
1882 &serial, pcchSerialBuf );
1885 USERINFOSTATE WINAPI MsiGetUserInfoA(LPCSTR szProduct,
1886 LPSTR lpUserNameBuf, LPDWORD pcchUserNameBuf,
1887 LPSTR lpOrgNameBuf, LPDWORD pcchOrgNameBuf,
1888 LPSTR lpSerialBuf, LPDWORD pcchSerialBuf)
1890 awstring user, org, serial;
1894 prod = strdupAtoW( szProduct );
1895 if (szProduct && !prod)
1896 return ERROR_OUTOFMEMORY;
1898 user.unicode = FALSE;
1899 user.str.a = lpUserNameBuf;
1900 org.unicode = FALSE;
1901 org.str.a = lpOrgNameBuf;
1902 serial.unicode = FALSE;
1903 serial.str.a = lpSerialBuf;
1905 r = MSI_GetUserInfo( prod, &user, pcchUserNameBuf,
1906 &org, pcchOrgNameBuf,
1907 &serial, pcchSerialBuf );
1914 UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
1918 MSIPACKAGE *package;
1919 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1921 TRACE("(%s)\n",debugstr_w(szProduct));
1923 rc = MsiOpenProductW(szProduct,&handle);
1924 if (rc != ERROR_SUCCESS)
1925 return ERROR_INVALID_PARAMETER;
1927 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1928 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
1929 msiobj_release( &package->hdr );
1931 MsiCloseHandle(handle);
1936 UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
1940 MSIPACKAGE *package;
1941 static const WCHAR szFirstRun[] = {'F','i','r','s','t','R','u','n',0};
1943 TRACE("(%s)\n",debugstr_a(szProduct));
1945 rc = MsiOpenProductA(szProduct,&handle);
1946 if (rc != ERROR_SUCCESS)
1947 return ERROR_INVALID_PARAMETER;
1949 package = msihandle2msiinfo(handle, MSIHANDLETYPE_PACKAGE);
1950 rc = ACTION_PerformUIAction(package, szFirstRun, -1);
1951 msiobj_release( &package->hdr );
1953 MsiCloseHandle(handle);
1958 /***********************************************************************
1959 * MsiConfigureFeatureA [MSI.@]
1961 UINT WINAPI MsiConfigureFeatureA(LPCSTR szProduct, LPCSTR szFeature, INSTALLSTATE eInstallState)
1963 LPWSTR prod, feat = NULL;
1964 UINT r = ERROR_OUTOFMEMORY;
1966 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature), eInstallState);
1968 prod = strdupAtoW( szProduct );
1969 if (szProduct && !prod)
1972 feat = strdupAtoW( szFeature );
1973 if (szFeature && !feat)
1976 r = MsiConfigureFeatureW(prod, feat, eInstallState);
1985 /***********************************************************************
1986 * MsiConfigureFeatureW [MSI.@]
1988 UINT WINAPI MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLSTATE eInstallState)
1990 static const WCHAR szCostInit[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
1991 MSIPACKAGE *package = NULL;
1993 WCHAR sourcepath[MAX_PATH], filename[MAX_PATH];
1996 TRACE("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature), eInstallState);
1998 if (!szProduct || !szFeature)
1999 return ERROR_INVALID_PARAMETER;
2001 switch (eInstallState)
2003 case INSTALLSTATE_DEFAULT:
2004 /* FIXME: how do we figure out the default location? */
2005 eInstallState = INSTALLSTATE_LOCAL;
2007 case INSTALLSTATE_LOCAL:
2008 case INSTALLSTATE_SOURCE:
2009 case INSTALLSTATE_ABSENT:
2010 case INSTALLSTATE_ADVERTISED:
2013 return ERROR_INVALID_PARAMETER;
2016 r = MSI_OpenProductW( szProduct, &package );
2017 if (r != ERROR_SUCCESS)
2020 sz = sizeof(sourcepath);
2021 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
2022 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
2024 sz = sizeof(filename);
2025 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
2026 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
2028 lstrcatW( sourcepath, filename );
2030 MsiSetInternalUI( INSTALLUILEVEL_BASIC, NULL );
2032 r = ACTION_PerformUIAction( package, szCostInit, -1 );
2033 if (r != ERROR_SUCCESS)
2036 r = MSI_SetFeatureStateW( package, szFeature, eInstallState);
2037 if (r != ERROR_SUCCESS)
2040 r = MSI_InstallPackage( package, sourcepath, NULL );
2043 msiobj_release( &package->hdr );
2048 /***********************************************************************
2049 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
2051 * Notes: undocumented
2053 UINT WINAPI MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved)
2055 WCHAR path[MAX_PATH];
2057 TRACE("%d\n", dwReserved);
2061 FIXME("dwReserved=%d\n", dwReserved);
2062 return ERROR_INVALID_PARAMETER;
2065 if (!GetWindowsDirectoryW(path, MAX_PATH))
2066 return ERROR_FUNCTION_FAILED;
2068 lstrcatW(path, installerW);
2070 if (!CreateDirectoryW(path, NULL))
2071 return ERROR_FUNCTION_FAILED;
2073 return ERROR_SUCCESS;
2076 /***********************************************************************
2077 * MsiGetShortcutTargetA [MSI.@]
2079 UINT WINAPI MsiGetShortcutTargetA( LPCSTR szShortcutTarget,
2080 LPSTR szProductCode, LPSTR szFeatureId,
2081 LPSTR szComponentCode )
2084 const int len = MAX_FEATURE_CHARS+1;
2085 WCHAR product[MAX_FEATURE_CHARS+1], feature[MAX_FEATURE_CHARS+1], component[MAX_FEATURE_CHARS+1];
2088 target = strdupAtoW( szShortcutTarget );
2089 if (szShortcutTarget && !target )
2090 return ERROR_OUTOFMEMORY;
2094 r = MsiGetShortcutTargetW( target, product, feature, component );
2096 if (r == ERROR_SUCCESS)
2098 WideCharToMultiByte( CP_ACP, 0, product, -1, szProductCode, len, NULL, NULL );
2099 WideCharToMultiByte( CP_ACP, 0, feature, -1, szFeatureId, len, NULL, NULL );
2100 WideCharToMultiByte( CP_ACP, 0, component, -1, szComponentCode, len, NULL, NULL );
2105 /***********************************************************************
2106 * MsiGetShortcutTargetW [MSI.@]
2108 UINT WINAPI MsiGetShortcutTargetW( LPCWSTR szShortcutTarget,
2109 LPWSTR szProductCode, LPWSTR szFeatureId,
2110 LPWSTR szComponentCode )
2112 IShellLinkDataList *dl = NULL;
2113 IPersistFile *pf = NULL;
2114 LPEXP_DARWIN_LINK darwin = NULL;
2117 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget),
2118 szProductCode, szFeatureId, szComponentCode );
2120 init = CoInitialize(NULL);
2122 r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2123 &IID_IPersistFile, (LPVOID*) &pf );
2124 if( SUCCEEDED( r ) )
2126 r = IPersistFile_Load( pf, szShortcutTarget,
2127 STGM_READ | STGM_SHARE_DENY_WRITE );
2128 if( SUCCEEDED( r ) )
2130 r = IPersistFile_QueryInterface( pf, &IID_IShellLinkDataList,
2132 if( SUCCEEDED( r ) )
2134 IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG,
2136 IShellLinkDataList_Release( dl );
2139 IPersistFile_Release( pf );
2142 if (SUCCEEDED(init))
2145 TRACE("darwin = %p\n", darwin);
2152 ret = MsiDecomposeDescriptorW( darwin->szwDarwinID,
2153 szProductCode, szFeatureId, szComponentCode, &sz );
2154 LocalFree( darwin );
2158 return ERROR_FUNCTION_FAILED;
2161 UINT WINAPI MsiReinstallFeatureW( LPCWSTR szProduct, LPCWSTR szFeature,
2162 DWORD dwReinstallMode )
2164 MSIPACKAGE* package = NULL;
2166 WCHAR sourcepath[MAX_PATH];
2167 WCHAR filename[MAX_PATH];
2168 static const WCHAR szLogVerbose[] = {
2169 ' ','L','O','G','V','E','R','B','O','S','E',0 };
2170 static const WCHAR szInstalled[] = { 'I','n','s','t','a','l','l','e','d',0};
2171 static const WCHAR szReinstall[] = {'R','E','I','N','S','T','A','L','L',0};
2172 static const WCHAR szReinstallMode[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
2173 static const WCHAR szOne[] = {'1',0};
2174 WCHAR reinstallmode[11];
2178 FIXME("%s %s %i\n", debugstr_w(szProduct), debugstr_w(szFeature),
2181 ptr = reinstallmode;
2183 if (dwReinstallMode & REINSTALLMODE_FILEMISSING)
2185 if (dwReinstallMode & REINSTALLMODE_FILEOLDERVERSION)
2187 if (dwReinstallMode & REINSTALLMODE_FILEEQUALVERSION)
2189 if (dwReinstallMode & REINSTALLMODE_FILEEXACT)
2191 if (dwReinstallMode & REINSTALLMODE_FILEVERIFY)
2193 if (dwReinstallMode & REINSTALLMODE_FILEREPLACE)
2195 if (dwReinstallMode & REINSTALLMODE_USERDATA)
2197 if (dwReinstallMode & REINSTALLMODE_MACHINEDATA)
2199 if (dwReinstallMode & REINSTALLMODE_SHORTCUT)
2201 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
2205 sz = sizeof(sourcepath);
2206 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
2207 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEW, sourcepath, &sz);
2209 sz = sizeof(filename);
2210 MsiSourceListGetInfoW(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
2211 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAMEW, filename, &sz);
2213 lstrcatW( sourcepath, filename );
2215 if (dwReinstallMode & REINSTALLMODE_PACKAGE)
2216 r = MSI_OpenPackageW( sourcepath, &package );
2218 r = MSI_OpenProductW( szProduct, &package );
2220 if (r != ERROR_SUCCESS)
2223 MSI_SetPropertyW( package, szReinstallMode, reinstallmode );
2224 MSI_SetPropertyW( package, szInstalled, szOne );
2225 MSI_SetPropertyW( package, szLogVerbose, szOne );
2226 MSI_SetPropertyW( package, szReinstall, szFeature );
2228 r = MSI_InstallPackage( package, sourcepath, NULL );
2230 msiobj_release( &package->hdr );
2235 UINT WINAPI MsiReinstallFeatureA( LPCSTR szProduct, LPCSTR szFeature,
2236 DWORD dwReinstallMode )
2242 TRACE("%s %s %i\n", debugstr_a(szProduct), debugstr_a(szFeature),
2245 wszProduct = strdupAtoW(szProduct);
2246 wszFeature = strdupAtoW(szFeature);
2248 rc = MsiReinstallFeatureW(wszProduct, wszFeature, dwReinstallMode);
2250 msi_free(wszProduct);
2251 msi_free(wszFeature);
2258 unsigned int buf[4];
2259 unsigned char in[64];
2260 unsigned char digest[16];
2263 extern VOID WINAPI MD5Init( MD5_CTX *);
2264 extern VOID WINAPI MD5Update( MD5_CTX *, const unsigned char *, unsigned int );
2265 extern VOID WINAPI MD5Final( MD5_CTX *);
2267 /***********************************************************************
2268 * MsiGetFileHashW [MSI.@]
2270 UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions,
2271 PMSIFILEHASHINFO pHash )
2273 HANDLE handle, mapping;
2276 UINT r = ERROR_FUNCTION_FAILED;
2278 TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash );
2281 return ERROR_INVALID_PARAMETER;
2283 return ERROR_INVALID_PARAMETER;
2284 if (pHash->dwFileHashInfoSize < sizeof *pHash)
2285 return ERROR_INVALID_PARAMETER;
2287 handle = CreateFileW( szFilePath, GENERIC_READ,
2288 FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL );
2289 if (handle == INVALID_HANDLE_VALUE)
2290 return ERROR_FILE_NOT_FOUND;
2292 length = GetFileSize( handle, NULL );
2294 mapping = CreateFileMappingW( handle, NULL, PAGE_READONLY, 0, 0, NULL );
2297 p = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, length );
2303 MD5Update( &ctx, p, length );
2305 UnmapViewOfFile( p );
2307 memcpy( pHash->dwData, &ctx.digest, sizeof pHash->dwData );
2310 CloseHandle( mapping );
2312 CloseHandle( handle );
2317 /***********************************************************************
2318 * MsiGetFileHashA [MSI.@]
2320 UINT WINAPI MsiGetFileHashA( LPCSTR szFilePath, DWORD dwOptions,
2321 PMSIFILEHASHINFO pHash )
2326 TRACE("%s %08x %p\n", debugstr_a(szFilePath), dwOptions, pHash );
2328 file = strdupAtoW( szFilePath );
2329 if (szFilePath && !file)
2330 return ERROR_OUTOFMEMORY;
2332 r = MsiGetFileHashW( file, dwOptions, pHash );
2337 /***********************************************************************
2338 * MsiAdvertiseScriptW [MSI.@]
2340 UINT WINAPI MsiAdvertiseScriptW( LPCWSTR szScriptFile, DWORD dwFlags,
2341 PHKEY phRegData, BOOL fRemoveItems )
2343 FIXME("%s %08x %p %d\n",
2344 debugstr_w( szScriptFile ), dwFlags, phRegData, fRemoveItems );
2345 return ERROR_CALL_NOT_IMPLEMENTED;
2348 /***********************************************************************
2349 * MsiAdvertiseScriptA [MSI.@]
2351 UINT WINAPI MsiAdvertiseScriptA( LPCSTR szScriptFile, DWORD dwFlags,
2352 PHKEY phRegData, BOOL fRemoveItems )
2354 FIXME("%s %08x %p %d\n",
2355 debugstr_a( szScriptFile ), dwFlags, phRegData, fRemoveItems );
2356 return ERROR_CALL_NOT_IMPLEMENTED;