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
;
769 static const int GUID_LEN
= 38;
770 static const WCHAR szWindowsInstaller
[] = {
771 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0
774 TRACE("%s\n", debugstr_w(szProduct
));
776 if (!szProduct
|| !*szProduct
|| lstrlenW(szProduct
) != GUID_LEN
)
777 return INSTALLSTATE_INVALIDARG
;
779 rc
= MSIREG_OpenUserProductsKey(szProduct
,&hkey
,FALSE
);
780 if (rc
!= ERROR_SUCCESS
)
783 state
= INSTALLSTATE_ADVERTISED
;
786 rc
= MSIREG_OpenUninstallKey(szProduct
,&hkey
,FALSE
);
787 if (rc
!= ERROR_SUCCESS
)
791 rc
= RegQueryValueExW(hkey
,szWindowsInstaller
,NULL
,NULL
,(LPVOID
)&state
, &sz
);
792 if (rc
!= ERROR_SUCCESS
)
799 state
= INSTALLSTATE_DEFAULT
;
802 FIXME("Unknown install state read from registry (%i)\n",state
);
803 state
= INSTALLSTATE_UNKNOWN
;
811 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
813 INSTALLUILEVEL old
= gUILevel
;
814 HWND oldwnd
= gUIhwnd
;
816 TRACE("%08x %p\n", dwUILevel
, phWnd
);
818 gUILevel
= dwUILevel
;
827 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
828 DWORD dwMessageFilter
, LPVOID pvContext
)
830 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
832 TRACE("%p %x %p\n",puiHandler
, dwMessageFilter
,pvContext
);
833 gUIHandlerA
= puiHandler
;
834 gUIFilter
= dwMessageFilter
;
835 gUIContext
= pvContext
;
840 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
841 DWORD dwMessageFilter
, LPVOID pvContext
)
843 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
845 TRACE("%p %x %p\n",puiHandler
,dwMessageFilter
,pvContext
);
846 gUIHandlerW
= puiHandler
;
847 gUIFilter
= dwMessageFilter
;
848 gUIContext
= pvContext
;
853 /******************************************************************
854 * MsiLoadStringW [MSI.@]
856 * Loads a string from MSI's string resources.
860 * handle [I] only -1 is handled currently
861 * id [I] id of the string to be loaded
862 * lpBuffer [O] buffer for the string to be written to
863 * nBufferMax [I] maximum size of the buffer in characters
864 * lang [I] the preferred language for the string
868 * If successful, this function returns the language id of the string loaded
869 * If the function fails, the function returns zero.
873 * The type of the first parameter is unknown. LoadString's prototype
874 * suggests that it might be a module handle. I have made it an MSI handle
875 * for starters, as -1 is an invalid MSI handle, but not an invalid module
876 * handle. Maybe strings can be stored in an MSI database somehow.
878 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
879 int nBufferMax
, LANGID lang
)
886 TRACE("%ld %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
889 FIXME("don't know how to deal with handle = %08lx\n", handle
);
892 lang
= GetUserDefaultLangID();
894 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
898 hResData
= LoadResource( msi_hInstance
, hres
);
901 p
= LockResource( hResData
);
905 for (i
= 0; i
< (id
&0xf); i
++)
909 if( nBufferMax
<= len
)
912 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
915 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
920 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
921 int nBufferMax
, LANGID lang
)
927 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
928 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
931 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
932 if( len
<= nBufferMax
)
933 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
934 lpBuffer
, nBufferMax
, NULL
, NULL
);
942 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
945 char szProduct
[GUID_SIZE
];
947 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
949 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
950 return INSTALLSTATE_UNKNOWN
;
952 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
955 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
958 WCHAR szProduct
[GUID_SIZE
];
960 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
962 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
963 return INSTALLSTATE_UNKNOWN
;
965 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
968 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
969 WORD wLanguageId
, DWORD f
)
971 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
972 uType
, wLanguageId
, f
);
973 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
976 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
977 WORD wLanguageId
, DWORD f
)
979 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
980 uType
, wLanguageId
, f
);
981 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
984 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
985 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
988 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
989 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
991 return ERROR_CALL_NOT_IMPLEMENTED
;
994 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
995 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
998 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
999 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
1001 return ERROR_CALL_NOT_IMPLEMENTED
;
1004 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
1005 LPSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
1007 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
1008 return ERROR_CALL_NOT_IMPLEMENTED
;
1011 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
1012 LPWSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
1014 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
1015 return ERROR_CALL_NOT_IMPLEMENTED
;
1018 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
1019 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
1022 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
1023 ppcCertContext
, pbHashData
, pcbHashData
);
1024 return ERROR_CALL_NOT_IMPLEMENTED
;
1027 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
1028 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
1031 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
1032 ppcCertContext
, pbHashData
, pcbHashData
);
1033 return ERROR_CALL_NOT_IMPLEMENTED
;
1036 UINT WINAPI
MsiGetProductPropertyA( MSIHANDLE hProduct
, LPCSTR szProperty
,
1037 LPSTR szValue
, DWORD
*pccbValue
)
1039 FIXME("%ld %s %p %p\n", hProduct
, debugstr_a(szProperty
), szValue
, pccbValue
);
1040 return ERROR_CALL_NOT_IMPLEMENTED
;
1043 UINT WINAPI
MsiGetProductPropertyW( MSIHANDLE hProduct
, LPCWSTR szProperty
,
1044 LPWSTR szValue
, DWORD
*pccbValue
)
1046 FIXME("%ld %s %p %p\n", hProduct
, debugstr_w(szProperty
), szValue
, pccbValue
);
1047 return ERROR_CALL_NOT_IMPLEMENTED
;
1050 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
1053 LPWSTR szPack
= NULL
;
1055 TRACE("%s\n", debugstr_a(szPackage
) );
1059 szPack
= strdupAtoW( szPackage
);
1061 return ERROR_OUTOFMEMORY
;
1064 r
= MsiVerifyPackageW( szPack
);
1071 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
1076 TRACE("%s\n", debugstr_w(szPackage
) );
1078 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
1079 MsiCloseHandle( handle
);
1084 static INSTALLSTATE WINAPI
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
1085 awstring
* lpPathBuf
, DWORD
* pcchBuf
)
1087 WCHAR squished_pc
[GUID_SIZE
], squished_comp
[GUID_SIZE
];
1093 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
1094 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
1096 if( !szProduct
|| !szComponent
)
1097 return INSTALLSTATE_INVALIDARG
;
1098 if( lpPathBuf
->str
.w
&& !pcchBuf
)
1099 return INSTALLSTATE_INVALIDARG
;
1101 if (!squash_guid( szProduct
, squished_pc
) ||
1102 !squash_guid( szComponent
, squished_comp
))
1103 return INSTALLSTATE_INVALIDARG
;
1105 rc
= MSIREG_OpenProductsKey( szProduct
, &hkey
, FALSE
);
1106 if( rc
!= ERROR_SUCCESS
)
1107 return INSTALLSTATE_UNKNOWN
;
1111 rc
= MSIREG_OpenComponentsKey( szComponent
, &hkey
, FALSE
);
1112 if( rc
!= ERROR_SUCCESS
)
1113 return INSTALLSTATE_UNKNOWN
;
1115 path
= msi_reg_get_val_str( hkey
, squished_pc
);
1118 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent
),
1119 debugstr_w(szProduct
), debugstr_w(path
));
1122 return INSTALLSTATE_UNKNOWN
;
1125 r
= INSTALLSTATE_LOCAL
;
1127 r
= INSTALLSTATE_NOTUSED
;
1129 msi_strcpy_to_awstring( path
, lpPathBuf
, pcchBuf
);
1135 /******************************************************************
1136 * MsiGetComponentPathW [MSI.@]
1138 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
1139 LPWSTR lpPathBuf
, DWORD
* pcchBuf
)
1143 path
.unicode
= TRUE
;
1144 path
.str
.w
= lpPathBuf
;
1146 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
1149 /******************************************************************
1150 * MsiGetComponentPathA [MSI.@]
1152 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
1153 LPSTR lpPathBuf
, DWORD
* pcchBuf
)
1155 LPWSTR szwProduct
, szwComponent
= NULL
;
1156 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
1159 szwProduct
= strdupAtoW( szProduct
);
1160 if( szProduct
&& !szwProduct
)
1163 szwComponent
= strdupAtoW( szComponent
);
1164 if( szComponent
&& !szwComponent
)
1167 path
.unicode
= FALSE
;
1168 path
.str
.a
= lpPathBuf
;
1170 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
1173 msi_free( szwProduct
);
1174 msi_free( szwComponent
);
1179 /******************************************************************
1180 * MsiQueryFeatureStateA [MSI.@]
1182 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
1184 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
1185 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
1187 szwProduct
= strdupAtoW( szProduct
);
1188 if ( szProduct
&& !szwProduct
)
1191 szwFeature
= strdupAtoW( szFeature
);
1192 if ( szFeature
&& !szwFeature
)
1195 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
1198 msi_free( szwProduct
);
1199 msi_free( szwFeature
);
1204 /******************************************************************
1205 * MsiQueryFeatureStateW [MSI.@]
1207 * Checks the state of a feature
1210 * szProduct [I] Product's GUID string
1211 * szFeature [I] Feature's GUID string
1214 * INSTALLSTATE_LOCAL Feature is installed and useable
1215 * INSTALLSTATE_ABSENT Feature is absent
1216 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
1217 * INSTALLSTATE_UNKNOWN An error occurred
1218 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
1221 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
1223 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
1225 LPWSTR components
, p
, parent_feature
;
1229 BOOL missing
= FALSE
;
1231 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
1233 if (!szProduct
|| !szFeature
)
1234 return INSTALLSTATE_INVALIDARG
;
1236 if (!squash_guid( szProduct
, squishProduct
))
1237 return INSTALLSTATE_INVALIDARG
;
1239 /* check that it's installed at all */
1240 rc
= MSIREG_OpenUserFeaturesKey(szProduct
, &hkey
, FALSE
);
1241 if (rc
!= ERROR_SUCCESS
)
1242 return INSTALLSTATE_UNKNOWN
;
1244 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
1247 if (!parent_feature
)
1248 return INSTALLSTATE_UNKNOWN
;
1250 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
1251 msi_free(parent_feature
);
1252 if (r
== INSTALLSTATE_ABSENT
)
1255 /* now check if it's complete or advertised */
1256 rc
= MSIREG_OpenFeaturesKey(szProduct
, &hkey
, FALSE
);
1257 if (rc
!= ERROR_SUCCESS
)
1258 return INSTALLSTATE_UNKNOWN
;
1260 components
= msi_reg_get_val_str( hkey
, szFeature
);
1263 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
1267 ERR("components missing %s %s\n",
1268 debugstr_w(szProduct
), debugstr_w(szFeature
));
1269 return INSTALLSTATE_UNKNOWN
;
1272 for( p
= components
; *p
!= 2 ; p
+= 20)
1274 if (!decode_base85_guid( p
, &guid
))
1276 ERR("%s\n", debugstr_w(p
));
1279 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
1280 r
= MsiGetComponentPathW(szProduct
, comp
, NULL
, 0);
1281 TRACE("component %s state %d\n", debugstr_guid(&guid
), r
);
1284 case INSTALLSTATE_NOTUSED
:
1285 case INSTALLSTATE_LOCAL
:
1286 case INSTALLSTATE_SOURCE
:
1293 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
1294 msi_free(components
);
1297 return INSTALLSTATE_ADVERTISED
;
1299 return INSTALLSTATE_LOCAL
;
1302 /******************************************************************
1303 * MsiGetFileVersionA [MSI.@]
1305 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
1306 DWORD
* pcchVersionBuf
, LPSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1308 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
1309 UINT ret
= ERROR_OUTOFMEMORY
;
1313 szwFilePath
= strdupAtoW( szFilePath
);
1318 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1320 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
1321 if( !lpwVersionBuff
)
1325 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1327 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
1332 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
1333 lpwLangBuff
, pcchLangBuf
);
1335 if( lpwVersionBuff
)
1336 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
1337 lpVersionBuf
, *pcchVersionBuf
, NULL
, NULL
);
1339 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
1340 lpLangBuf
, *pcchLangBuf
, NULL
, NULL
);
1343 msi_free(szwFilePath
);
1344 msi_free(lpwVersionBuff
);
1345 msi_free(lpwLangBuff
);
1350 /******************************************************************
1351 * MsiGetFileVersionW [MSI.@]
1353 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
1354 DWORD
* pcchVersionBuf
, LPWSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1356 static const WCHAR szVersionResource
[] = {'\\',0};
1357 static const WCHAR szVersionFormat
[] = {
1358 '%','d','.','%','d','.','%','d','.','%','d',0};
1359 static const WCHAR szLangFormat
[] = {'%','d',0};
1362 LPVOID lpVer
= NULL
;
1363 VS_FIXEDFILEINFO
*ffi
;
1367 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath
),
1368 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
1369 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
1371 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
1373 return GetLastError();
1375 lpVer
= msi_alloc(dwVerLen
);
1378 ret
= ERROR_OUTOFMEMORY
;
1382 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
1384 ret
= GetLastError();
1387 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1389 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
1392 wsprintfW(tmp
, szVersionFormat
,
1393 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
1394 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
1395 lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
1396 *pcchVersionBuf
= lstrlenW(lpVersionBuf
);
1401 *pcchVersionBuf
= 0;
1405 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1407 DWORD lang
= GetUserDefaultLangID();
1409 FIXME("Retrieve language from file\n");
1410 wsprintfW(tmp
, szLangFormat
, lang
);
1411 lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
1412 *pcchLangBuf
= lstrlenW(lpLangBuf
);
1420 /***********************************************************************
1421 * MsiGetFeatureUsageW [MSI.@]
1423 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1424 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1426 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
1427 pdwUseCount
, pwDateUsed
);
1428 return ERROR_CALL_NOT_IMPLEMENTED
;
1431 /***********************************************************************
1432 * MsiGetFeatureUsageA [MSI.@]
1434 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
1435 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1437 LPWSTR prod
= NULL
, feat
= NULL
;
1438 UINT ret
= ERROR_OUTOFMEMORY
;
1440 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1441 pdwUseCount
, pwDateUsed
);
1443 prod
= strdupAtoW( szProduct
);
1444 if (szProduct
&& !prod
)
1447 feat
= strdupAtoW( szFeature
);
1448 if (szFeature
&& !feat
)
1451 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
1460 /***********************************************************************
1461 * MsiUseFeatureExW [MSI.@]
1463 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1464 DWORD dwInstallMode
, DWORD dwReserved
)
1468 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
1469 dwInstallMode
, dwReserved
);
1471 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
1474 return INSTALLSTATE_INVALIDARG
;
1476 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
1478 FIXME("mark product %s feature %s as used\n",
1479 debugstr_w(szProduct
), debugstr_w(szFeature
) );
1485 /***********************************************************************
1486 * MsiUseFeatureExA [MSI.@]
1488 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
1489 DWORD dwInstallMode
, DWORD dwReserved
)
1491 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
1492 LPWSTR prod
= NULL
, feat
= NULL
;
1494 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1495 dwInstallMode
, dwReserved
);
1497 prod
= strdupAtoW( szProduct
);
1498 if (szProduct
&& !prod
)
1501 feat
= strdupAtoW( szFeature
);
1502 if (szFeature
&& !feat
)
1505 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
1514 /***********************************************************************
1515 * MsiUseFeatureW [MSI.@]
1517 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
1519 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
1522 /***********************************************************************
1523 * MsiUseFeatureA [MSI.@]
1525 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
1527 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
1530 /***********************************************************************
1531 * MSI_ProvideQualifiedComponentEx [internal]
1533 static UINT WINAPI
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
1534 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
1535 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
1538 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
1539 feature
[MAX_FEATURE_CHARS
+1];
1545 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent
),
1546 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
1547 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1549 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
1550 if (rc
!= ERROR_SUCCESS
)
1551 return ERROR_INDEX_ABSENT
;
1553 info
= msi_reg_get_val_str( hkey
, szQualifier
);
1557 return ERROR_INDEX_ABSENT
;
1559 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
1562 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
1564 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
1568 if (rc
!= INSTALLSTATE_LOCAL
)
1569 return ERROR_FILE_NOT_FOUND
;
1571 return ERROR_SUCCESS
;
1574 /***********************************************************************
1575 * MsiProvideQualifiedComponentExW [MSI.@]
1577 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
1578 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR szProduct
,
1579 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
1584 path
.unicode
= TRUE
;
1585 path
.str
.w
= lpPathBuf
;
1587 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
1588 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
1591 /***********************************************************************
1592 * MsiProvideQualifiedComponentExA [MSI.@]
1594 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
1595 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR szProduct
,
1596 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
1599 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
1600 UINT r
= ERROR_OUTOFMEMORY
;
1603 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
1604 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
1605 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1607 szwComponent
= strdupAtoW( szComponent
);
1608 if (szComponent
&& !szwComponent
)
1611 szwQualifier
= strdupAtoW( szQualifier
);
1612 if (szQualifier
&& !szwQualifier
)
1615 szwProduct
= strdupAtoW( szProduct
);
1616 if (szProduct
&& !szwProduct
)
1619 path
.unicode
= FALSE
;
1620 path
.str
.a
= lpPathBuf
;
1622 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
1623 dwInstallMode
, szwProduct
, Unused1
,
1624 Unused2
, &path
, pcchPathBuf
);
1626 msi_free(szwProduct
);
1627 msi_free(szwComponent
);
1628 msi_free(szwQualifier
);
1633 /***********************************************************************
1634 * MsiProvideQualifiedComponentW [MSI.@]
1636 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
1637 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
1640 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
1641 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1644 /***********************************************************************
1645 * MsiProvideQualifiedComponentA [MSI.@]
1647 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
1648 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
1651 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
1652 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1655 /***********************************************************************
1656 * MSI_GetUserInfo [internal]
1658 static USERINFOSTATE WINAPI
MSI_GetUserInfo(LPCWSTR szProduct
,
1659 awstring
*lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1660 awstring
*lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1661 awstring
*lpSerialBuf
, DWORD
* pcchSerialBuf
)
1664 LPWSTR user
, org
, serial
;
1666 USERINFOSTATE state
;
1668 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct
), lpUserNameBuf
,
1669 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
1673 return USERINFOSTATE_INVALIDARG
;
1675 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
1676 if (r
!= ERROR_SUCCESS
)
1677 return USERINFOSTATE_UNKNOWN
;
1679 user
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGOWNERW
);
1680 org
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGCOMPANYW
);
1681 serial
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_PRODUCTIDW
);
1685 state
= USERINFOSTATE_PRESENT
;
1689 r
= msi_strcpy_to_awstring( user
, lpUserNameBuf
, pcchUserNameBuf
);
1690 if (r
== ERROR_MORE_DATA
)
1691 state
= USERINFOSTATE_MOREDATA
;
1694 state
= USERINFOSTATE_ABSENT
;
1697 r
= msi_strcpy_to_awstring( org
, lpOrgNameBuf
, pcchOrgNameBuf
);
1698 if (r
== ERROR_MORE_DATA
&& state
== USERINFOSTATE_PRESENT
)
1699 state
= USERINFOSTATE_MOREDATA
;
1701 /* msdn states: The user information is considered to be present even in the absence of a company name. */
1704 r
= msi_strcpy_to_awstring( serial
, lpSerialBuf
, pcchSerialBuf
);
1705 if (r
== ERROR_MORE_DATA
&& state
== USERINFOSTATE_PRESENT
)
1706 state
= USERINFOSTATE_MOREDATA
;
1709 state
= USERINFOSTATE_ABSENT
;
1718 /***********************************************************************
1719 * MsiGetUserInfoW [MSI.@]
1721 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
1722 LPWSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1723 LPWSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1724 LPWSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1726 awstring user
, org
, serial
;
1728 user
.unicode
= TRUE
;
1729 user
.str
.w
= lpUserNameBuf
;
1731 org
.str
.w
= lpOrgNameBuf
;
1732 serial
.unicode
= TRUE
;
1733 serial
.str
.w
= lpSerialBuf
;
1735 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
1736 &org
, pcchOrgNameBuf
,
1737 &serial
, pcchSerialBuf
);
1740 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
1741 LPSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1742 LPSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1743 LPSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1745 awstring user
, org
, serial
;
1749 prod
= strdupAtoW( szProduct
);
1750 if (szProduct
&& !prod
)
1751 return ERROR_OUTOFMEMORY
;
1753 user
.unicode
= FALSE
;
1754 user
.str
.a
= lpUserNameBuf
;
1755 org
.unicode
= FALSE
;
1756 org
.str
.a
= lpOrgNameBuf
;
1757 serial
.unicode
= FALSE
;
1758 serial
.str
.a
= lpSerialBuf
;
1760 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
1761 &org
, pcchOrgNameBuf
,
1762 &serial
, pcchSerialBuf
);
1769 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
1773 MSIPACKAGE
*package
;
1774 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1776 TRACE("(%s)\n",debugstr_w(szProduct
));
1778 rc
= MsiOpenProductW(szProduct
,&handle
);
1779 if (rc
!= ERROR_SUCCESS
)
1780 return ERROR_INVALID_PARAMETER
;
1782 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1783 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
1784 msiobj_release( &package
->hdr
);
1786 MsiCloseHandle(handle
);
1791 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
1795 MSIPACKAGE
*package
;
1796 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1798 TRACE("(%s)\n",debugstr_a(szProduct
));
1800 rc
= MsiOpenProductA(szProduct
,&handle
);
1801 if (rc
!= ERROR_SUCCESS
)
1802 return ERROR_INVALID_PARAMETER
;
1804 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1805 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
1806 msiobj_release( &package
->hdr
);
1808 MsiCloseHandle(handle
);
1813 /***********************************************************************
1814 * MsiConfigureFeatureA [MSI.@]
1816 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
1818 LPWSTR prod
, feat
= NULL
;
1819 UINT r
= ERROR_OUTOFMEMORY
;
1821 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
1823 prod
= strdupAtoW( szProduct
);
1824 if (szProduct
&& !prod
)
1827 feat
= strdupAtoW( szFeature
);
1828 if (szFeature
&& !feat
)
1831 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
1840 /***********************************************************************
1841 * MsiConfigureFeatureW [MSI.@]
1843 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
1845 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
1846 MSIPACKAGE
*package
= NULL
;
1848 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
1851 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
1853 if (!szProduct
|| !szFeature
)
1854 return ERROR_INVALID_PARAMETER
;
1856 switch (eInstallState
)
1858 case INSTALLSTATE_DEFAULT
:
1859 /* FIXME: how do we figure out the default location? */
1860 eInstallState
= INSTALLSTATE_LOCAL
;
1862 case INSTALLSTATE_LOCAL
:
1863 case INSTALLSTATE_SOURCE
:
1864 case INSTALLSTATE_ABSENT
:
1865 case INSTALLSTATE_ADVERTISED
:
1868 return ERROR_INVALID_PARAMETER
;
1871 r
= MSI_OpenProductW( szProduct
, &package
);
1872 if (r
!= ERROR_SUCCESS
)
1875 sz
= sizeof(sourcepath
);
1876 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1877 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
1879 sz
= sizeof(filename
);
1880 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1881 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
1883 lstrcatW( sourcepath
, filename
);
1885 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
1887 r
= ACTION_PerformUIAction( package
, szCostInit
, -1 );
1888 if (r
!= ERROR_SUCCESS
)
1891 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
1892 if (r
!= ERROR_SUCCESS
)
1895 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
1898 msiobj_release( &package
->hdr
);
1903 /***********************************************************************
1904 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
1906 * Notes: undocumented
1908 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
1910 WCHAR path
[MAX_PATH
];
1912 TRACE("%d\n", dwReserved
);
1916 FIXME("dwReserved=%d\n", dwReserved
);
1917 return ERROR_INVALID_PARAMETER
;
1920 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
1921 return ERROR_FUNCTION_FAILED
;
1923 lstrcatW(path
, installerW
);
1925 if (!CreateDirectoryW(path
, NULL
))
1926 return ERROR_FUNCTION_FAILED
;
1928 return ERROR_SUCCESS
;
1931 /***********************************************************************
1932 * MsiGetShortcutTargetA [MSI.@]
1934 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
1935 LPSTR szProductCode
, LPSTR szFeatureId
,
1936 LPSTR szComponentCode
)
1939 const int len
= MAX_FEATURE_CHARS
+1;
1940 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
1943 target
= strdupAtoW( szShortcutTarget
);
1944 if (szShortcutTarget
&& !target
)
1945 return ERROR_OUTOFMEMORY
;
1949 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
1951 if (r
== ERROR_SUCCESS
)
1953 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
1954 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
1955 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
1960 /***********************************************************************
1961 * MsiGetShortcutTargetW [MSI.@]
1963 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
1964 LPWSTR szProductCode
, LPWSTR szFeatureId
,
1965 LPWSTR szComponentCode
)
1967 IShellLinkDataList
*dl
= NULL
;
1968 IPersistFile
*pf
= NULL
;
1969 LPEXP_DARWIN_LINK darwin
= NULL
;
1972 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
1973 szProductCode
, szFeatureId
, szComponentCode
);
1975 init
= CoInitialize(NULL
);
1977 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
1978 &IID_IPersistFile
, (LPVOID
*) &pf
);
1979 if( SUCCEEDED( r
) )
1981 r
= IPersistFile_Load( pf
, szShortcutTarget
,
1982 STGM_READ
| STGM_SHARE_DENY_WRITE
);
1983 if( SUCCEEDED( r
) )
1985 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
1987 if( SUCCEEDED( r
) )
1989 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
1991 IShellLinkDataList_Release( dl
);
1994 IPersistFile_Release( pf
);
1997 if (SUCCEEDED(init
))
2000 TRACE("darwin = %p\n", darwin
);
2007 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
2008 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
2009 LocalFree( darwin
);
2013 return ERROR_FUNCTION_FAILED
;
2016 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2017 DWORD dwReinstallMode
)
2019 MSIPACKAGE
* package
= NULL
;
2021 WCHAR sourcepath
[MAX_PATH
];
2022 WCHAR filename
[MAX_PATH
];
2023 static const WCHAR szLogVerbose
[] = {
2024 ' ','L','O','G','V','E','R','B','O','S','E',0 };
2025 static const WCHAR szInstalled
[] = { 'I','n','s','t','a','l','l','e','d',0};
2026 static const WCHAR szReinstall
[] = {'R','E','I','N','S','T','A','L','L',0};
2027 static const WCHAR szReinstallMode
[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
2028 static const WCHAR szOne
[] = {'1',0};
2029 WCHAR reinstallmode
[11];
2033 FIXME("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
2036 ptr
= reinstallmode
;
2038 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
2040 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
2042 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
2044 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
2046 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
2048 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
2050 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
2052 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
2054 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
2056 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
2060 sz
= sizeof(sourcepath
);
2061 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2062 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
2064 sz
= sizeof(filename
);
2065 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2066 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
2068 lstrcatW( sourcepath
, filename
);
2070 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
2071 r
= MSI_OpenPackageW( sourcepath
, &package
);
2073 r
= MSI_OpenProductW( szProduct
, &package
);
2075 if (r
!= ERROR_SUCCESS
)
2078 MSI_SetPropertyW( package
, szReinstallMode
, reinstallmode
);
2079 MSI_SetPropertyW( package
, szInstalled
, szOne
);
2080 MSI_SetPropertyW( package
, szLogVerbose
, szOne
);
2081 MSI_SetPropertyW( package
, szReinstall
, szFeature
);
2083 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
2085 msiobj_release( &package
->hdr
);
2090 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
2091 DWORD dwReinstallMode
)
2097 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2100 wszProduct
= strdupAtoW(szProduct
);
2101 wszFeature
= strdupAtoW(szFeature
);
2103 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
2105 msi_free(wszProduct
);
2106 msi_free(wszFeature
);
2113 unsigned int buf
[4];
2114 unsigned char in
[64];
2115 unsigned char digest
[16];
2118 extern VOID WINAPI
MD5Init( MD5_CTX
*);
2119 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
2120 extern VOID WINAPI
MD5Final( MD5_CTX
*);
2122 /***********************************************************************
2123 * MsiGetFileHashW [MSI.@]
2125 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
2126 PMSIFILEHASHINFO pHash
)
2128 HANDLE handle
, mapping
;
2131 UINT r
= ERROR_FUNCTION_FAILED
;
2133 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
2136 return ERROR_INVALID_PARAMETER
;
2138 return ERROR_INVALID_PARAMETER
;
2139 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
2140 return ERROR_INVALID_PARAMETER
;
2142 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
2143 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
2144 if (handle
== INVALID_HANDLE_VALUE
)
2145 return ERROR_FILE_NOT_FOUND
;
2147 length
= GetFileSize( handle
, NULL
);
2149 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
2152 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
2158 MD5Update( &ctx
, p
, length
);
2160 UnmapViewOfFile( p
);
2162 memcpy( pHash
->dwData
, &ctx
.digest
, sizeof pHash
->dwData
);
2165 CloseHandle( mapping
);
2167 CloseHandle( handle
);
2172 /***********************************************************************
2173 * MsiGetFileHashA [MSI.@]
2175 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
2176 PMSIFILEHASHINFO pHash
)
2181 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
2183 file
= strdupAtoW( szFilePath
);
2184 if (szFilePath
&& !file
)
2185 return ERROR_OUTOFMEMORY
;
2187 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
2192 /***********************************************************************
2193 * MsiAdvertiseScriptW [MSI.@]
2195 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
2196 PHKEY phRegData
, BOOL fRemoveItems
)
2198 FIXME("%s %08x %p %d\n",
2199 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2200 return ERROR_CALL_NOT_IMPLEMENTED
;
2203 /***********************************************************************
2204 * MsiAdvertiseScriptA [MSI.@]
2206 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
2207 PHKEY phRegData
, BOOL fRemoveItems
)
2209 FIXME("%s %08x %p %d\n",
2210 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2211 return ERROR_CALL_NOT_IMPLEMENTED
;