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
);
128 msiobj_release( &package
->hdr
);
133 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
134 LPCSTR szTransforms
, LANGID lgidLanguage
)
136 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
137 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
138 return ERROR_CALL_NOT_IMPLEMENTED
;
141 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
142 LPCWSTR szTransforms
, LANGID lgidLanguage
)
144 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
145 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
146 return ERROR_CALL_NOT_IMPLEMENTED
;
149 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
150 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
152 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_a(szPackagePath
),
153 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
154 lgidLanguage
, dwPlatform
, dwOptions
);
155 return ERROR_CALL_NOT_IMPLEMENTED
;
158 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
159 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
161 FIXME("%s %s %s %08x %08lx %08lx\n", debugstr_w(szPackagePath
),
162 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
163 lgidLanguage
, dwPlatform
, dwOptions
);
164 return ERROR_CALL_NOT_IMPLEMENTED
;
167 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
169 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
170 UINT r
= ERROR_OUTOFMEMORY
;
172 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
176 szwPath
= strdupAtoW( szPackagePath
);
183 szwCommand
= strdupAtoW( szCommandLine
);
188 r
= MsiInstallProductW( szwPath
, szwCommand
);
192 msi_free( szwCommand
);
197 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
199 MSIPACKAGE
*package
= NULL
;
202 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
204 r
= MSI_OpenPackageW( szPackagePath
, &package
);
205 if (r
== ERROR_SUCCESS
)
207 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
208 msiobj_release( &package
->hdr
);
214 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
216 FIXME("%s %08lx\n", debugstr_a(szProduct
), dwReinstallMode
);
217 return ERROR_CALL_NOT_IMPLEMENTED
;
220 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
222 FIXME("%s %08lx\n", debugstr_w(szProduct
), dwReinstallMode
);
223 return ERROR_CALL_NOT_IMPLEMENTED
;
226 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
227 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
229 FIXME("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
230 eInstallType
, debugstr_a(szCommandLine
));
231 return ERROR_CALL_NOT_IMPLEMENTED
;
234 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
235 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
237 FIXME("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
238 eInstallType
, debugstr_w(szCommandLine
));
239 return ERROR_CALL_NOT_IMPLEMENTED
;
242 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
243 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
245 MSIPACKAGE
* package
= NULL
;
248 WCHAR sourcepath
[MAX_PATH
];
249 WCHAR filename
[MAX_PATH
];
250 static const WCHAR szInstalled
[] = {
251 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
254 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
255 debugstr_w(szCommandLine
));
257 if (eInstallState
!= INSTALLSTATE_LOCAL
&&
258 eInstallState
!= INSTALLSTATE_DEFAULT
)
260 FIXME("Not implemented for anything other than local installs\n");
261 return ERROR_CALL_NOT_IMPLEMENTED
;
264 sz
= sizeof(sourcepath
);
265 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
266 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
,
269 sz
= sizeof(filename
);
270 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
271 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
273 lstrcatW(sourcepath
,filename
);
276 * ok 1, we need to find the msi file for this product.
277 * 2, find the source dir for the files
278 * 3, do the configure/install.
279 * 4, cleanupany runonce entry.
282 r
= MSI_OpenProductW( szProduct
, &package
);
283 if (r
!= ERROR_SUCCESS
)
286 sz
= lstrlenW(szInstalled
) + 1;
289 sz
+= lstrlenW(szCommandLine
);
291 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
294 r
= ERROR_OUTOFMEMORY
;
300 lstrcpyW(commandline
,szCommandLine
);
302 if (MsiQueryProductStateW(szProduct
) != INSTALLSTATE_UNKNOWN
)
303 lstrcatW(commandline
,szInstalled
);
305 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
307 msi_free(commandline
);
310 msiobj_release( &package
->hdr
);
315 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
316 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
318 LPWSTR szwProduct
= NULL
;
319 LPWSTR szwCommandLine
= NULL
;
320 UINT r
= ERROR_OUTOFMEMORY
;
324 szwProduct
= strdupAtoW( szProduct
);
331 szwCommandLine
= strdupAtoW( szCommandLine
);
336 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
339 msi_free( szwProduct
);
340 msi_free( szwCommandLine
);
345 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
346 INSTALLSTATE eInstallState
)
348 LPWSTR szwProduct
= NULL
;
351 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
355 szwProduct
= strdupAtoW( szProduct
);
357 return ERROR_OUTOFMEMORY
;
360 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
361 msi_free( szwProduct
);
366 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
367 INSTALLSTATE eInstallState
)
369 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
372 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
374 LPWSTR szwComponent
= NULL
;
376 WCHAR szwBuffer
[GUID_SIZE
];
378 TRACE("%s %s\n",debugstr_a(szComponent
), debugstr_a(szBuffer
));
382 szwComponent
= strdupAtoW( szComponent
);
384 return ERROR_OUTOFMEMORY
;
387 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
389 if( ERROR_SUCCESS
== r
)
390 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
392 msi_free( szwComponent
);
397 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
401 WCHAR szSquished
[GUID_SIZE
];
402 DWORD sz
= GUID_SIZE
;
403 static const WCHAR szPermKey
[] =
404 { '0','0','0','0','0','0','0','0','0','0','0','0',
405 '0','0','0','0','0','0','0','0','0','0','0','0',
406 '0','0','0','0','0','0','0','0',0};
408 TRACE("%s %p\n",debugstr_w(szComponent
), szBuffer
);
410 if (NULL
== szComponent
)
411 return ERROR_INVALID_PARAMETER
;
413 rc
= MSIREG_OpenComponentsKey( szComponent
, &hkey
, FALSE
);
414 if (rc
!= ERROR_SUCCESS
)
415 return ERROR_UNKNOWN_COMPONENT
;
417 rc
= RegEnumValueW(hkey
, 0, szSquished
, &sz
, NULL
, NULL
, NULL
, NULL
);
418 if (rc
== ERROR_SUCCESS
&& strcmpW(szSquished
,szPermKey
)==0)
421 rc
= RegEnumValueW(hkey
, 1, szSquished
, &sz
, NULL
, NULL
, NULL
, NULL
);
426 if (rc
!= ERROR_SUCCESS
)
427 return ERROR_INSTALL_FAILURE
;
429 unsquash_guid(szSquished
, szBuffer
);
430 return ERROR_SUCCESS
;
433 UINT WINAPI
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
434 awstring
*szValue
, DWORD
*pcchValueBuf
)
440 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
441 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
444 * FIXME: Values seem scattered/duplicated in the registry. Is there a system?
447 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
448 return ERROR_INVALID_PARAMETER
;
450 /* check for special properties */
451 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
454 WCHAR packagecode
[35];
456 r
= MSIREG_OpenUserProductsKey(szProduct
, &hkey
, FALSE
);
457 if (r
!= ERROR_SUCCESS
)
458 return ERROR_UNKNOWN_PRODUCT
;
460 regval
= msi_reg_get_val_str( hkey
, szAttribute
);
463 if (unsquash_guid(regval
, packagecode
))
464 val
= strdupW(packagecode
);
470 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
472 static const WCHAR one
[] = { '1',0 };
474 * FIXME: should be in the Product key (user or system?)
475 * but isn't written yet...
477 val
= strdupW( one
);
479 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
480 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONW
))
482 static const WCHAR fmt
[] = { '%','u',0 };
486 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
487 if (r
!= ERROR_SUCCESS
)
488 return ERROR_UNKNOWN_PRODUCT
;
490 if (msi_reg_get_val_dword( hkey
, szAttribute
, ®val
))
492 sprintfW(szVal
, fmt
, regval
);
493 val
= strdupW( szVal
);
498 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
))
500 r
= MSIREG_OpenUserProductsKey(szProduct
, &hkey
, FALSE
);
501 if (r
!= ERROR_SUCCESS
)
502 return ERROR_UNKNOWN_PRODUCT
;
504 val
= msi_reg_get_val_str( hkey
, szAttribute
);
510 static const WCHAR szDisplayVersion
[] = {
511 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0 };
513 FIXME("%s\n", debugstr_w(szAttribute
));
514 /* FIXME: some attribute values not tested... */
516 if (!lstrcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
517 szAttribute
= szDisplayVersion
;
519 r
= MSIREG_OpenUninstallKey( szProduct
, &hkey
, FALSE
);
520 if (r
!= ERROR_SUCCESS
)
521 return ERROR_UNKNOWN_PRODUCT
;
523 val
= msi_reg_get_val_str( hkey
, szAttribute
);
528 TRACE("returning %s\n", debugstr_w(val
));
531 return ERROR_UNKNOWN_PROPERTY
;
533 r
= msi_strcpy_to_awstring( val
, szValue
, pcchValueBuf
);
540 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
541 LPSTR szBuffer
, DWORD
*pcchValueBuf
)
543 LPWSTR szwProduct
, szwAttribute
= NULL
;
544 UINT r
= ERROR_OUTOFMEMORY
;
547 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
548 szBuffer
, pcchValueBuf
);
550 szwProduct
= strdupAtoW( szProduct
);
551 if( szProduct
&& !szwProduct
)
554 szwAttribute
= strdupAtoW( szAttribute
);
555 if( szAttribute
&& !szwAttribute
)
558 buffer
.unicode
= FALSE
;
559 buffer
.str
.a
= szBuffer
;
561 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
562 &buffer
, pcchValueBuf
);
565 msi_free( szwProduct
);
566 msi_free( szwAttribute
);
571 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
572 LPWSTR szBuffer
, DWORD
*pcchValueBuf
)
576 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
577 szBuffer
, pcchValueBuf
);
579 buffer
.unicode
= TRUE
;
580 buffer
.str
.w
= szBuffer
;
582 return MSI_GetProductInfo( szProduct
, szAttribute
,
583 &buffer
, pcchValueBuf
);
586 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
588 LPWSTR szwLogFile
= NULL
;
591 TRACE("%08lx %s %08lx\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
595 szwLogFile
= strdupAtoW( szLogFile
);
597 return ERROR_OUTOFMEMORY
;
599 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
600 msi_free( szwLogFile
);
604 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
606 HANDLE file
= INVALID_HANDLE_VALUE
;
608 TRACE("%08lx %s %08lx\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
612 lstrcpyW(gszLogFile
,szLogFile
);
613 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
614 DeleteFileW(szLogFile
);
615 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, 0, NULL
, OPEN_ALWAYS
,
616 FILE_ATTRIBUTE_NORMAL
, NULL
);
617 if (file
!= INVALID_HANDLE_VALUE
)
620 ERR("Unable to enable log %s\n",debugstr_w(szLogFile
));
623 gszLogFile
[0] = '\0';
625 return ERROR_SUCCESS
;
628 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
630 LPWSTR szwProduct
= NULL
;
635 szwProduct
= strdupAtoW( szProduct
);
637 return ERROR_OUTOFMEMORY
;
639 r
= MsiQueryProductStateW( szwProduct
);
640 msi_free( szwProduct
);
644 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
647 INSTALLSTATE rrc
= INSTALLSTATE_UNKNOWN
;
649 static const WCHAR szWindowsInstaller
[] = {
650 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0 };
653 TRACE("%s\n", debugstr_w(szProduct
));
656 return INSTALLSTATE_INVALIDARG
;
658 rc
= MSIREG_OpenUserProductsKey(szProduct
,&hkey
,FALSE
);
659 if (rc
!= ERROR_SUCCESS
)
664 rc
= MSIREG_OpenUninstallKey(szProduct
,&hkey
,FALSE
);
665 if (rc
!= ERROR_SUCCESS
)
669 rc
= RegQueryValueExW(hkey
,szWindowsInstaller
,NULL
,NULL
,(LPVOID
)&rrc
, &sz
);
670 if (rc
!= ERROR_SUCCESS
)
677 rrc
= INSTALLSTATE_DEFAULT
;
680 FIXME("Unknown install state read from registry (%i)\n",rrc
);
681 rrc
= INSTALLSTATE_UNKNOWN
;
689 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
691 INSTALLUILEVEL old
= gUILevel
;
692 HWND oldwnd
= gUIhwnd
;
694 TRACE("%08x %p\n", dwUILevel
, phWnd
);
696 gUILevel
= dwUILevel
;
705 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
706 DWORD dwMessageFilter
, LPVOID pvContext
)
708 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
710 TRACE("%p %lx %p\n",puiHandler
, dwMessageFilter
,pvContext
);
711 gUIHandlerA
= puiHandler
;
712 gUIFilter
= dwMessageFilter
;
713 gUIContext
= pvContext
;
718 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
719 DWORD dwMessageFilter
, LPVOID pvContext
)
721 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
723 TRACE("%p %lx %p\n",puiHandler
,dwMessageFilter
,pvContext
);
724 gUIHandlerW
= puiHandler
;
725 gUIFilter
= dwMessageFilter
;
726 gUIContext
= pvContext
;
731 /******************************************************************
732 * MsiLoadStringW [MSI.@]
734 * Loads a string from MSI's string resources.
738 * handle [I] only -1 is handled currently
739 * id [I] id of the string to be loaded
740 * lpBuffer [O] buffer for the string to be written to
741 * nBufferMax [I] maximum size of the buffer in characters
742 * lang [I] the preferred language for the string
746 * If successful, this function returns the language id of the string loaded
747 * If the function fails, the function returns zero.
751 * The type of the first parameter is unknown. LoadString's prototype
752 * suggests that it might be a module handle. I have made it an MSI handle
753 * for starters, as -1 is an invalid MSI handle, but not an invalid module
754 * handle. Maybe strings can be stored in an MSI database somehow.
756 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
757 int nBufferMax
, LANGID lang
)
764 TRACE("%ld %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
767 FIXME("don't know how to deal with handle = %08lx\n", handle
);
770 lang
= GetUserDefaultLangID();
772 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
776 hResData
= LoadResource( msi_hInstance
, hres
);
779 p
= LockResource( hResData
);
783 for (i
= 0; i
< (id
&0xf); i
++)
787 if( nBufferMax
<= len
)
790 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
793 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
798 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
799 int nBufferMax
, LANGID lang
)
805 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
806 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
809 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
810 if( len
<= nBufferMax
)
811 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
812 lpBuffer
, nBufferMax
, NULL
, NULL
);
820 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
823 char szProduct
[GUID_SIZE
];
825 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
827 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
828 return INSTALLSTATE_UNKNOWN
;
830 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
833 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
836 WCHAR szProduct
[GUID_SIZE
];
838 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
840 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
841 return INSTALLSTATE_UNKNOWN
;
843 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
846 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
847 WORD wLanguageId
, DWORD f
)
849 FIXME("%p %s %s %u %08x %08lx\n",hWnd
,debugstr_a(lpText
),debugstr_a(lpCaption
),
850 uType
,wLanguageId
,f
);
851 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
854 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
855 WORD wLanguageId
, DWORD f
)
857 FIXME("%p %s %s %u %08x %08lx\n",hWnd
,debugstr_w(lpText
),debugstr_w(lpCaption
),
858 uType
,wLanguageId
,f
);
859 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
862 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
863 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
866 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_a(szAssemblyName
),
867 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
869 return ERROR_CALL_NOT_IMPLEMENTED
;
872 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
873 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
876 FIXME("%s %s %08lx %08lx %p %p\n", debugstr_w(szAssemblyName
),
877 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
879 return ERROR_CALL_NOT_IMPLEMENTED
;
882 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
883 LPSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
885 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
886 return ERROR_CALL_NOT_IMPLEMENTED
;
889 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
890 LPWSTR szPath
, DWORD
*pcchPath
, DWORD
*pcchArgs
)
892 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
893 return ERROR_CALL_NOT_IMPLEMENTED
;
896 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
897 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
900 FIXME("%s %08lx %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
901 ppcCertContext
, pbHashData
, pcbHashData
);
902 return ERROR_CALL_NOT_IMPLEMENTED
;
905 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
906 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, BYTE
* pbHashData
,
909 FIXME("%s %08lx %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
910 ppcCertContext
, pbHashData
, pcbHashData
);
911 return ERROR_CALL_NOT_IMPLEMENTED
;
914 UINT WINAPI
MsiGetProductPropertyA( MSIHANDLE hProduct
, LPCSTR szProperty
,
915 LPSTR szValue
, DWORD
*pccbValue
)
917 FIXME("%ld %s %p %p\n", hProduct
, debugstr_a(szProperty
), szValue
, pccbValue
);
918 return ERROR_CALL_NOT_IMPLEMENTED
;
921 UINT WINAPI
MsiGetProductPropertyW( MSIHANDLE hProduct
, LPCWSTR szProperty
,
922 LPWSTR szValue
, DWORD
*pccbValue
)
924 FIXME("%ld %s %p %p\n", hProduct
, debugstr_w(szProperty
), szValue
, pccbValue
);
925 return ERROR_CALL_NOT_IMPLEMENTED
;
928 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
931 LPWSTR szPack
= NULL
;
933 TRACE("%s\n", debugstr_a(szPackage
) );
937 szPack
= strdupAtoW( szPackage
);
939 return ERROR_OUTOFMEMORY
;
942 r
= MsiVerifyPackageW( szPack
);
949 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
954 TRACE("%s\n", debugstr_w(szPackage
) );
956 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
957 MsiCloseHandle( handle
);
962 INSTALLSTATE WINAPI
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
963 awstring
* lpPathBuf
, DWORD
* pcchBuf
)
965 WCHAR squished_pc
[GUID_SIZE
], squished_comp
[GUID_SIZE
];
971 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
972 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
974 if( !szProduct
|| !szComponent
)
975 return INSTALLSTATE_INVALIDARG
;
976 if( lpPathBuf
->str
.w
&& !pcchBuf
)
977 return INSTALLSTATE_INVALIDARG
;
979 if (!squash_guid( szProduct
, squished_pc
) ||
980 !squash_guid( szComponent
, squished_comp
))
981 return INSTALLSTATE_INVALIDARG
;
983 rc
= MSIREG_OpenProductsKey( szProduct
, &hkey
, FALSE
);
984 if( rc
!= ERROR_SUCCESS
)
985 return INSTALLSTATE_UNKNOWN
;
989 rc
= MSIREG_OpenComponentsKey( szComponent
, &hkey
, FALSE
);
990 if( rc
!= ERROR_SUCCESS
)
991 return INSTALLSTATE_UNKNOWN
;
993 path
= msi_reg_get_val_str( hkey
, squished_pc
);
996 TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent
),
997 debugstr_w(szProduct
), debugstr_w(path
));
1000 return INSTALLSTATE_UNKNOWN
;
1003 r
= INSTALLSTATE_LOCAL
;
1005 r
= INSTALLSTATE_NOTUSED
;
1007 msi_strcpy_to_awstring( path
, lpPathBuf
, pcchBuf
);
1013 /******************************************************************
1014 * MsiGetComponentPathW [MSI.@]
1016 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
1017 LPWSTR lpPathBuf
, DWORD
* pcchBuf
)
1021 path
.unicode
= TRUE
;
1022 path
.str
.w
= lpPathBuf
;
1024 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
1027 /******************************************************************
1028 * MsiGetComponentPathA [MSI.@]
1030 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
1031 LPSTR lpPathBuf
, DWORD
* pcchBuf
)
1033 LPWSTR szwProduct
, szwComponent
= NULL
;
1034 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
1037 szwProduct
= strdupAtoW( szProduct
);
1038 if( szProduct
&& !szwProduct
)
1041 szwComponent
= strdupAtoW( szComponent
);
1042 if( szComponent
&& !szwComponent
)
1045 path
.unicode
= FALSE
;
1046 path
.str
.a
= lpPathBuf
;
1048 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
1051 msi_free( szwProduct
);
1052 msi_free( szwComponent
);
1057 /******************************************************************
1058 * MsiQueryFeatureStateA [MSI.@]
1060 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
1062 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
1063 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
1065 szwProduct
= strdupAtoW( szProduct
);
1066 if ( szProduct
&& !szwProduct
)
1069 szwFeature
= strdupAtoW( szFeature
);
1070 if ( szFeature
&& !szwFeature
)
1073 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
1076 msi_free( szwProduct
);
1077 msi_free( szwFeature
);
1082 /******************************************************************
1083 * MsiQueryFeatureStateW [MSI.@]
1085 * Checks the state of a feature
1088 * szProduct [I] Product's GUID string
1089 * szFeature [I] Feature's GUID string
1092 * INSTALLSTATE_LOCAL Feature is installed and useable
1093 * INSTALLSTATE_ABSENT Feature is absent
1094 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
1095 * INSTALLSTATE_UNKNOWN An error occured
1096 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
1099 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
1101 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
1103 LPWSTR components
, p
, parent_feature
;
1107 BOOL missing
= FALSE
;
1109 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
1111 if (!szProduct
|| !szFeature
)
1112 return INSTALLSTATE_INVALIDARG
;
1114 if (!squash_guid( szProduct
, squishProduct
))
1115 return INSTALLSTATE_INVALIDARG
;
1117 /* check that it's installed at all */
1118 rc
= MSIREG_OpenUserFeaturesKey(szProduct
, &hkey
, FALSE
);
1119 if (rc
!= ERROR_SUCCESS
)
1120 return INSTALLSTATE_UNKNOWN
;
1122 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
1125 if (!parent_feature
)
1126 return INSTALLSTATE_UNKNOWN
;
1128 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
1129 msi_free(parent_feature
);
1130 if (r
== INSTALLSTATE_ABSENT
)
1133 /* now check if it's complete or advertised */
1134 rc
= MSIREG_OpenFeaturesKey(szProduct
, &hkey
, FALSE
);
1135 if (rc
!= ERROR_SUCCESS
)
1136 return INSTALLSTATE_UNKNOWN
;
1138 components
= msi_reg_get_val_str( hkey
, szFeature
);
1141 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
1145 ERR("components missing %s %s\n",
1146 debugstr_w(szProduct
), debugstr_w(szFeature
));
1147 return INSTALLSTATE_UNKNOWN
;
1150 for( p
= components
; *p
!= 2 ; p
+= 20)
1152 if (!decode_base85_guid( p
, &guid
))
1154 ERR("%s\n", debugstr_w(p
));
1157 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
1158 r
= MsiGetComponentPathW(szProduct
, comp
, NULL
, 0);
1159 TRACE("component %s state %d\n", debugstr_guid(&guid
), r
);
1162 case INSTALLSTATE_NOTUSED
:
1163 case INSTALLSTATE_LOCAL
:
1164 case INSTALLSTATE_SOURCE
:
1171 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
1172 msi_free(components
);
1175 return INSTALLSTATE_ADVERTISED
;
1177 return INSTALLSTATE_LOCAL
;
1180 /******************************************************************
1181 * MsiGetFileVersionA [MSI.@]
1183 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
1184 DWORD
* pcchVersionBuf
, LPSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1186 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
1187 UINT ret
= ERROR_OUTOFMEMORY
;
1191 szwFilePath
= strdupAtoW( szFilePath
);
1196 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1198 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
1199 if( !lpwVersionBuff
)
1203 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1205 lpwLangBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
1210 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
1211 lpwLangBuff
, pcchLangBuf
);
1213 if( lpwVersionBuff
)
1214 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
1215 lpVersionBuf
, *pcchVersionBuf
, NULL
, NULL
);
1217 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
1218 lpLangBuf
, *pcchLangBuf
, NULL
, NULL
);
1221 msi_free(szwFilePath
);
1222 msi_free(lpwVersionBuff
);
1223 msi_free(lpwLangBuff
);
1228 /******************************************************************
1229 * MsiGetFileVersionW [MSI.@]
1231 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
1232 DWORD
* pcchVersionBuf
, LPWSTR lpLangBuf
, DWORD
* pcchLangBuf
)
1234 static WCHAR szVersionResource
[] = {'\\',0};
1235 static const WCHAR szVersionFormat
[] = {
1236 '%','d','.','%','d','.','%','d','.','%','d',0};
1237 static const WCHAR szLangFormat
[] = {'%','d',0};
1240 LPVOID lpVer
= NULL
;
1241 VS_FIXEDFILEINFO
*ffi
;
1245 TRACE("%s %p %ld %p %ld\n", debugstr_w(szFilePath
),
1246 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
1247 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
1249 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
1251 return GetLastError();
1253 lpVer
= msi_alloc(dwVerLen
);
1256 ret
= ERROR_OUTOFMEMORY
;
1260 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
1262 ret
= GetLastError();
1265 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1267 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
1270 wsprintfW(tmp
, szVersionFormat
,
1271 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
1272 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
1273 lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
1274 *pcchVersionBuf
= lstrlenW(lpVersionBuf
);
1279 *pcchVersionBuf
= 0;
1283 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1285 DWORD lang
= GetUserDefaultLangID();
1287 FIXME("Retrieve language from file\n");
1288 wsprintfW(tmp
, szLangFormat
, lang
);
1289 lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
1290 *pcchLangBuf
= lstrlenW(lpLangBuf
);
1298 /***********************************************************************
1299 * MsiGetFeatureUsageW [MSI.@]
1301 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1302 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1304 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
1305 pdwUseCount
, pwDateUsed
);
1306 return ERROR_CALL_NOT_IMPLEMENTED
;
1309 /***********************************************************************
1310 * MsiGetFeatureUsageA [MSI.@]
1312 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
1313 DWORD
* pdwUseCount
, WORD
* pwDateUsed
)
1315 LPWSTR prod
= NULL
, feat
= NULL
;
1316 UINT ret
= ERROR_OUTOFMEMORY
;
1318 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1319 pdwUseCount
, pwDateUsed
);
1321 prod
= strdupAtoW( szProduct
);
1322 if (szProduct
&& !prod
)
1325 feat
= strdupAtoW( szFeature
);
1326 if (szFeature
&& !feat
)
1329 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
1338 /***********************************************************************
1339 * MsiUseFeatureExW [MSI.@]
1341 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1342 DWORD dwInstallMode
, DWORD dwReserved
)
1346 TRACE("%s %s %li %li\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
1347 dwInstallMode
, dwReserved
);
1349 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
1352 return INSTALLSTATE_INVALIDARG
;
1354 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
1356 FIXME("mark product %s feature %s as used\n",
1357 debugstr_w(szProduct
), debugstr_w(szFeature
) );
1363 /***********************************************************************
1364 * MsiUseFeatureExA [MSI.@]
1366 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
1367 DWORD dwInstallMode
, DWORD dwReserved
)
1369 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
1370 LPWSTR prod
= NULL
, feat
= NULL
;
1372 TRACE("%s %s %li %li\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1373 dwInstallMode
, dwReserved
);
1375 prod
= strdupAtoW( szProduct
);
1376 if (szProduct
&& !prod
)
1379 feat
= strdupAtoW( szFeature
);
1380 if (szFeature
&& !feat
)
1383 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
1392 /***********************************************************************
1393 * MsiUseFeatureW [MSI.@]
1395 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
1397 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
1400 /***********************************************************************
1401 * MsiUseFeatureA [MSI.@]
1403 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
1405 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
1408 /***********************************************************************
1409 * MSI_ProvideQualifiedComponentEx [internal]
1411 UINT WINAPI
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
1412 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR szProduct
,
1413 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
1416 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
1417 feature
[MAX_FEATURE_CHARS
+1];
1423 TRACE("%s %s %li %s %li %li %p %p\n", debugstr_w(szComponent
),
1424 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
1425 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1427 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
1428 if (rc
!= ERROR_SUCCESS
)
1429 return ERROR_INDEX_ABSENT
;
1431 info
= msi_reg_get_val_str( hkey
, szQualifier
);
1435 return ERROR_INDEX_ABSENT
;
1437 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
1440 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
1442 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
1445 if (rc
!= INSTALLSTATE_LOCAL
)
1446 return ERROR_FILE_NOT_FOUND
;
1448 return ERROR_SUCCESS
;
1451 /***********************************************************************
1452 * MsiProvideQualifiedComponentExW [MSI.@]
1454 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
1455 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR szProduct
,
1456 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
1461 path
.unicode
= TRUE
;
1462 path
.str
.w
= lpPathBuf
;
1464 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
1465 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
1468 /***********************************************************************
1469 * MsiProvideQualifiedComponentExA [MSI.@]
1471 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
1472 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR szProduct
,
1473 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
1476 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
1477 UINT r
= ERROR_OUTOFMEMORY
;
1480 TRACE("%s %s %lu %s %lu %lu %p %p\n", debugstr_a(szComponent
),
1481 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
1482 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1484 szwComponent
= strdupAtoW( szComponent
);
1485 if (szComponent
&& !szwComponent
)
1488 szwQualifier
= strdupAtoW( szQualifier
);
1489 if (szQualifier
&& !szwQualifier
)
1492 szwProduct
= strdupAtoW( szProduct
);
1493 if (szProduct
&& !szwProduct
)
1496 path
.unicode
= FALSE
;
1497 path
.str
.a
= lpPathBuf
;
1499 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
1500 dwInstallMode
, szwProduct
, Unused1
,
1501 Unused2
, &path
, pcchPathBuf
);
1503 msi_free(szwProduct
);
1504 msi_free(szwComponent
);
1505 msi_free(szwQualifier
);
1510 /***********************************************************************
1511 * MsiProvideQualifiedComponentW [MSI.@]
1513 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
1514 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
1517 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
1518 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1521 /***********************************************************************
1522 * MsiProvideQualifiedComponentA [MSI.@]
1524 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
1525 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
1528 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
1529 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1532 /***********************************************************************
1533 * MSI_GetUserInfo [internal]
1535 USERINFOSTATE WINAPI
MSI_GetUserInfo(LPCWSTR szProduct
,
1536 awstring
*lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1537 awstring
*lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1538 awstring
*lpSerialBuf
, DWORD
* pcchSerialBuf
)
1541 LPWSTR user
, org
, serial
;
1543 USERINFOSTATE state
;
1545 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct
), lpUserNameBuf
,
1546 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
1550 return USERINFOSTATE_INVALIDARG
;
1552 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
1553 if (r
!= ERROR_SUCCESS
)
1554 return USERINFOSTATE_UNKNOWN
;
1556 user
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGOWNERW
);
1557 org
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGCOMPANYW
);
1558 serial
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_PRODUCTIDW
);
1562 state
= USERINFOSTATE_PRESENT
;
1564 r
= msi_strcpy_to_awstring( user
, lpUserNameBuf
, pcchUserNameBuf
);
1565 if (r
== ERROR_MORE_DATA
)
1566 state
= USERINFOSTATE_MOREDATA
;
1567 r
= msi_strcpy_to_awstring( org
, lpOrgNameBuf
, pcchOrgNameBuf
);
1568 if (r
== ERROR_MORE_DATA
)
1569 state
= USERINFOSTATE_MOREDATA
;
1570 r
= msi_strcpy_to_awstring( serial
, lpSerialBuf
, pcchSerialBuf
);
1571 if (r
== ERROR_MORE_DATA
)
1572 state
= USERINFOSTATE_MOREDATA
;
1581 /***********************************************************************
1582 * MsiGetUserInfoW [MSI.@]
1584 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
1585 LPWSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1586 LPWSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1587 LPWSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1589 awstring user
, org
, serial
;
1591 user
.unicode
= TRUE
;
1592 user
.str
.w
= lpUserNameBuf
;
1594 org
.str
.w
= lpOrgNameBuf
;
1595 serial
.unicode
= TRUE
;
1596 serial
.str
.w
= lpSerialBuf
;
1598 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
1599 &org
, pcchOrgNameBuf
,
1600 &serial
, pcchSerialBuf
);
1603 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
1604 LPSTR lpUserNameBuf
, DWORD
* pcchUserNameBuf
,
1605 LPSTR lpOrgNameBuf
, DWORD
* pcchOrgNameBuf
,
1606 LPSTR lpSerialBuf
, DWORD
* pcchSerialBuf
)
1608 awstring user
, org
, serial
;
1612 prod
= strdupAtoW( szProduct
);
1613 if (szProduct
&& !prod
)
1614 return ERROR_OUTOFMEMORY
;
1616 user
.unicode
= FALSE
;
1617 user
.str
.a
= lpUserNameBuf
;
1618 org
.unicode
= FALSE
;
1619 org
.str
.a
= lpOrgNameBuf
;
1620 serial
.unicode
= FALSE
;
1621 serial
.str
.a
= lpSerialBuf
;
1623 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
1624 &org
, pcchOrgNameBuf
,
1625 &serial
, pcchSerialBuf
);
1632 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
1636 MSIPACKAGE
*package
;
1637 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1639 TRACE("(%s)\n",debugstr_w(szProduct
));
1641 rc
= MsiOpenProductW(szProduct
,&handle
);
1642 if (rc
!= ERROR_SUCCESS
)
1643 return ERROR_INVALID_PARAMETER
;
1645 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1646 rc
= ACTION_PerformUIAction(package
, szFirstRun
);
1647 msiobj_release( &package
->hdr
);
1649 MsiCloseHandle(handle
);
1654 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
1658 MSIPACKAGE
*package
;
1659 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
1661 TRACE("(%s)\n",debugstr_a(szProduct
));
1663 rc
= MsiOpenProductA(szProduct
,&handle
);
1664 if (rc
!= ERROR_SUCCESS
)
1665 return ERROR_INVALID_PARAMETER
;
1667 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
1668 rc
= ACTION_PerformUIAction(package
, szFirstRun
);
1669 msiobj_release( &package
->hdr
);
1671 MsiCloseHandle(handle
);
1676 /***********************************************************************
1677 * MsiConfigureFeatureA [MSI.@]
1679 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
1681 LPWSTR prod
, feat
= NULL
;
1682 UINT r
= ERROR_OUTOFMEMORY
;
1684 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
1686 prod
= strdupAtoW( szProduct
);
1687 if (szProduct
&& !prod
)
1690 feat
= strdupAtoW( szFeature
);
1691 if (szFeature
&& !feat
)
1694 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
1703 /***********************************************************************
1704 * MsiConfigureFeatureW [MSI.@]
1706 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
1708 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
1709 MSIPACKAGE
*package
= NULL
;
1711 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
1714 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
1716 if (!szProduct
|| !szFeature
)
1717 return ERROR_INVALID_PARAMETER
;
1719 switch (eInstallState
)
1721 case INSTALLSTATE_DEFAULT
:
1722 /* FIXME: how do we figure out the default location? */
1723 eInstallState
= INSTALLSTATE_LOCAL
;
1725 case INSTALLSTATE_LOCAL
:
1726 case INSTALLSTATE_SOURCE
:
1727 case INSTALLSTATE_ABSENT
:
1728 case INSTALLSTATE_ADVERTISED
:
1731 return ERROR_INVALID_PARAMETER
;
1734 r
= MSI_OpenProductW( szProduct
, &package
);
1735 if (r
!= ERROR_SUCCESS
)
1738 sz
= sizeof(sourcepath
);
1739 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1740 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
1742 sz
= sizeof(filename
);
1743 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1744 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
1746 lstrcatW( sourcepath
, filename
);
1748 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
1750 r
= ACTION_PerformUIAction( package
, szCostInit
);
1751 if (r
!= ERROR_SUCCESS
)
1754 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
1755 if (r
!= ERROR_SUCCESS
)
1758 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
1761 msiobj_release( &package
->hdr
);
1766 /***********************************************************************
1767 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
1769 * Notes: undocumented
1771 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
1773 WCHAR path
[MAX_PATH
];
1775 TRACE("%ld\n", dwReserved
);
1779 FIXME("dwReserved=%ld\n", dwReserved
);
1780 return ERROR_INVALID_PARAMETER
;
1783 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
1784 return ERROR_FUNCTION_FAILED
;
1786 lstrcatW(path
, installerW
);
1788 if (!CreateDirectoryW(path
, NULL
))
1789 return ERROR_FUNCTION_FAILED
;
1791 return ERROR_SUCCESS
;
1794 /***********************************************************************
1795 * MsiGetShortcutTargetA [MSI.@]
1797 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
1798 LPSTR szProductCode
, LPSTR szFeatureId
,
1799 LPSTR szComponentCode
)
1802 const int len
= MAX_FEATURE_CHARS
+1;
1803 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
1806 target
= strdupAtoW( szShortcutTarget
);
1807 if (szShortcutTarget
&& !target
)
1808 return ERROR_OUTOFMEMORY
;
1812 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
1814 if (r
== ERROR_SUCCESS
)
1816 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
1817 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
1818 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
1823 /***********************************************************************
1824 * MsiGetShortcutTargetW [MSI.@]
1826 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
1827 LPWSTR szProductCode
, LPWSTR szFeatureId
,
1828 LPWSTR szComponentCode
)
1830 IShellLinkDataList
*dl
= NULL
;
1831 IPersistFile
*pf
= NULL
;
1832 LPEXP_DARWIN_LINK darwin
= NULL
;
1835 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
1836 szProductCode
, szFeatureId
, szComponentCode
);
1838 init
= CoInitialize(NULL
);
1840 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
1841 &IID_IPersistFile
, (LPVOID
*) &pf
);
1842 if( SUCCEEDED( r
) )
1844 r
= IPersistFile_Load( pf
, szShortcutTarget
,
1845 STGM_READ
| STGM_SHARE_DENY_WRITE
);
1846 if( SUCCEEDED( r
) )
1848 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
1850 if( SUCCEEDED( r
) )
1852 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
1854 IShellLinkDataList_Release( dl
);
1857 IPersistFile_Release( pf
);
1860 if (SUCCEEDED(init
))
1863 TRACE("darwin = %p\n", darwin
);
1870 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
1871 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
1872 LocalFree( darwin
);
1876 return ERROR_FUNCTION_FAILED
;
1879 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1880 DWORD dwReinstallMode
)
1882 MSIPACKAGE
* package
= NULL
;
1884 WCHAR sourcepath
[MAX_PATH
];
1885 WCHAR filename
[MAX_PATH
];
1886 static const WCHAR szLogVerbose
[] = {
1887 ' ','L','O','G','V','E','R','B','O','S','E',0 };
1888 static const WCHAR szInstalled
[] = { 'I','n','s','t','a','l','l','e','d',0};
1889 static const WCHAR szReinstall
[] = {'R','E','I','N','S','T','A','L','L',0};
1890 static const WCHAR szReinstallMode
[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
1891 static const WCHAR szOne
[] = {'1',0};
1892 WCHAR reinstallmode
[11];
1896 FIXME("%s %s %li\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
1899 ptr
= reinstallmode
;
1901 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
1903 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
1905 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
1907 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
1909 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
1911 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
1913 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
1915 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
1917 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
1919 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
1923 sz
= sizeof(sourcepath
);
1924 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1925 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
1927 sz
= sizeof(filename
);
1928 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1929 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
1931 lstrcatW( sourcepath
, filename
);
1933 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
1934 r
= MSI_OpenPackageW( sourcepath
, &package
);
1936 r
= MSI_OpenProductW( szProduct
, &package
);
1938 if (r
!= ERROR_SUCCESS
)
1941 MSI_SetPropertyW( package
, szReinstallMode
, reinstallmode
);
1942 MSI_SetPropertyW( package
, szInstalled
, szOne
);
1943 MSI_SetPropertyW( package
, szLogVerbose
, szOne
);
1944 MSI_SetPropertyW( package
, szReinstall
, szFeature
);
1946 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
1948 msiobj_release( &package
->hdr
);
1953 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
1954 DWORD dwReinstallMode
)
1960 TRACE("%s %s %li\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1963 wszProduct
= strdupAtoW(szProduct
);
1964 wszFeature
= strdupAtoW(szFeature
);
1966 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
1968 msi_free(wszProduct
);
1969 msi_free(wszFeature
);
1976 unsigned int buf
[4];
1977 unsigned char in
[64];
1978 unsigned char digest
[16];
1981 extern VOID WINAPI
MD5Init( MD5_CTX
*);
1982 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
1983 extern VOID WINAPI
MD5Final( MD5_CTX
*);
1985 /***********************************************************************
1986 * MsiGetFileHashW [MSI.@]
1988 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
1989 PMSIFILEHASHINFO pHash
)
1991 HANDLE handle
, mapping
;
1994 UINT r
= ERROR_FUNCTION_FAILED
;
1996 TRACE("%s %08lx %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
1999 return ERROR_INVALID_PARAMETER
;
2001 return ERROR_INVALID_PARAMETER
;
2002 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
2003 return ERROR_INVALID_PARAMETER
;
2005 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
2006 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
2007 if (handle
== INVALID_HANDLE_VALUE
)
2008 return ERROR_FILE_NOT_FOUND
;
2010 length
= GetFileSize( handle
, NULL
);
2012 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
2015 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
2021 MD5Update( &ctx
, p
, length
);
2023 UnmapViewOfFile( p
);
2025 memcpy( pHash
->dwData
, &ctx
.digest
, sizeof pHash
->dwData
);
2028 CloseHandle( mapping
);
2030 CloseHandle( handle
);
2035 /***********************************************************************
2036 * MsiGetFileHashA [MSI.@]
2038 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
2039 PMSIFILEHASHINFO pHash
)
2044 TRACE("%s %08lx %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
2046 file
= strdupAtoW( szFilePath
);
2047 if (szFilePath
&& !file
)
2048 return ERROR_OUTOFMEMORY
;
2050 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
2055 /***********************************************************************
2056 * MsiAdvertiseScriptW [MSI.@]
2058 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
2059 PHKEY phRegData
, BOOL fRemoveItems
)
2061 FIXME("%s %08lx %p %d\n",
2062 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2063 return ERROR_CALL_NOT_IMPLEMENTED
;
2066 /***********************************************************************
2067 * MsiAdvertiseScriptA [MSI.@]
2069 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
2070 PHKEY phRegData
, BOOL fRemoveItems
)
2072 FIXME("%s %08lx %p %d\n",
2073 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2074 return ERROR_CALL_NOT_IMPLEMENTED
;