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
32 #include "wine/debug.h"
42 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
47 static const WCHAR installerW
[] = {'\\','I','n','s','t','a','l','l','e','r',0};
49 UINT WINAPI
MsiOpenProductA(LPCSTR szProduct
, MSIHANDLE
*phProduct
)
52 LPWSTR szwProd
= NULL
;
54 TRACE("%s %p\n",debugstr_a(szProduct
), phProduct
);
58 szwProd
= strdupAtoW( szProduct
);
60 return ERROR_OUTOFMEMORY
;
63 r
= MsiOpenProductW( szwProd
, phProduct
);
70 static UINT
MSI_OpenProductW( LPCWSTR szProduct
, MSIPACKAGE
**ppackage
)
74 HKEY hKeyProduct
= NULL
;
77 TRACE("%s %p\n", debugstr_w(szProduct
), ppackage
);
79 r
= MSIREG_OpenUninstallKey(szProduct
,&hKeyProduct
,FALSE
);
80 if( r
!= ERROR_SUCCESS
)
82 r
= ERROR_UNKNOWN_PRODUCT
;
86 /* find the size of the path */
88 r
= RegQueryValueExW( hKeyProduct
, INSTALLPROPERTY_LOCALPACKAGEW
,
89 NULL
, &type
, NULL
, &count
);
90 if( r
!= ERROR_SUCCESS
)
92 r
= ERROR_UNKNOWN_PRODUCT
;
96 /* now alloc and fetch the path of the database to open */
97 path
= msi_alloc( count
);
101 r
= RegQueryValueExW( hKeyProduct
, INSTALLPROPERTY_LOCALPACKAGEW
,
102 NULL
, &type
, (LPBYTE
) path
, &count
);
103 if( r
!= ERROR_SUCCESS
)
105 r
= ERROR_UNKNOWN_PRODUCT
;
109 r
= MSI_OpenPackageW( path
, ppackage
);
114 RegCloseKey( hKeyProduct
);
119 UINT WINAPI
MsiOpenProductW( LPCWSTR szProduct
, MSIHANDLE
*phProduct
)
121 MSIPACKAGE
*package
= NULL
;
124 r
= MSI_OpenProductW( szProduct
, &package
);
125 if( r
== ERROR_SUCCESS
)
127 *phProduct
= alloc_msihandle( &package
->hdr
);
129 r
= ERROR_NOT_ENOUGH_MEMORY
;
130 msiobj_release( &package
->hdr
);
135 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
136 LPCSTR szTransforms
, LANGID lgidLanguage
)
138 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
139 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
140 return ERROR_CALL_NOT_IMPLEMENTED
;
143 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
144 LPCWSTR szTransforms
, LANGID lgidLanguage
)
146 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
147 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
148 return ERROR_CALL_NOT_IMPLEMENTED
;
151 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
152 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
154 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_a(szPackagePath
),
155 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
156 lgidLanguage
, dwPlatform
, dwOptions
);
157 return ERROR_CALL_NOT_IMPLEMENTED
;
160 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
161 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
163 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_w(szPackagePath
),
164 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
165 lgidLanguage
, dwPlatform
, dwOptions
);
166 return ERROR_CALL_NOT_IMPLEMENTED
;
169 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
171 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
172 UINT r
= ERROR_OUTOFMEMORY
;
174 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
178 szwPath
= strdupAtoW( szPackagePath
);
185 szwCommand
= strdupAtoW( szCommandLine
);
190 r
= MsiInstallProductW( szwPath
, szwCommand
);
194 msi_free( szwCommand
);
199 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
201 MSIPACKAGE
*package
= NULL
;
204 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
206 r
= MSI_OpenPackageW( szPackagePath
, &package
);
207 if (r
== ERROR_SUCCESS
)
209 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
210 msiobj_release( &package
->hdr
);
216 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
218 FIXME("%s %08lx\n", debugstr_a(szProduct
), dwReinstallMode
);
219 return ERROR_CALL_NOT_IMPLEMENTED
;
222 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
224 FIXME("%s %08lx\n", debugstr_w(szProduct
), dwReinstallMode
);
225 return ERROR_CALL_NOT_IMPLEMENTED
;
228 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
229 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
231 FIXME("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
232 eInstallType
, debugstr_a(szCommandLine
));
233 return ERROR_CALL_NOT_IMPLEMENTED
;
236 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
237 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
239 FIXME("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
240 eInstallType
, debugstr_w(szCommandLine
));
241 return ERROR_CALL_NOT_IMPLEMENTED
;
244 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
245 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
247 MSIPACKAGE
* package
= NULL
;
250 WCHAR sourcepath
[MAX_PATH
];
251 WCHAR filename
[MAX_PATH
];
252 static const WCHAR szInstalled
[] = {
253 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
256 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
257 debugstr_w(szCommandLine
));
259 if (eInstallState
!= INSTALLSTATE_LOCAL
&&
260 eInstallState
!= INSTALLSTATE_DEFAULT
)
262 FIXME("Not implemented for anything other than local installs\n");
263 return ERROR_CALL_NOT_IMPLEMENTED
;
266 sz
= sizeof(sourcepath
);
267 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
268 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
,
271 sz
= sizeof(filename
);
272 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
273 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
275 lstrcatW(sourcepath
,filename
);
278 * ok 1, we need to find the msi file for this product.
279 * 2, find the source dir for the files
280 * 3, do the configure/install.
281 * 4, cleanupany runonce entry.
284 r
= MSI_OpenProductW( szProduct
, &package
);
285 if (r
!= ERROR_SUCCESS
)
288 sz
= lstrlenW(szInstalled
) + 1;
291 sz
+= lstrlenW(szCommandLine
);
293 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
296 r
= ERROR_OUTOFMEMORY
;
302 lstrcpyW(commandline
,szCommandLine
);
304 if (MsiQueryProductStateW(szProduct
) != INSTALLSTATE_UNKNOWN
)
305 lstrcatW(commandline
,szInstalled
);
307 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
309 msi_free(commandline
);
312 msiobj_release( &package
->hdr
);
317 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
318 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
320 LPWSTR szwProduct
= NULL
;
321 LPWSTR szwCommandLine
= NULL
;
322 UINT r
= ERROR_OUTOFMEMORY
;
326 szwProduct
= strdupAtoW( szProduct
);
333 szwCommandLine
= strdupAtoW( szCommandLine
);
338 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
341 msi_free( szwProduct
);
342 msi_free( szwCommandLine
);
347 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
348 INSTALLSTATE eInstallState
)
350 LPWSTR szwProduct
= NULL
;
353 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
357 szwProduct
= strdupAtoW( szProduct
);
359 return ERROR_OUTOFMEMORY
;
362 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
363 msi_free( szwProduct
);
368 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
369 INSTALLSTATE eInstallState
)
371 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
374 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
376 LPWSTR szwComponent
= NULL
;
378 WCHAR szwBuffer
[GUID_SIZE
];
380 TRACE("%s %s\n",debugstr_a(szComponent
), debugstr_a(szBuffer
));
384 szwComponent
= strdupAtoW( szComponent
);
386 return ERROR_OUTOFMEMORY
;
389 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
391 if( ERROR_SUCCESS
== r
)
392 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
394 msi_free( szwComponent
);
399 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
403 WCHAR szSquished
[GUID_SIZE
];
404 DWORD sz
= GUID_SIZE
;
405 static const WCHAR szPermKey
[] =
406 { '0','0','0','0','0','0','0','0','0','0','0','0',
407 '0','0','0','0','0','0','0','0','0','0','0','0',
408 '0','0','0','0','0','0','0','0',0};
410 TRACE("%s %p\n",debugstr_w(szComponent
), szBuffer
);
412 if (NULL
== szComponent
)
413 return ERROR_INVALID_PARAMETER
;
415 rc
= MSIREG_OpenComponentsKey( szComponent
, &hkey
, FALSE
);
416 if (rc
!= ERROR_SUCCESS
)
417 return ERROR_UNKNOWN_COMPONENT
;
419 rc
= RegEnumValueW(hkey
, 0, szSquished
, &sz
, NULL
, NULL
, NULL
, NULL
);
420 if (rc
== ERROR_SUCCESS
&& strcmpW(szSquished
,szPermKey
)==0)
423 rc
= RegEnumValueW(hkey
, 1, szSquished
, &sz
, NULL
, NULL
, NULL
, NULL
);
428 if (rc
!= ERROR_SUCCESS
)
429 return ERROR_INSTALL_FAILURE
;
431 unsquash_guid(szSquished
, szBuffer
);
432 return ERROR_SUCCESS
;
435 UINT WINAPI
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
436 awstring
*szValue
, DWORD
*pcchValueBuf
)
442 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
443 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
446 * FIXME: Values seem scattered/duplicated in the registry. Is there a system?
449 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
450 return ERROR_INVALID_PARAMETER
;
452 /* check for special properties */
453 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
456 WCHAR packagecode
[35];
458 r
= MSIREG_OpenUserProductsKey(szProduct
, &hkey
, FALSE
);
459 if (r
!= ERROR_SUCCESS
)
460 return ERROR_UNKNOWN_PRODUCT
;
462 regval
= msi_reg_get_val_str( hkey
, szAttribute
);
465 if (unsquash_guid(regval
, packagecode
))
466 val
= strdupW(packagecode
);
472 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
474 static const WCHAR one
[] = { '1',0 };
476 * FIXME: should be in the Product key (user or system?)
477 * but isn't written yet...
479 val
= strdupW( one
);
481 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
482 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONW
))
484 static const WCHAR fmt
[] = { '%','u',0 };
488 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
489 if (r
!= ERROR_SUCCESS
)
490 return ERROR_UNKNOWN_PRODUCT
;
492 if (msi_reg_get_val_dword( hkey
, szAttribute
, ®val
))
494 sprintfW(szVal
, fmt
, regval
);
495 val
= strdupW( szVal
);
500 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
))
502 r
= MSIREG_OpenUserProductsKey(szProduct
, &hkey
, FALSE
);
503 if (r
!= ERROR_SUCCESS
)
504 return ERROR_UNKNOWN_PRODUCT
;
506 val
= msi_reg_get_val_str( hkey
, szAttribute
);
512 static const WCHAR szDisplayVersion
[] = {
513 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0 };
515 FIXME("%s\n", debugstr_w(szAttribute
));
516 /* FIXME: some attribute values not tested... */
518 if (!lstrcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
519 szAttribute
= szDisplayVersion
;
521 r
= MSIREG_OpenUninstallKey( szProduct
, &hkey
, FALSE
);
522 if (r
!= ERROR_SUCCESS
)
523 return ERROR_UNKNOWN_PRODUCT
;
525 val
= msi_reg_get_val_str( hkey
, szAttribute
);
530 TRACE("returning %s\n", debugstr_w(val
));
533 return ERROR_UNKNOWN_PROPERTY
;
535 r
= msi_strcpy_to_awstring( val
, szValue
, pcchValueBuf
);
542 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
543 LPSTR szBuffer
, DWORD
*pcchValueBuf
)
545 LPWSTR szwProduct
, szwAttribute
= NULL
;
546 UINT r
= ERROR_OUTOFMEMORY
;
549 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
550 szBuffer
, pcchValueBuf
);
552 szwProduct
= strdupAtoW( szProduct
);
553 if( szProduct
&& !szwProduct
)
556 szwAttribute
= strdupAtoW( szAttribute
);
557 if( szAttribute
&& !szwAttribute
)
560 buffer
.unicode
= FALSE
;
561 buffer
.str
.a
= szBuffer
;
563 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
564 &buffer
, pcchValueBuf
);
567 msi_free( szwProduct
);
568 msi_free( szwAttribute
);
573 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
574 LPWSTR szBuffer
, DWORD
*pcchValueBuf
)
578 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
579 szBuffer
, pcchValueBuf
);
581 buffer
.unicode
= TRUE
;
582 buffer
.str
.w
= szBuffer
;
584 return MSI_GetProductInfo( szProduct
, szAttribute
,
585 &buffer
, pcchValueBuf
);
588 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
590 LPWSTR szwLogFile
= NULL
;
593 TRACE("%08lx %s %08lx\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
597 szwLogFile
= strdupAtoW( szLogFile
);
599 return ERROR_OUTOFMEMORY
;
601 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
602 msi_free( szwLogFile
);
606 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
608 HANDLE file
= INVALID_HANDLE_VALUE
;
610 TRACE("%08lx %s %08lx\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
614 lstrcpyW(gszLogFile
,szLogFile
);
615 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
616 DeleteFileW(szLogFile
);
617 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, 0, NULL
, OPEN_ALWAYS
,
618 FILE_ATTRIBUTE_NORMAL
, NULL
);
619 if (file
!= INVALID_HANDLE_VALUE
)
622 ERR("Unable to enable log %s\n",debugstr_w(szLogFile
));
625 gszLogFile
[0] = '\0';
627 return ERROR_SUCCESS
;
630 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
632 LPWSTR szwProduct
= NULL
;
637 szwProduct
= strdupAtoW( szProduct
);
639 return ERROR_OUTOFMEMORY
;
641 r
= MsiQueryProductStateW( szwProduct
);
642 msi_free( szwProduct
);
646 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
649 INSTALLSTATE rrc
= INSTALLSTATE_UNKNOWN
;
651 static const WCHAR szWindowsInstaller
[] = {
652 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 };
655 TRACE("%s\n", debugstr_w(szProduct
));
658 return INSTALLSTATE_INVALIDARG
;
660 rc
= MSIREG_OpenUserProductsKey(szProduct
,&hkey
,FALSE
);
661 if (rc
!= ERROR_SUCCESS
)
666 rc
= MSIREG_OpenUninstallKey(szProduct
,&hkey
,FALSE
);
667 if (rc
!= ERROR_SUCCESS
)
671 rc
= RegQueryValueExW(hkey
,szWindowsInstaller
,NULL
,NULL
,(LPVOID
)&rrc
, &sz
);
672 if (rc
!= ERROR_SUCCESS
)
679 rrc
= INSTALLSTATE_DEFAULT
;
682 FIXME("Unknown install state read from registry (%i)\n",rrc
);
683 rrc
= INSTALLSTATE_UNKNOWN
;
691 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
693 INSTALLUILEVEL old
= gUILevel
;
694 HWND oldwnd
= gUIhwnd
;
696 TRACE("%08x %p\n", dwUILevel
, phWnd
);
698 gUILevel
= dwUILevel
;
707 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
708 DWORD dwMessageFilter
, LPVOID pvContext
)
710 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
712 TRACE("%p %lx %p\n",puiHandler
, dwMessageFilter
,pvContext
);
713 gUIHandlerA
= puiHandler
;
714 gUIFilter
= dwMessageFilter
;
715 gUIContext
= pvContext
;
720 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
721 DWORD dwMessageFilter
, LPVOID pvContext
)
723 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
725 TRACE("%p %lx %p\n",puiHandler
,dwMessageFilter
,pvContext
);
726 gUIHandlerW
= puiHandler
;
727 gUIFilter
= dwMessageFilter
;
728 gUIContext
= pvContext
;
733 /******************************************************************
734 * MsiLoadStringW [MSI.@]
736 * Loads a string from MSI's string resources.
740 * handle [I] only -1 is handled currently
741 * id [I] id of the string to be loaded
742 * lpBuffer [O] buffer for the string to be written to
743 * nBufferMax [I] maximum size of the buffer in characters
744 * lang [I] the preferred language for the string
748 * If successful, this function returns the language id of the string loaded
749 * If the function fails, the function returns zero.
753 * The type of the first parameter is unknown. LoadString's prototype
754 * suggests that it might be a module handle. I have made it an MSI handle
755 * for starters, as -1 is an invalid MSI handle, but not an invalid module
756 * handle. Maybe strings can be stored in an MSI database somehow.
758 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
759 int nBufferMax
, LANGID lang
)
766 TRACE("%ld %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
769 FIXME("don't know how to deal with handle = %08lx\n", handle
);
772 lang
= GetUserDefaultLangID();
774 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
778 hResData
= LoadResource( msi_hInstance
, hres
);
781 p
= LockResource( hResData
);
785 for (i
= 0; i
< (id
&0xf); i
++)
789 if( nBufferMax
<= len
)
792 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
795 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
800 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
801 int nBufferMax
, LANGID lang
)
807 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
808 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
811 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
812 if( len
<= nBufferMax
)
813 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
814 lpBuffer
, nBufferMax
, NULL
, NULL
);
822 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
825 char szProduct
[GUID_SIZE
];
827 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
829 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
830 return INSTALLSTATE_UNKNOWN
;
832 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
835 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
838 WCHAR szProduct
[GUID_SIZE
];
840 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
842 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
843 return INSTALLSTATE_UNKNOWN
;
845 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
848 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
849 WORD wLanguageId
, DWORD f
)
851 FIXME("%p %s %s %u %08x %08lx\n",hWnd
,debugstr_a(lpText
),debugstr_a(lpCaption
),
852 uType
,wLanguageId
,f
);
853 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
856 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
857 WORD wLanguageId
, DWORD f
)
859 FIXME("%p %s %s %u %08x %08lx\n",hWnd
,debugstr_w(lpText
),debugstr_w(lpCaption
),
860 uType
,wLanguageId
,f
);
861 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
864 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
865 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
868 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_a(szAssemblyName
),
869 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
871 return ERROR_CALL_NOT_IMPLEMENTED
;
874 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
875 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
878 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName
),
879 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
881 return ERROR_CALL_NOT_IMPLEMENTED
;
884 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
885 LPSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
887 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
888 return ERROR_CALL_NOT_IMPLEMENTED
;
891 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
892 LPWSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
894 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
895 return ERROR_CALL_NOT_IMPLEMENTED
;
898 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
899 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
902 FIXME("%s %08lx %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
903 ppcCertContext
, pbHashData
, pcbHashData
);
904 return ERROR_CALL_NOT_IMPLEMENTED
;
907 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
908 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
911 FIXME("%s %08lx %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
912 ppcCertContext
, pbHashData
, pcbHashData
);
913 return ERROR_CALL_NOT_IMPLEMENTED
;
916 UINT WINAPI
MsiGetProductPropertyA( MSIHANDLE hProduct
, LPCSTR szProperty
,
917 LPSTR szValue
, DWORD
*pccbValue
)
919 FIXME("%ld %s %p %p\n", hProduct
, debugstr_a(szProperty
), szValue
, pccbValue
);
920 return ERROR_CALL_NOT_IMPLEMENTED
;
923 UINT WINAPI
MsiGetProductPropertyW( MSIHANDLE hProduct
, LPCWSTR szProperty
,
924 LPWSTR szValue
, DWORD
*pccbValue
)
926 FIXME("%ld %s %p %p\n", hProduct
, debugstr_w(szProperty
), szValue
, pccbValue
);
927 return ERROR_CALL_NOT_IMPLEMENTED
;
930 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
933 LPWSTR szPack
= NULL
;
935 TRACE("%s\n", debugstr_a(szPackage
) );
939 szPack
= strdupAtoW( szPackage
);
941 return ERROR_OUTOFMEMORY
;
944 r
= MsiVerifyPackageW( szPack
);
951 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
956 TRACE("%s\n", debugstr_w(szPackage
) );
958 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
959 MsiCloseHandle( handle
);
964 INSTALLSTATE WINAPI
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
965 awstring
* lpPathBuf
, DWORD
* pcchBuf
)
967 WCHAR squished_pc
[GUID_SIZE
], squished_comp
[GUID_SIZE
];
973 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
974 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
976 if( !szProduct
|| !szComponent
)
977 return INSTALLSTATE_INVALIDARG
;
978 if( lpPathBuf
->str
.w
&& !pcchBuf
)
979 return INSTALLSTATE_INVALIDARG
;
981 if (!squash_guid( szProduct
, squished_pc
) ||
982 !squash_guid( szComponent
, squished_comp
))
983 return INSTALLSTATE_INVALIDARG
;
985 rc
= MSIREG_OpenProductsKey( szProduct
, &hkey
, FALSE
);
986 if( rc
!= ERROR_SUCCESS
)
987 return INSTALLSTATE_UNKNOWN
;
991 rc
= MSIREG_OpenComponentsKey( szComponent
, &hkey
, FALSE
);
992 if( rc
!= ERROR_SUCCESS
)
993 return INSTALLSTATE_UNKNOWN
;
995 path
= msi_reg_get_val_str( hkey
, squished_pc
);
998 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent
),
999 debugstr_w(szProduct
), debugstr_w(path
));
1002 return INSTALLSTATE_UNKNOWN
;
1005 r
= INSTALLSTATE_LOCAL
;
1007 r
= INSTALLSTATE_NOTUSED
;
1009 msi_strcpy_to_awstring( path
, lpPathBuf
, pcchBuf
);
1015 /******************************************************************
1016 * MsiGetComponentPathW [MSI.@]
1018 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
1019 LPWSTR lpPathBuf
, DWORD
* pcchBuf
)
1023 path
.unicode
= TRUE
;
1024 path
.str
.w
= lpPathBuf
;
1026 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
1029 /******************************************************************
1030 * MsiGetComponentPathA [MSI.@]
1032 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
1033 LPSTR lpPathBuf
, DWORD
* pcchBuf
)
1035 LPWSTR szwProduct
, szwComponent
= NULL
;
1036 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
1039 szwProduct
= strdupAtoW( szProduct
);
1040 if( szProduct
&& !szwProduct
)
1043 szwComponent
= strdupAtoW( szComponent
);
1044 if( szComponent
&& !szwComponent
)
1047 path
.unicode
= FALSE
;
1048 path
.str
.a
= lpPathBuf
;
1050 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
1053 msi_free( szwProduct
);
1054 msi_free( szwComponent
);
1059 /******************************************************************
1060 * MsiQueryFeatureStateA [MSI.@]
1062 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
1064 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
1065 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
1067 szwProduct
= strdupAtoW( szProduct
);
1068 if ( szProduct
&& !szwProduct
)
1071 szwFeature
= strdupAtoW( szFeature
);
1072 if ( szFeature
&& !szwFeature
)
1075 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
1078 msi_free( szwProduct
);
1079 msi_free( szwFeature
);
1084 /******************************************************************
1085 * MsiQueryFeatureStateW [MSI.@]
1087 * Checks the state of a feature
1090 * szProduct [I] Product's GUID string
1091 * szFeature [I] Feature's GUID string
1094 * INSTALLSTATE_LOCAL Feature is installed and useable
1095 * INSTALLSTATE_ABSENT Feature is absent
1096 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
1097 * INSTALLSTATE_UNKNOWN An error occurred
1098 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
1101 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
1103 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
1105 LPWSTR components
, p
, parent_feature
;
1109 BOOL missing
= FALSE
;
1111 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
1113 if (!szProduct
|| !szFeature
)
1114 return INSTALLSTATE_INVALIDARG
;
1116 if (!squash_guid( szProduct
, squishProduct
))
1117 return INSTALLSTATE_INVALIDARG
;
1119 /* check that it's installed at all */
1120 rc
= MSIREG_OpenUserFeaturesKey(szProduct
, &hkey
, FALSE
);
1121 if (rc
!= ERROR_SUCCESS
)
1122 return INSTALLSTATE_UNKNOWN
;
1124 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
1127 if (!parent_feature
)
1128 return INSTALLSTATE_UNKNOWN
;
1130 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
1131 msi_free(parent_feature
);
1132 if (r
== INSTALLSTATE_ABSENT
)
1135 /* now check if it's complete or advertised */
1136 rc
= MSIREG_OpenFeaturesKey(szProduct
, &hkey
, FALSE
);
1137 if (rc
!= ERROR_SUCCESS
)
1138 return INSTALLSTATE_UNKNOWN
;
1140 components
= msi_reg_get_val_str( hkey
, szFeature
);
1143 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
1147 ERR("components missing %s %s\n",
1148 debugstr_w(szProduct
), debugstr_w(szFeature
));
1149 return INSTALLSTATE_UNKNOWN
;
1152 for( p
= components
; *p
!= 2 ; p
+= 20)
1154 if (!decode_base85_guid( p
, &guid
))
1156 ERR("%s\n", debugstr_w(p
));
1159 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
1160 r
= MsiGetComponentPathW(szProduct
, comp
, NULL
, 0);
1161 TRACE("component %s state %d\n", debugstr_guid(&guid
), r
);
1164 case INSTALLSTATE_NOTUSED
:
1165 case INSTALLSTATE_LOCAL
:
1166 case INSTALLSTATE_SOURCE
:
1173 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
1174 msi_free(components
);
1177 return INSTALLSTATE_ADVERTISED
;
1179 return INSTALLSTATE_LOCAL
;
1182 /******************************************************************
1183 * MsiGetFileVersionA [MSI.@]
1185 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
1186 DWORD
* pcchVersionBuf
, LPSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1188 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
1189 UINT ret
= ERROR_OUTOFMEMORY
;
1193 szwFilePath
= strdupAtoW( szFilePath
);
1198 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1200 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
1201 if( !lpwVersionBuff
)
1205 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1207 lpwLangBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
1212 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
1213 lpwLangBuff
, pcchLangBuf
);
1215 if( lpwVersionBuff
)
1216 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
1217 lpVersionBuf
, *pcchVersionBuf
, NULL
, NULL
);
1219 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
1220 lpLangBuf
, *pcchLangBuf
, NULL
, NULL
);
1223 msi_free(szwFilePath
);
1224 msi_free(lpwVersionBuff
);
1225 msi_free(lpwLangBuff
);
1230 /******************************************************************
1231 * MsiGetFileVersionW [MSI.@]
1233 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
1234 DWORD
* pcchVersionBuf
, LPWSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1236 static WCHAR szVersionResource
[] = {'\\',0};
1237 static const WCHAR szVersionFormat
[] = {
1238 '%','d','.','%','d','.','%','d','.','%','d',0};
1239 static const WCHAR szLangFormat
[] = {'%','d',0};
1242 LPVOID lpVer
= NULL
;
1243 VS_FIXEDFILEINFO
*ffi
;
1247 TRACE("%s %p %ld %p %ld\n", debugstr_w(szFilePath
),
1248 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
1249 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
1251 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
1253 return GetLastError();
1255 lpVer
= msi_alloc(dwVerLen
);
1258 ret
= ERROR_OUTOFMEMORY
;
1262 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
1264 ret
= GetLastError();
1267 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1269 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
1272 wsprintfW(tmp
, szVersionFormat
,
1273 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
1274 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
1275 lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
1276 *pcchVersionBuf
= lstrlenW(lpVersionBuf
);
1281 *pcchVersionBuf
= 0;
1285 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1287 DWORD lang
= GetUserDefaultLangID();
1289 FIXME("Retrieve language from file\n");
1290 wsprintfW(tmp
, szLangFormat
, lang
);
1291 lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
1292 *pcchLangBuf
= lstrlenW(lpLangBuf
);
1300 /***********************************************************************
1301 * MsiGetFeatureUsageW [MSI.@]
1303 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1304 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1306 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
1307 pdwUseCount
, pwDateUsed
);
1308 return ERROR_CALL_NOT_IMPLEMENTED
;
1311 /***********************************************************************
1312 * MsiGetFeatureUsageA [MSI.@]
1314 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
1315 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1317 LPWSTR prod
= NULL
, feat
= NULL
;
1318 UINT ret
= ERROR_OUTOFMEMORY
;
1320 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1321 pdwUseCount
, pwDateUsed
);
1323 prod
= strdupAtoW( szProduct
);
1324 if (szProduct
&& !prod
)
1327 feat
= strdupAtoW( szFeature
);
1328 if (szFeature
&& !feat
)
1331 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
1340 /***********************************************************************
1341 * MsiUseFeatureExW [MSI.@]
1343 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1344 DWORD dwInstallMode
, DWORD dwReserved
)
1348 TRACE("%s %s %li %li\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
1349 dwInstallMode
, dwReserved
);
1351 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
1354 return INSTALLSTATE_INVALIDARG
;
1356 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
1358 FIXME("mark product %s feature %s as used\n",
1359 debugstr_w(szProduct
), debugstr_w(szFeature
) );
1365 /***********************************************************************
1366 * MsiUseFeatureExA [MSI.@]
1368 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
1369 DWORD dwInstallMode
, DWORD dwReserved
)
1371 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
1372 LPWSTR prod
= NULL
, feat
= NULL
;
1374 TRACE("%s %s %li %li\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1375 dwInstallMode
, dwReserved
);
1377 prod
= strdupAtoW( szProduct
);
1378 if (szProduct
&& !prod
)
1381 feat
= strdupAtoW( szFeature
);
1382 if (szFeature
&& !feat
)
1385 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
1394 /***********************************************************************
1395 * MsiUseFeatureW [MSI.@]
1397 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
1399 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
1402 /***********************************************************************
1403 * MsiUseFeatureA [MSI.@]
1405 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
1407 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
1410 /***********************************************************************
1411 * MSI_ProvideQualifiedComponentEx [internal]
1413 UINT WINAPI
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
1414 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR szProduct
,
1415 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
1418 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
1419 feature
[MAX_FEATURE_CHARS
+1];
1425 TRACE("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent
),
1426 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
1427 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1429 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
1430 if (rc
!= ERROR_SUCCESS
)
1431 return ERROR_INDEX_ABSENT
;
1433 info
= msi_reg_get_val_str( hkey
, szQualifier
);
1437 return ERROR_INDEX_ABSENT
;
1439 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
1442 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
1444 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
1448 if (rc
!= INSTALLSTATE_LOCAL
)
1449 return ERROR_FILE_NOT_FOUND
;
1451 return ERROR_SUCCESS
;
1454 /***********************************************************************
1455 * MsiProvideQualifiedComponentExW [MSI.@]
1457 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
1458 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR szProduct
,
1459 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
1464 path
.unicode
= TRUE
;
1465 path
.str
.w
= lpPathBuf
;
1467 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
1468 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
1471 /***********************************************************************
1472 * MsiProvideQualifiedComponentExA [MSI.@]
1474 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
1475 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR szProduct
,
1476 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
1479 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
1480 UINT r
= ERROR_OUTOFMEMORY
;
1483 TRACE("%s %s %lu %s %lu %lu %p %p\n", debugstr_a(szComponent
),
1484 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
1485 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1487 szwComponent
= strdupAtoW( szComponent
);
1488 if (szComponent
&& !szwComponent
)
1491 szwQualifier
= strdupAtoW( szQualifier
);
1492 if (szQualifier
&& !szwQualifier
)
1495 szwProduct
= strdupAtoW( szProduct
);
1496 if (szProduct
&& !szwProduct
)
1499 path
.unicode
= FALSE
;
1500 path
.str
.a
= lpPathBuf
;
1502 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
1503 dwInstallMode
, szwProduct
, Unused1
,
1504 Unused2
, &path
, pcchPathBuf
);
1506 msi_free(szwProduct
);
1507 msi_free(szwComponent
);
1508 msi_free(szwQualifier
);
1513 /***********************************************************************
1514 * MsiProvideQualifiedComponentW [MSI.@]
1516 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
1517 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
1520 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
1521 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1524 /***********************************************************************
1525 * MsiProvideQualifiedComponentA [MSI.@]
1527 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
1528 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
1531 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
1532 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1535 /***********************************************************************
1536 * MSI_GetUserInfo [internal]
1538 USERINFOSTATE WINAPI
MSI_GetUserInfo(LPCWSTR szProduct
,
1539 awstring
*lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1540 awstring
*lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1541 awstring
*lpSerialBuf
, DWORD
* pcchSerialBuf
)
1544 LPWSTR user
, org
, serial
;
1546 USERINFOSTATE state
;
1548 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct
), lpUserNameBuf
,
1549 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
1553 return USERINFOSTATE_INVALIDARG
;
1555 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
1556 if (r
!= ERROR_SUCCESS
)
1557 return USERINFOSTATE_UNKNOWN
;
1559 user
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGOWNERW
);
1560 org
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGCOMPANYW
);
1561 serial
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_PRODUCTIDW
);
1565 state
= USERINFOSTATE_PRESENT
;
1567 r
= msi_strcpy_to_awstring( user
, lpUserNameBuf
, pcchUserNameBuf
);
1568 if (r
== ERROR_MORE_DATA
)
1569 state
= USERINFOSTATE_MOREDATA
;
1570 r
= msi_strcpy_to_awstring( org
, lpOrgNameBuf
, pcchOrgNameBuf
);
1571 if (r
== ERROR_MORE_DATA
)
1572 state
= USERINFOSTATE_MOREDATA
;
1573 r
= msi_strcpy_to_awstring( serial
, lpSerialBuf
, pcchSerialBuf
);
1574 if (r
== ERROR_MORE_DATA
)
1575 state
= USERINFOSTATE_MOREDATA
;
1584 /***********************************************************************
1585 * MsiGetUserInfoW [MSI.@]
1587 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
1588 LPWSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1589 LPWSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1590 LPWSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1592 awstring user
, org
, serial
;
1594 user
.unicode
= TRUE
;
1595 user
.str
.w
= lpUserNameBuf
;
1597 org
.str
.w
= lpOrgNameBuf
;
1598 serial
.unicode
= TRUE
;
1599 serial
.str
.w
= lpSerialBuf
;
1601 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
1602 &org
, pcchOrgNameBuf
,
1603 &serial
, pcchSerialBuf
);
1606 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
1607 LPSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1608 LPSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1609 LPSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1611 awstring user
, org
, serial
;
1615 prod
= strdupAtoW( szProduct
);
1616 if (szProduct
&& !prod
)
1617 return ERROR_OUTOFMEMORY
;
1619 user
.unicode
= FALSE
;
1620 user
.str
.a
= lpUserNameBuf
;
1621 org
.unicode
= FALSE
;
1622 org
.str
.a
= lpOrgNameBuf
;
1623 serial
.unicode
= FALSE
;
1624 serial
.str
.a
= lpSerialBuf
;
1626 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
1627 &org
, pcchOrgNameBuf
,
1628 &serial
, pcchSerialBuf
);
1635 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
1639 MSIPACKAGE
*package
;
1640 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1642 TRACE("(%s)\n",debugstr_w(szProduct
));
1644 rc
= MsiOpenProductW(szProduct
,&handle
);
1645 if (rc
!= ERROR_SUCCESS
)
1646 return ERROR_INVALID_PARAMETER
;
1648 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1649 rc
= ACTION_PerformUIAction(package
, szFirstRun
);
1650 msiobj_release( &package
->hdr
);
1652 MsiCloseHandle(handle
);
1657 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
1661 MSIPACKAGE
*package
;
1662 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1664 TRACE("(%s)\n",debugstr_a(szProduct
));
1666 rc
= MsiOpenProductA(szProduct
,&handle
);
1667 if (rc
!= ERROR_SUCCESS
)
1668 return ERROR_INVALID_PARAMETER
;
1670 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1671 rc
= ACTION_PerformUIAction(package
, szFirstRun
);
1672 msiobj_release( &package
->hdr
);
1674 MsiCloseHandle(handle
);
1679 /***********************************************************************
1680 * MsiConfigureFeatureA [MSI.@]
1682 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
1684 LPWSTR prod
, feat
= NULL
;
1685 UINT r
= ERROR_OUTOFMEMORY
;
1687 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
1689 prod
= strdupAtoW( szProduct
);
1690 if (szProduct
&& !prod
)
1693 feat
= strdupAtoW( szFeature
);
1694 if (szFeature
&& !feat
)
1697 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
1706 /***********************************************************************
1707 * MsiConfigureFeatureW [MSI.@]
1709 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
1711 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
1712 MSIPACKAGE
*package
= NULL
;
1714 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
1717 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
1719 if (!szProduct
|| !szFeature
)
1720 return ERROR_INVALID_PARAMETER
;
1722 switch (eInstallState
)
1724 case INSTALLSTATE_DEFAULT
:
1725 /* FIXME: how do we figure out the default location? */
1726 eInstallState
= INSTALLSTATE_LOCAL
;
1728 case INSTALLSTATE_LOCAL
:
1729 case INSTALLSTATE_SOURCE
:
1730 case INSTALLSTATE_ABSENT
:
1731 case INSTALLSTATE_ADVERTISED
:
1734 return ERROR_INVALID_PARAMETER
;
1737 r
= MSI_OpenProductW( szProduct
, &package
);
1738 if (r
!= ERROR_SUCCESS
)
1741 sz
= sizeof(sourcepath
);
1742 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1743 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
1745 sz
= sizeof(filename
);
1746 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1747 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
1749 lstrcatW( sourcepath
, filename
);
1751 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
1753 r
= ACTION_PerformUIAction( package
, szCostInit
);
1754 if (r
!= ERROR_SUCCESS
)
1757 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
1758 if (r
!= ERROR_SUCCESS
)
1761 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
1764 msiobj_release( &package
->hdr
);
1769 /***********************************************************************
1770 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
1772 * Notes: undocumented
1774 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
1776 WCHAR path
[MAX_PATH
];
1778 TRACE("%ld\n", dwReserved
);
1782 FIXME("dwReserved=%ld\n", dwReserved
);
1783 return ERROR_INVALID_PARAMETER
;
1786 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
1787 return ERROR_FUNCTION_FAILED
;
1789 lstrcatW(path
, installerW
);
1791 if (!CreateDirectoryW(path
, NULL
))
1792 return ERROR_FUNCTION_FAILED
;
1794 return ERROR_SUCCESS
;
1797 /***********************************************************************
1798 * MsiGetShortcutTargetA [MSI.@]
1800 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
1801 LPSTR szProductCode
, LPSTR szFeatureId
,
1802 LPSTR szComponentCode
)
1805 const int len
= MAX_FEATURE_CHARS
+1;
1806 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
1809 target
= strdupAtoW( szShortcutTarget
);
1810 if (szShortcutTarget
&& !target
)
1811 return ERROR_OUTOFMEMORY
;
1815 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
1817 if (r
== ERROR_SUCCESS
)
1819 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
1820 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
1821 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
1826 /***********************************************************************
1827 * MsiGetShortcutTargetW [MSI.@]
1829 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
1830 LPWSTR szProductCode
, LPWSTR szFeatureId
,
1831 LPWSTR szComponentCode
)
1833 IShellLinkDataList
*dl
= NULL
;
1834 IPersistFile
*pf
= NULL
;
1835 LPEXP_DARWIN_LINK darwin
= NULL
;
1838 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
1839 szProductCode
, szFeatureId
, szComponentCode
);
1841 init
= CoInitialize(NULL
);
1843 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
1844 &IID_IPersistFile
, (LPVOID
*) &pf
);
1845 if( SUCCEEDED( r
) )
1847 r
= IPersistFile_Load( pf
, szShortcutTarget
,
1848 STGM_READ
| STGM_SHARE_DENY_WRITE
);
1849 if( SUCCEEDED( r
) )
1851 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
1853 if( SUCCEEDED( r
) )
1855 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
1857 IShellLinkDataList_Release( dl
);
1860 IPersistFile_Release( pf
);
1863 if (SUCCEEDED(init
))
1866 TRACE("darwin = %p\n", darwin
);
1873 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
1874 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
1875 LocalFree( darwin
);
1879 return ERROR_FUNCTION_FAILED
;
1882 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1883 DWORD dwReinstallMode
)
1885 MSIPACKAGE
* package
= NULL
;
1887 WCHAR sourcepath
[MAX_PATH
];
1888 WCHAR filename
[MAX_PATH
];
1889 static const WCHAR szLogVerbose
[] = {
1890 ' ','L','O','G','V','E','R','B','O','S','E',0 };
1891 static const WCHAR szInstalled
[] = { 'I','n','s','t','a','l','l','e','d',0};
1892 static const WCHAR szReinstall
[] = {'R','E','I','N','S','T','A','L','L',0};
1893 static const WCHAR szReinstallMode
[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
1894 static const WCHAR szOne
[] = {'1',0};
1895 WCHAR reinstallmode
[11];
1899 FIXME("%s %s %li\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
1902 ptr
= reinstallmode
;
1904 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
1906 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
1908 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
1910 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
1912 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
1914 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
1916 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
1918 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
1920 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
1922 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
1926 sz
= sizeof(sourcepath
);
1927 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1928 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
1930 sz
= sizeof(filename
);
1931 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1932 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
1934 lstrcatW( sourcepath
, filename
);
1936 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
1937 r
= MSI_OpenPackageW( sourcepath
, &package
);
1939 r
= MSI_OpenProductW( szProduct
, &package
);
1941 if (r
!= ERROR_SUCCESS
)
1944 MSI_SetPropertyW( package
, szReinstallMode
, reinstallmode
);
1945 MSI_SetPropertyW( package
, szInstalled
, szOne
);
1946 MSI_SetPropertyW( package
, szLogVerbose
, szOne
);
1947 MSI_SetPropertyW( package
, szReinstall
, szFeature
);
1949 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
1951 msiobj_release( &package
->hdr
);
1956 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
1957 DWORD dwReinstallMode
)
1963 TRACE("%s %s %li\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1966 wszProduct
= strdupAtoW(szProduct
);
1967 wszFeature
= strdupAtoW(szFeature
);
1969 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
1971 msi_free(wszProduct
);
1972 msi_free(wszFeature
);
1979 unsigned int buf
[4];
1980 unsigned char in
[64];
1981 unsigned char digest
[16];
1984 extern VOID WINAPI
MD5Init( MD5_CTX
*);
1985 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
1986 extern VOID WINAPI
MD5Final( MD5_CTX
*);
1988 /***********************************************************************
1989 * MsiGetFileHashW [MSI.@]
1991 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
1992 PMSIFILEHASHINFO pHash
)
1994 HANDLE handle
, mapping
;
1997 UINT r
= ERROR_FUNCTION_FAILED
;
1999 TRACE("%s %08lx %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
2002 return ERROR_INVALID_PARAMETER
;
2004 return ERROR_INVALID_PARAMETER
;
2005 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
2006 return ERROR_INVALID_PARAMETER
;
2008 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
2009 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
2010 if (handle
== INVALID_HANDLE_VALUE
)
2011 return ERROR_FILE_NOT_FOUND
;
2013 length
= GetFileSize( handle
, NULL
);
2015 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
2018 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
2024 MD5Update( &ctx
, p
, length
);
2026 UnmapViewOfFile( p
);
2028 memcpy( pHash
->dwData
, &ctx
.digest
, sizeof pHash
->dwData
);
2031 CloseHandle( mapping
);
2033 CloseHandle( handle
);
2038 /***********************************************************************
2039 * MsiGetFileHashA [MSI.@]
2041 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
2042 PMSIFILEHASHINFO pHash
)
2047 TRACE("%s %08lx %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
2049 file
= strdupAtoW( szFilePath
);
2050 if (szFilePath
&& !file
)
2051 return ERROR_OUTOFMEMORY
;
2053 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
2058 /***********************************************************************
2059 * MsiAdvertiseScriptW [MSI.@]
2061 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
2062 PHKEY phRegData
, BOOL fRemoveItems
)
2064 FIXME("%s %08lx %p %d\n",
2065 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2066 return ERROR_CALL_NOT_IMPLEMENTED
;
2069 /***********************************************************************
2070 * MsiAdvertiseScriptA [MSI.@]
2072 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
2073 PHKEY phRegData
, BOOL fRemoveItems
)
2075 FIXME("%s %08lx %p %d\n",
2076 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2077 return ERROR_CALL_NOT_IMPLEMENTED
;