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
, DWORD
*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
, DWORD
*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
, DWORD
*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(LPSTR szProductCode
, LPSTR szUserSid
, MSIINSTALLCONTEXT dwContext
, LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
737 FIXME("(%s, %s, %d, %s, %p): stub!\n", debugstr_a(szProductCode
), debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
740 return ERROR_INVALID_PARAMETER
;
742 *pdwState
= INSTALLSTATE_UNKNOWN
;
743 return ERROR_UNKNOWN_PRODUCT
;
746 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
748 LPWSTR szwProduct
= NULL
;
753 szwProduct
= strdupAtoW( szProduct
);
755 return ERROR_OUTOFMEMORY
;
757 r
= MsiQueryProductStateW( szwProduct
);
758 msi_free( szwProduct
);
762 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
765 INSTALLSTATE state
= INSTALLSTATE_UNKNOWN
;
766 HKEY hkey
= 0, props
= 0;
768 BOOL userkey_exists
= FALSE
;
770 static const int GUID_LEN
= 38;
771 static const WCHAR szInstallProperties
[] = {
772 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0
774 static const WCHAR szWindowsInstaller
[] = {
775 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0
778 TRACE("%s\n", debugstr_w(szProduct
));
780 if (!szProduct
|| !*szProduct
|| lstrlenW(szProduct
) != GUID_LEN
)
781 return INSTALLSTATE_INVALIDARG
;
783 rc
= MSIREG_OpenUserProductsKey(szProduct
,&hkey
,FALSE
);
784 if (rc
== ERROR_SUCCESS
)
786 userkey_exists
= TRUE
;
787 state
= INSTALLSTATE_ADVERTISED
;
791 rc
= MSIREG_OpenUserDataProductKey(szProduct
,&hkey
,FALSE
);
792 if (rc
!= ERROR_SUCCESS
)
795 rc
= RegOpenKeyW(hkey
, szInstallProperties
, &props
);
796 if (rc
!= ERROR_SUCCESS
)
800 rc
= RegQueryValueExW(props
,szWindowsInstaller
,NULL
,NULL
,(LPVOID
)&state
, &sz
);
801 if (rc
!= ERROR_SUCCESS
)
805 state
= INSTALLSTATE_DEFAULT
;
807 state
= INSTALLSTATE_UNKNOWN
;
809 if (state
== INSTALLSTATE_DEFAULT
&& !userkey_exists
)
810 state
= INSTALLSTATE_ABSENT
;
818 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
820 INSTALLUILEVEL old
= gUILevel
;
821 HWND oldwnd
= gUIhwnd
;
823 TRACE("%08x %p\n", dwUILevel
, phWnd
);
825 gUILevel
= dwUILevel
;
834 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
835 DWORD dwMessageFilter
, LPVOID pvContext
)
837 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
839 TRACE("%p %x %p\n",puiHandler
, dwMessageFilter
,pvContext
);
840 gUIHandlerA
= puiHandler
;
841 gUIFilter
= dwMessageFilter
;
842 gUIContext
= pvContext
;
847 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
848 DWORD dwMessageFilter
, LPVOID pvContext
)
850 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
852 TRACE("%p %x %p\n",puiHandler
,dwMessageFilter
,pvContext
);
853 gUIHandlerW
= puiHandler
;
854 gUIFilter
= dwMessageFilter
;
855 gUIContext
= pvContext
;
860 /******************************************************************
861 * MsiLoadStringW [MSI.@]
863 * Loads a string from MSI's string resources.
867 * handle [I] only -1 is handled currently
868 * id [I] id of the string to be loaded
869 * lpBuffer [O] buffer for the string to be written to
870 * nBufferMax [I] maximum size of the buffer in characters
871 * lang [I] the preferred language for the string
875 * If successful, this function returns the language id of the string loaded
876 * If the function fails, the function returns zero.
880 * The type of the first parameter is unknown. LoadString's prototype
881 * suggests that it might be a module handle. I have made it an MSI handle
882 * for starters, as -1 is an invalid MSI handle, but not an invalid module
883 * handle. Maybe strings can be stored in an MSI database somehow.
885 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
886 int nBufferMax
, LANGID lang
)
893 TRACE("%ld %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
896 FIXME("don't know how to deal with handle = %08lx\n", handle
);
899 lang
= GetUserDefaultLangID();
901 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
905 hResData
= LoadResource( msi_hInstance
, hres
);
908 p
= LockResource( hResData
);
912 for (i
= 0; i
< (id
&0xf); i
++)
916 if( nBufferMax
<= len
)
919 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
922 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
927 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
928 int nBufferMax
, LANGID lang
)
934 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
935 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
938 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
939 if( len
<= nBufferMax
)
940 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
941 lpBuffer
, nBufferMax
, NULL
, NULL
);
949 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
952 char szProduct
[GUID_SIZE
];
954 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
956 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
957 return INSTALLSTATE_UNKNOWN
;
959 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
962 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
965 WCHAR szProduct
[GUID_SIZE
];
967 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
969 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
970 return INSTALLSTATE_UNKNOWN
;
972 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
975 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
976 WORD wLanguageId
, DWORD f
)
978 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
979 uType
, wLanguageId
, f
);
980 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
983 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
984 WORD wLanguageId
, DWORD f
)
986 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
987 uType
, wLanguageId
, f
);
988 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
991 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
992 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
995 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
996 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
998 return ERROR_CALL_NOT_IMPLEMENTED
;
1001 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
1002 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
1003 DWORD
* pcchPathBuf
)
1005 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
1006 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
1008 return ERROR_CALL_NOT_IMPLEMENTED
;
1011 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
1012 LPSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
1014 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
1015 return ERROR_CALL_NOT_IMPLEMENTED
;
1018 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
1019 LPWSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
1021 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
1022 return ERROR_CALL_NOT_IMPLEMENTED
;
1025 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
1026 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
1029 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
1030 ppcCertContext
, pbHashData
, pcbHashData
);
1031 return ERROR_CALL_NOT_IMPLEMENTED
;
1034 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
1035 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
1038 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
1039 ppcCertContext
, pbHashData
, pcbHashData
);
1040 return ERROR_CALL_NOT_IMPLEMENTED
;
1043 UINT WINAPI
MsiGetProductPropertyA( MSIHANDLE hProduct
, LPCSTR szProperty
,
1044 LPSTR szValue
, DWORD
*pccbValue
)
1046 FIXME("%ld %s %p %p\n", hProduct
, debugstr_a(szProperty
), szValue
, pccbValue
);
1047 return ERROR_CALL_NOT_IMPLEMENTED
;
1050 UINT WINAPI
MsiGetProductPropertyW( MSIHANDLE hProduct
, LPCWSTR szProperty
,
1051 LPWSTR szValue
, DWORD
*pccbValue
)
1053 FIXME("%ld %s %p %p\n", hProduct
, debugstr_w(szProperty
), szValue
, pccbValue
);
1054 return ERROR_CALL_NOT_IMPLEMENTED
;
1057 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
1060 LPWSTR szPack
= NULL
;
1062 TRACE("%s\n", debugstr_a(szPackage
) );
1066 szPack
= strdupAtoW( szPackage
);
1068 return ERROR_OUTOFMEMORY
;
1071 r
= MsiVerifyPackageW( szPack
);
1078 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
1083 TRACE("%s\n", debugstr_w(szPackage
) );
1085 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
1086 MsiCloseHandle( handle
);
1091 static INSTALLSTATE WINAPI
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
1092 awstring
* lpPathBuf
, DWORD
* pcchBuf
)
1094 WCHAR squished_pc
[GUID_SIZE
], squished_comp
[GUID_SIZE
];
1100 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
1101 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
1103 if( !szProduct
|| !szComponent
)
1104 return INSTALLSTATE_INVALIDARG
;
1105 if( lpPathBuf
->str
.w
&& !pcchBuf
)
1106 return INSTALLSTATE_INVALIDARG
;
1108 if (!squash_guid( szProduct
, squished_pc
) ||
1109 !squash_guid( szComponent
, squished_comp
))
1110 return INSTALLSTATE_INVALIDARG
;
1112 rc
= MSIREG_OpenProductsKey( szProduct
, &hkey
, FALSE
);
1113 if( rc
!= ERROR_SUCCESS
)
1114 return INSTALLSTATE_UNKNOWN
;
1118 rc
= MSIREG_OpenComponentsKey( szComponent
, &hkey
, FALSE
);
1119 if( rc
!= ERROR_SUCCESS
)
1120 return INSTALLSTATE_UNKNOWN
;
1122 path
= msi_reg_get_val_str( hkey
, squished_pc
);
1125 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent
),
1126 debugstr_w(szProduct
), debugstr_w(path
));
1129 return INSTALLSTATE_UNKNOWN
;
1132 r
= INSTALLSTATE_LOCAL
;
1134 r
= INSTALLSTATE_NOTUSED
;
1136 msi_strcpy_to_awstring( path
, lpPathBuf
, pcchBuf
);
1142 /******************************************************************
1143 * MsiGetComponentPathW [MSI.@]
1145 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
1146 LPWSTR lpPathBuf
, DWORD
* pcchBuf
)
1150 path
.unicode
= TRUE
;
1151 path
.str
.w
= lpPathBuf
;
1153 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
1156 /******************************************************************
1157 * MsiGetComponentPathA [MSI.@]
1159 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
1160 LPSTR lpPathBuf
, DWORD
* pcchBuf
)
1162 LPWSTR szwProduct
, szwComponent
= NULL
;
1163 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
1166 szwProduct
= strdupAtoW( szProduct
);
1167 if( szProduct
&& !szwProduct
)
1170 szwComponent
= strdupAtoW( szComponent
);
1171 if( szComponent
&& !szwComponent
)
1174 path
.unicode
= FALSE
;
1175 path
.str
.a
= lpPathBuf
;
1177 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
1180 msi_free( szwProduct
);
1181 msi_free( szwComponent
);
1186 /******************************************************************
1187 * MsiQueryFeatureStateA [MSI.@]
1189 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
1191 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
1192 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
1194 szwProduct
= strdupAtoW( szProduct
);
1195 if ( szProduct
&& !szwProduct
)
1198 szwFeature
= strdupAtoW( szFeature
);
1199 if ( szFeature
&& !szwFeature
)
1202 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
1205 msi_free( szwProduct
);
1206 msi_free( szwFeature
);
1211 /******************************************************************
1212 * MsiQueryFeatureStateW [MSI.@]
1214 * Checks the state of a feature
1217 * szProduct [I] Product's GUID string
1218 * szFeature [I] Feature's GUID string
1221 * INSTALLSTATE_LOCAL Feature is installed and useable
1222 * INSTALLSTATE_ABSENT Feature is absent
1223 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
1224 * INSTALLSTATE_UNKNOWN An error occurred
1225 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
1228 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
1230 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
1232 LPWSTR components
, p
, parent_feature
;
1236 BOOL missing
= FALSE
;
1238 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
1240 if (!szProduct
|| !szFeature
)
1241 return INSTALLSTATE_INVALIDARG
;
1243 if (!squash_guid( szProduct
, squishProduct
))
1244 return INSTALLSTATE_INVALIDARG
;
1246 /* check that it's installed at all */
1247 rc
= MSIREG_OpenUserFeaturesKey(szProduct
, &hkey
, FALSE
);
1248 if (rc
!= ERROR_SUCCESS
)
1249 return INSTALLSTATE_UNKNOWN
;
1251 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
1254 if (!parent_feature
)
1255 return INSTALLSTATE_UNKNOWN
;
1257 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
1258 msi_free(parent_feature
);
1259 if (r
== INSTALLSTATE_ABSENT
)
1262 /* now check if it's complete or advertised */
1263 rc
= MSIREG_OpenFeaturesKey(szProduct
, &hkey
, FALSE
);
1264 if (rc
!= ERROR_SUCCESS
)
1265 return INSTALLSTATE_UNKNOWN
;
1267 components
= msi_reg_get_val_str( hkey
, szFeature
);
1270 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
1274 ERR("components missing %s %s\n",
1275 debugstr_w(szProduct
), debugstr_w(szFeature
));
1276 return INSTALLSTATE_UNKNOWN
;
1279 for( p
= components
; *p
!= 2 ; p
+= 20)
1281 if (!decode_base85_guid( p
, &guid
))
1283 ERR("%s\n", debugstr_w(p
));
1286 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
1287 r
= MsiGetComponentPathW(szProduct
, comp
, NULL
, 0);
1288 TRACE("component %s state %d\n", debugstr_guid(&guid
), r
);
1291 case INSTALLSTATE_NOTUSED
:
1292 case INSTALLSTATE_LOCAL
:
1293 case INSTALLSTATE_SOURCE
:
1300 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
1301 msi_free(components
);
1304 return INSTALLSTATE_ADVERTISED
;
1306 return INSTALLSTATE_LOCAL
;
1309 /******************************************************************
1310 * MsiGetFileVersionA [MSI.@]
1312 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
1313 DWORD
* pcchVersionBuf
, LPSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1315 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
1316 UINT ret
= ERROR_OUTOFMEMORY
;
1320 szwFilePath
= strdupAtoW( szFilePath
);
1325 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1327 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
1328 if( !lpwVersionBuff
)
1332 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1334 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
1339 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
1340 lpwLangBuff
, pcchLangBuf
);
1342 if( lpwVersionBuff
)
1343 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
1344 lpVersionBuf
, *pcchVersionBuf
, NULL
, NULL
);
1346 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
1347 lpLangBuf
, *pcchLangBuf
, NULL
, NULL
);
1350 msi_free(szwFilePath
);
1351 msi_free(lpwVersionBuff
);
1352 msi_free(lpwLangBuff
);
1357 /******************************************************************
1358 * MsiGetFileVersionW [MSI.@]
1360 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
1361 DWORD
* pcchVersionBuf
, LPWSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1363 static const WCHAR szVersionResource
[] = {'\\',0};
1364 static const WCHAR szVersionFormat
[] = {
1365 '%','d','.','%','d','.','%','d','.','%','d',0};
1366 static const WCHAR szLangFormat
[] = {'%','d',0};
1369 LPVOID lpVer
= NULL
;
1370 VS_FIXEDFILEINFO
*ffi
;
1374 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath
),
1375 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
1376 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
1378 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
1380 return GetLastError();
1382 lpVer
= msi_alloc(dwVerLen
);
1385 ret
= ERROR_OUTOFMEMORY
;
1389 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
1391 ret
= GetLastError();
1394 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1396 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
1399 wsprintfW(tmp
, szVersionFormat
,
1400 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
1401 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
1402 lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
1403 *pcchVersionBuf
= lstrlenW(lpVersionBuf
);
1408 *pcchVersionBuf
= 0;
1412 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1414 DWORD lang
= GetUserDefaultLangID();
1416 FIXME("Retrieve language from file\n");
1417 wsprintfW(tmp
, szLangFormat
, lang
);
1418 lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
1419 *pcchLangBuf
= lstrlenW(lpLangBuf
);
1427 /***********************************************************************
1428 * MsiGetFeatureUsageW [MSI.@]
1430 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1431 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1433 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
1434 pdwUseCount
, pwDateUsed
);
1435 return ERROR_CALL_NOT_IMPLEMENTED
;
1438 /***********************************************************************
1439 * MsiGetFeatureUsageA [MSI.@]
1441 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
1442 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1444 LPWSTR prod
= NULL
, feat
= NULL
;
1445 UINT ret
= ERROR_OUTOFMEMORY
;
1447 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1448 pdwUseCount
, pwDateUsed
);
1450 prod
= strdupAtoW( szProduct
);
1451 if (szProduct
&& !prod
)
1454 feat
= strdupAtoW( szFeature
);
1455 if (szFeature
&& !feat
)
1458 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
1467 /***********************************************************************
1468 * MsiUseFeatureExW [MSI.@]
1470 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1471 DWORD dwInstallMode
, DWORD dwReserved
)
1475 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
1476 dwInstallMode
, dwReserved
);
1478 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
1481 return INSTALLSTATE_INVALIDARG
;
1483 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
1485 FIXME("mark product %s feature %s as used\n",
1486 debugstr_w(szProduct
), debugstr_w(szFeature
) );
1492 /***********************************************************************
1493 * MsiUseFeatureExA [MSI.@]
1495 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
1496 DWORD dwInstallMode
, DWORD dwReserved
)
1498 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
1499 LPWSTR prod
= NULL
, feat
= NULL
;
1501 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1502 dwInstallMode
, dwReserved
);
1504 prod
= strdupAtoW( szProduct
);
1505 if (szProduct
&& !prod
)
1508 feat
= strdupAtoW( szFeature
);
1509 if (szFeature
&& !feat
)
1512 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
1521 /***********************************************************************
1522 * MsiUseFeatureW [MSI.@]
1524 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
1526 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
1529 /***********************************************************************
1530 * MsiUseFeatureA [MSI.@]
1532 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
1534 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
1537 /***********************************************************************
1538 * MSI_ProvideQualifiedComponentEx [internal]
1540 static UINT WINAPI
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
1541 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
1542 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
1545 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
1546 feature
[MAX_FEATURE_CHARS
+1];
1552 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent
),
1553 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
1554 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1556 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
1557 if (rc
!= ERROR_SUCCESS
)
1558 return ERROR_INDEX_ABSENT
;
1560 info
= msi_reg_get_val_str( hkey
, szQualifier
);
1564 return ERROR_INDEX_ABSENT
;
1566 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
1569 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
1571 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
1575 if (rc
!= INSTALLSTATE_LOCAL
)
1576 return ERROR_FILE_NOT_FOUND
;
1578 return ERROR_SUCCESS
;
1581 /***********************************************************************
1582 * MsiProvideQualifiedComponentExW [MSI.@]
1584 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
1585 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR szProduct
,
1586 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
1591 path
.unicode
= TRUE
;
1592 path
.str
.w
= lpPathBuf
;
1594 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
1595 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
1598 /***********************************************************************
1599 * MsiProvideQualifiedComponentExA [MSI.@]
1601 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
1602 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR szProduct
,
1603 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
1606 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
1607 UINT r
= ERROR_OUTOFMEMORY
;
1610 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
1611 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
1612 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1614 szwComponent
= strdupAtoW( szComponent
);
1615 if (szComponent
&& !szwComponent
)
1618 szwQualifier
= strdupAtoW( szQualifier
);
1619 if (szQualifier
&& !szwQualifier
)
1622 szwProduct
= strdupAtoW( szProduct
);
1623 if (szProduct
&& !szwProduct
)
1626 path
.unicode
= FALSE
;
1627 path
.str
.a
= lpPathBuf
;
1629 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
1630 dwInstallMode
, szwProduct
, Unused1
,
1631 Unused2
, &path
, pcchPathBuf
);
1633 msi_free(szwProduct
);
1634 msi_free(szwComponent
);
1635 msi_free(szwQualifier
);
1640 /***********************************************************************
1641 * MsiProvideQualifiedComponentW [MSI.@]
1643 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
1644 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
1647 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
1648 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1651 /***********************************************************************
1652 * MsiProvideQualifiedComponentA [MSI.@]
1654 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
1655 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
1658 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
1659 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1662 /***********************************************************************
1663 * MSI_GetUserInfo [internal]
1665 static USERINFOSTATE WINAPI
MSI_GetUserInfo(LPCWSTR szProduct
,
1666 awstring
*lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1667 awstring
*lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1668 awstring
*lpSerialBuf
, DWORD
* pcchSerialBuf
)
1671 LPWSTR user
, org
, serial
;
1673 USERINFOSTATE state
;
1675 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct
), lpUserNameBuf
,
1676 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
1680 return USERINFOSTATE_INVALIDARG
;
1682 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
1683 if (r
!= ERROR_SUCCESS
)
1684 return USERINFOSTATE_UNKNOWN
;
1686 user
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGOWNERW
);
1687 org
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGCOMPANYW
);
1688 serial
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_PRODUCTIDW
);
1692 state
= USERINFOSTATE_PRESENT
;
1696 r
= msi_strcpy_to_awstring( user
, lpUserNameBuf
, pcchUserNameBuf
);
1697 if (r
== ERROR_MORE_DATA
)
1698 state
= USERINFOSTATE_MOREDATA
;
1701 state
= USERINFOSTATE_ABSENT
;
1704 r
= msi_strcpy_to_awstring( org
, lpOrgNameBuf
, pcchOrgNameBuf
);
1705 if (r
== ERROR_MORE_DATA
&& state
== USERINFOSTATE_PRESENT
)
1706 state
= USERINFOSTATE_MOREDATA
;
1708 /* msdn states: The user information is considered to be present even in the absence of a company name. */
1711 r
= msi_strcpy_to_awstring( serial
, lpSerialBuf
, pcchSerialBuf
);
1712 if (r
== ERROR_MORE_DATA
&& state
== USERINFOSTATE_PRESENT
)
1713 state
= USERINFOSTATE_MOREDATA
;
1716 state
= USERINFOSTATE_ABSENT
;
1725 /***********************************************************************
1726 * MsiGetUserInfoW [MSI.@]
1728 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
1729 LPWSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1730 LPWSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1731 LPWSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1733 awstring user
, org
, serial
;
1735 user
.unicode
= TRUE
;
1736 user
.str
.w
= lpUserNameBuf
;
1738 org
.str
.w
= lpOrgNameBuf
;
1739 serial
.unicode
= TRUE
;
1740 serial
.str
.w
= lpSerialBuf
;
1742 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
1743 &org
, pcchOrgNameBuf
,
1744 &serial
, pcchSerialBuf
);
1747 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
1748 LPSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1749 LPSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1750 LPSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1752 awstring user
, org
, serial
;
1756 prod
= strdupAtoW( szProduct
);
1757 if (szProduct
&& !prod
)
1758 return ERROR_OUTOFMEMORY
;
1760 user
.unicode
= FALSE
;
1761 user
.str
.a
= lpUserNameBuf
;
1762 org
.unicode
= FALSE
;
1763 org
.str
.a
= lpOrgNameBuf
;
1764 serial
.unicode
= FALSE
;
1765 serial
.str
.a
= lpSerialBuf
;
1767 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
1768 &org
, pcchOrgNameBuf
,
1769 &serial
, pcchSerialBuf
);
1776 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
1780 MSIPACKAGE
*package
;
1781 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1783 TRACE("(%s)\n",debugstr_w(szProduct
));
1785 rc
= MsiOpenProductW(szProduct
,&handle
);
1786 if (rc
!= ERROR_SUCCESS
)
1787 return ERROR_INVALID_PARAMETER
;
1789 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1790 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
1791 msiobj_release( &package
->hdr
);
1793 MsiCloseHandle(handle
);
1798 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
1802 MSIPACKAGE
*package
;
1803 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1805 TRACE("(%s)\n",debugstr_a(szProduct
));
1807 rc
= MsiOpenProductA(szProduct
,&handle
);
1808 if (rc
!= ERROR_SUCCESS
)
1809 return ERROR_INVALID_PARAMETER
;
1811 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1812 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
1813 msiobj_release( &package
->hdr
);
1815 MsiCloseHandle(handle
);
1820 /***********************************************************************
1821 * MsiConfigureFeatureA [MSI.@]
1823 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
1825 LPWSTR prod
, feat
= NULL
;
1826 UINT r
= ERROR_OUTOFMEMORY
;
1828 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
1830 prod
= strdupAtoW( szProduct
);
1831 if (szProduct
&& !prod
)
1834 feat
= strdupAtoW( szFeature
);
1835 if (szFeature
&& !feat
)
1838 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
1847 /***********************************************************************
1848 * MsiConfigureFeatureW [MSI.@]
1850 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
1852 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
1853 MSIPACKAGE
*package
= NULL
;
1855 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
1858 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
1860 if (!szProduct
|| !szFeature
)
1861 return ERROR_INVALID_PARAMETER
;
1863 switch (eInstallState
)
1865 case INSTALLSTATE_DEFAULT
:
1866 /* FIXME: how do we figure out the default location? */
1867 eInstallState
= INSTALLSTATE_LOCAL
;
1869 case INSTALLSTATE_LOCAL
:
1870 case INSTALLSTATE_SOURCE
:
1871 case INSTALLSTATE_ABSENT
:
1872 case INSTALLSTATE_ADVERTISED
:
1875 return ERROR_INVALID_PARAMETER
;
1878 r
= MSI_OpenProductW( szProduct
, &package
);
1879 if (r
!= ERROR_SUCCESS
)
1882 sz
= sizeof(sourcepath
);
1883 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1884 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
1886 sz
= sizeof(filename
);
1887 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1888 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
1890 lstrcatW( sourcepath
, filename
);
1892 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
1894 r
= ACTION_PerformUIAction( package
, szCostInit
, -1 );
1895 if (r
!= ERROR_SUCCESS
)
1898 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
1899 if (r
!= ERROR_SUCCESS
)
1902 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
1905 msiobj_release( &package
->hdr
);
1910 /***********************************************************************
1911 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
1913 * Notes: undocumented
1915 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
1917 WCHAR path
[MAX_PATH
];
1919 TRACE("%d\n", dwReserved
);
1923 FIXME("dwReserved=%d\n", dwReserved
);
1924 return ERROR_INVALID_PARAMETER
;
1927 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
1928 return ERROR_FUNCTION_FAILED
;
1930 lstrcatW(path
, installerW
);
1932 if (!CreateDirectoryW(path
, NULL
))
1933 return ERROR_FUNCTION_FAILED
;
1935 return ERROR_SUCCESS
;
1938 /***********************************************************************
1939 * MsiGetShortcutTargetA [MSI.@]
1941 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
1942 LPSTR szProductCode
, LPSTR szFeatureId
,
1943 LPSTR szComponentCode
)
1946 const int len
= MAX_FEATURE_CHARS
+1;
1947 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
1950 target
= strdupAtoW( szShortcutTarget
);
1951 if (szShortcutTarget
&& !target
)
1952 return ERROR_OUTOFMEMORY
;
1956 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
1958 if (r
== ERROR_SUCCESS
)
1960 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
1961 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
1962 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
1967 /***********************************************************************
1968 * MsiGetShortcutTargetW [MSI.@]
1970 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
1971 LPWSTR szProductCode
, LPWSTR szFeatureId
,
1972 LPWSTR szComponentCode
)
1974 IShellLinkDataList
*dl
= NULL
;
1975 IPersistFile
*pf
= NULL
;
1976 LPEXP_DARWIN_LINK darwin
= NULL
;
1979 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
1980 szProductCode
, szFeatureId
, szComponentCode
);
1982 init
= CoInitialize(NULL
);
1984 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
1985 &IID_IPersistFile
, (LPVOID
*) &pf
);
1986 if( SUCCEEDED( r
) )
1988 r
= IPersistFile_Load( pf
, szShortcutTarget
,
1989 STGM_READ
| STGM_SHARE_DENY_WRITE
);
1990 if( SUCCEEDED( r
) )
1992 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
1994 if( SUCCEEDED( r
) )
1996 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
1998 IShellLinkDataList_Release( dl
);
2001 IPersistFile_Release( pf
);
2004 if (SUCCEEDED(init
))
2007 TRACE("darwin = %p\n", darwin
);
2014 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
2015 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
2016 LocalFree( darwin
);
2020 return ERROR_FUNCTION_FAILED
;
2023 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2024 DWORD dwReinstallMode
)
2026 MSIPACKAGE
* package
= NULL
;
2028 WCHAR sourcepath
[MAX_PATH
];
2029 WCHAR filename
[MAX_PATH
];
2030 static const WCHAR szLogVerbose
[] = {
2031 ' ','L','O','G','V','E','R','B','O','S','E',0 };
2032 static const WCHAR szInstalled
[] = { 'I','n','s','t','a','l','l','e','d',0};
2033 static const WCHAR szReinstall
[] = {'R','E','I','N','S','T','A','L','L',0};
2034 static const WCHAR szReinstallMode
[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
2035 static const WCHAR szOne
[] = {'1',0};
2036 WCHAR reinstallmode
[11];
2040 FIXME("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
2043 ptr
= reinstallmode
;
2045 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
2047 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
2049 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
2051 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
2053 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
2055 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
2057 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
2059 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
2061 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
2063 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
2067 sz
= sizeof(sourcepath
);
2068 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2069 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
2071 sz
= sizeof(filename
);
2072 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2073 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
2075 lstrcatW( sourcepath
, filename
);
2077 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
2078 r
= MSI_OpenPackageW( sourcepath
, &package
);
2080 r
= MSI_OpenProductW( szProduct
, &package
);
2082 if (r
!= ERROR_SUCCESS
)
2085 MSI_SetPropertyW( package
, szReinstallMode
, reinstallmode
);
2086 MSI_SetPropertyW( package
, szInstalled
, szOne
);
2087 MSI_SetPropertyW( package
, szLogVerbose
, szOne
);
2088 MSI_SetPropertyW( package
, szReinstall
, szFeature
);
2090 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
2092 msiobj_release( &package
->hdr
);
2097 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
2098 DWORD dwReinstallMode
)
2104 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2107 wszProduct
= strdupAtoW(szProduct
);
2108 wszFeature
= strdupAtoW(szFeature
);
2110 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
2112 msi_free(wszProduct
);
2113 msi_free(wszFeature
);
2120 unsigned int buf
[4];
2121 unsigned char in
[64];
2122 unsigned char digest
[16];
2125 extern VOID WINAPI
MD5Init( MD5_CTX
*);
2126 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
2127 extern VOID WINAPI
MD5Final( MD5_CTX
*);
2129 /***********************************************************************
2130 * MsiGetFileHashW [MSI.@]
2132 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
2133 PMSIFILEHASHINFO pHash
)
2135 HANDLE handle
, mapping
;
2138 UINT r
= ERROR_FUNCTION_FAILED
;
2140 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
2143 return ERROR_INVALID_PARAMETER
;
2145 return ERROR_INVALID_PARAMETER
;
2146 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
2147 return ERROR_INVALID_PARAMETER
;
2149 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
2150 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
2151 if (handle
== INVALID_HANDLE_VALUE
)
2152 return ERROR_FILE_NOT_FOUND
;
2154 length
= GetFileSize( handle
, NULL
);
2156 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
2159 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
2165 MD5Update( &ctx
, p
, length
);
2167 UnmapViewOfFile( p
);
2169 memcpy( pHash
->dwData
, &ctx
.digest
, sizeof pHash
->dwData
);
2172 CloseHandle( mapping
);
2174 CloseHandle( handle
);
2179 /***********************************************************************
2180 * MsiGetFileHashA [MSI.@]
2182 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
2183 PMSIFILEHASHINFO pHash
)
2188 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
2190 file
= strdupAtoW( szFilePath
);
2191 if (szFilePath
&& !file
)
2192 return ERROR_OUTOFMEMORY
;
2194 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
2199 /***********************************************************************
2200 * MsiAdvertiseScriptW [MSI.@]
2202 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
2203 PHKEY phRegData
, BOOL fRemoveItems
)
2205 FIXME("%s %08x %p %d\n",
2206 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2207 return ERROR_CALL_NOT_IMPLEMENTED
;
2210 /***********************************************************************
2211 * MsiAdvertiseScriptA [MSI.@]
2213 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
2214 PHKEY phRegData
, BOOL fRemoveItems
)
2216 FIXME("%s %08x %p %d\n",
2217 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2218 return ERROR_CALL_NOT_IMPLEMENTED
;