2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002,2003,2004,2005 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
31 #include "wine/debug.h"
42 #include "wine/unicode.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
46 static const WCHAR installerW
[] = {'\\','I','n','s','t','a','l','l','e','r',0};
48 UINT WINAPI
MsiOpenProductA(LPCSTR szProduct
, MSIHANDLE
*phProduct
)
51 LPWSTR szwProd
= NULL
;
53 TRACE("%s %p\n",debugstr_a(szProduct
), phProduct
);
57 szwProd
= strdupAtoW( szProduct
);
59 return ERROR_OUTOFMEMORY
;
62 r
= MsiOpenProductW( szwProd
, phProduct
);
69 static UINT
MSI_OpenProductW( LPCWSTR szProduct
, MSIPACKAGE
**ppackage
)
73 HKEY hKeyProduct
= NULL
;
76 TRACE("%s %p\n", debugstr_w(szProduct
), ppackage
);
78 r
= MSIREG_OpenUninstallKey(szProduct
,&hKeyProduct
,FALSE
);
79 if( r
!= ERROR_SUCCESS
)
81 r
= ERROR_UNKNOWN_PRODUCT
;
85 /* find the size of the path */
87 r
= RegQueryValueExW( hKeyProduct
, INSTALLPROPERTY_LOCALPACKAGEW
,
88 NULL
, &type
, NULL
, &count
);
89 if( r
!= ERROR_SUCCESS
)
91 r
= ERROR_UNKNOWN_PRODUCT
;
95 /* now alloc and fetch the path of the database to open */
96 path
= msi_alloc( count
);
100 r
= RegQueryValueExW( hKeyProduct
, INSTALLPROPERTY_LOCALPACKAGEW
,
101 NULL
, &type
, (LPBYTE
) path
, &count
);
102 if( r
!= ERROR_SUCCESS
)
104 r
= ERROR_UNKNOWN_PRODUCT
;
108 r
= MSI_OpenPackageW( path
, ppackage
);
113 RegCloseKey( hKeyProduct
);
118 UINT WINAPI
MsiOpenProductW( LPCWSTR szProduct
, MSIHANDLE
*phProduct
)
120 MSIPACKAGE
*package
= NULL
;
123 r
= MSI_OpenProductW( szProduct
, &package
);
124 if( r
== ERROR_SUCCESS
)
126 *phProduct
= alloc_msihandle( &package
->hdr
);
128 r
= ERROR_NOT_ENOUGH_MEMORY
;
129 msiobj_release( &package
->hdr
);
134 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
135 LPCSTR szTransforms
, LANGID lgidLanguage
)
137 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
138 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
139 return ERROR_CALL_NOT_IMPLEMENTED
;
142 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
143 LPCWSTR szTransforms
, LANGID lgidLanguage
)
145 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
146 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
147 return ERROR_CALL_NOT_IMPLEMENTED
;
150 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
151 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
153 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath
),
154 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
155 lgidLanguage
, dwPlatform
, dwOptions
);
156 return ERROR_CALL_NOT_IMPLEMENTED
;
159 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
160 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
162 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath
),
163 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
164 lgidLanguage
, dwPlatform
, dwOptions
);
165 return ERROR_CALL_NOT_IMPLEMENTED
;
168 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
170 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
171 UINT r
= ERROR_OUTOFMEMORY
;
173 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
177 szwPath
= strdupAtoW( szPackagePath
);
184 szwCommand
= strdupAtoW( szCommandLine
);
189 r
= MsiInstallProductW( szwPath
, szwCommand
);
193 msi_free( szwCommand
);
198 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
200 MSIPACKAGE
*package
= NULL
;
203 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
205 r
= MSI_OpenPackageW( szPackagePath
, &package
);
206 if (r
== ERROR_SUCCESS
)
208 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
209 msiobj_release( &package
->hdr
);
215 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
217 FIXME("%s %08x\n", debugstr_a(szProduct
), dwReinstallMode
);
218 return ERROR_CALL_NOT_IMPLEMENTED
;
221 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
223 FIXME("%s %08x\n", debugstr_w(szProduct
), dwReinstallMode
);
224 return ERROR_CALL_NOT_IMPLEMENTED
;
227 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
228 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
230 LPWSTR patch_package
= NULL
;
231 LPWSTR install_package
= NULL
;
232 LPWSTR command_line
= NULL
;
233 UINT r
= ERROR_OUTOFMEMORY
;
235 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
236 eInstallType
, debugstr_a(szCommandLine
));
238 if (szPatchPackage
&& !(patch_package
= strdupAtoW(szPatchPackage
)))
241 if (szInstallPackage
&& !(install_package
= strdupAtoW(szInstallPackage
)))
244 if (szCommandLine
&& !(command_line
= strdupAtoW(szCommandLine
)))
247 r
= MsiApplyPatchW(patch_package
, install_package
, eInstallType
, command_line
);
250 msi_free(patch_package
);
251 msi_free(install_package
);
252 msi_free(command_line
);
257 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
258 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
260 MSIHANDLE patch
, info
;
263 LPCWSTR cmd_ptr
= szCommandLine
;
265 LPWSTR cmd
= NULL
, codes
= NULL
;
267 static const WCHAR space
[] = {' ',0};
268 static const WCHAR patcheq
[] = {'P','A','T','C','H','=',0};
269 static WCHAR empty
[] = {0};
271 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
272 eInstallType
, debugstr_w(szCommandLine
));
274 if (szInstallPackage
|| eInstallType
== INSTALLTYPE_NETWORK_IMAGE
||
275 eInstallType
== INSTALLTYPE_SINGLE_INSTANCE
)
277 FIXME("Only reading target products from patch\n");
278 return ERROR_CALL_NOT_IMPLEMENTED
;
281 r
= MsiOpenDatabaseW(szPatchPackage
, MSIDBOPEN_READONLY
, &patch
);
282 if (r
!= ERROR_SUCCESS
)
285 r
= MsiGetSummaryInformationW(patch
, NULL
, 0, &info
);
286 if (r
!= ERROR_SUCCESS
)
289 r
= MsiSummaryInfoGetPropertyW(info
, PID_TEMPLATE
, &type
, NULL
, NULL
, empty
, &size
);
290 if (r
!= ERROR_MORE_DATA
|| !size
|| type
!= VT_LPSTR
)
292 ERR("Failed to read product codes from patch\n");
296 codes
= msi_alloc(++size
* sizeof(WCHAR
));
299 r
= ERROR_OUTOFMEMORY
;
303 r
= MsiSummaryInfoGetPropertyW(info
, PID_TEMPLATE
, &type
, NULL
, NULL
, codes
, &size
);
304 if (r
!= ERROR_SUCCESS
)
310 size
= lstrlenW(cmd_ptr
) + lstrlenW(patcheq
) + lstrlenW(szPatchPackage
) + 1;
311 cmd
= msi_alloc(size
* sizeof(WCHAR
));
314 r
= ERROR_OUTOFMEMORY
;
318 lstrcpyW(cmd
, cmd_ptr
);
319 if (szCommandLine
) lstrcatW(cmd
, space
);
320 lstrcatW(cmd
, patcheq
);
321 lstrcatW(cmd
, szPatchPackage
);
324 while ((end
= strchrW(beg
, '}')))
328 r
= MsiConfigureProductExW(beg
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
329 if (r
!= ERROR_SUCCESS
)
339 MsiCloseHandle(info
);
340 MsiCloseHandle(patch
);
345 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
346 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
348 MSIPACKAGE
* package
= NULL
;
351 WCHAR sourcepath
[MAX_PATH
];
352 WCHAR filename
[MAX_PATH
];
353 static const WCHAR szInstalled
[] = {
354 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
357 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
358 debugstr_w(szCommandLine
));
360 if (eInstallState
!= INSTALLSTATE_LOCAL
&&
361 eInstallState
!= INSTALLSTATE_DEFAULT
)
363 FIXME("Not implemented for anything other than local installs\n");
364 return ERROR_CALL_NOT_IMPLEMENTED
;
367 sz
= sizeof(sourcepath
);
368 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
369 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
,
372 sz
= sizeof(filename
);
373 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
374 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
376 lstrcatW(sourcepath
,filename
);
379 * ok 1, we need to find the msi file for this product.
380 * 2, find the source dir for the files
381 * 3, do the configure/install.
382 * 4, cleanupany runonce entry.
385 r
= MSI_OpenProductW( szProduct
, &package
);
386 if (r
!= ERROR_SUCCESS
)
389 sz
= lstrlenW(szInstalled
) + 1;
392 sz
+= lstrlenW(szCommandLine
);
394 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
397 r
= ERROR_OUTOFMEMORY
;
403 lstrcpyW(commandline
,szCommandLine
);
405 if (MsiQueryProductStateW(szProduct
) != INSTALLSTATE_UNKNOWN
)
406 lstrcatW(commandline
,szInstalled
);
408 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
410 msi_free(commandline
);
413 msiobj_release( &package
->hdr
);
418 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
419 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
421 LPWSTR szwProduct
= NULL
;
422 LPWSTR szwCommandLine
= NULL
;
423 UINT r
= ERROR_OUTOFMEMORY
;
427 szwProduct
= strdupAtoW( szProduct
);
434 szwCommandLine
= strdupAtoW( szCommandLine
);
439 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
442 msi_free( szwProduct
);
443 msi_free( szwCommandLine
);
448 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
449 INSTALLSTATE eInstallState
)
451 LPWSTR szwProduct
= NULL
;
454 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
458 szwProduct
= strdupAtoW( szProduct
);
460 return ERROR_OUTOFMEMORY
;
463 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
464 msi_free( szwProduct
);
469 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
470 INSTALLSTATE eInstallState
)
472 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
475 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
477 LPWSTR szwComponent
= NULL
;
479 WCHAR szwBuffer
[GUID_SIZE
];
481 TRACE("%s %s\n",debugstr_a(szComponent
), debugstr_a(szBuffer
));
485 szwComponent
= strdupAtoW( szComponent
);
487 return ERROR_OUTOFMEMORY
;
491 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
494 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
496 msi_free( szwComponent
);
501 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
504 HKEY compkey
, prodkey
;
505 WCHAR squished_comp
[GUID_SIZE
];
506 WCHAR squished_prod
[GUID_SIZE
];
507 DWORD sz
= GUID_SIZE
;
509 TRACE("%s %p\n", debugstr_w(szComponent
), szBuffer
);
511 if (!szComponent
|| !*szComponent
)
512 return ERROR_INVALID_PARAMETER
;
514 if (!squash_guid(szComponent
, squished_comp
))
515 return ERROR_INVALID_PARAMETER
;
517 if (MSIREG_OpenUserDataComponentKey(szComponent
, &compkey
, FALSE
) != ERROR_SUCCESS
&&
518 MSIREG_OpenLocalSystemComponentKey(szComponent
, &compkey
, FALSE
) != ERROR_SUCCESS
)
520 return ERROR_UNKNOWN_COMPONENT
;
523 rc
= RegEnumValueW(compkey
, 0, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
524 if (rc
!= ERROR_SUCCESS
)
526 RegCloseKey(compkey
);
527 return ERROR_UNKNOWN_COMPONENT
;
530 /* check simple case, only one product */
531 rc
= RegEnumValueW(compkey
, 1, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
532 if (rc
== ERROR_NO_MORE_ITEMS
)
539 while ((rc
= RegEnumValueW(compkey
, index
, squished_prod
, &sz
,
540 NULL
, NULL
, NULL
, NULL
)) != ERROR_NO_MORE_ITEMS
)
544 unsquash_guid(squished_prod
, szBuffer
);
546 if (MSIREG_OpenLocalManagedProductKey(szBuffer
, &prodkey
, FALSE
) == ERROR_SUCCESS
||
547 MSIREG_OpenUserProductsKey(szBuffer
, &prodkey
, FALSE
) == ERROR_SUCCESS
||
548 MSIREG_OpenLocalClassesProductKey(szBuffer
, &prodkey
, FALSE
) == ERROR_SUCCESS
)
550 RegCloseKey(prodkey
);
556 rc
= ERROR_INSTALL_FAILURE
;
559 RegCloseKey(compkey
);
560 unsquash_guid(squished_prod
, szBuffer
);
564 static UINT WINAPI
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
565 awstring
*szValue
, LPDWORD pcchValueBuf
)
571 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
572 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
575 * FIXME: Values seem scattered/duplicated in the registry. Is there a system?
578 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szProduct
[0] || !szAttribute
)
579 return ERROR_INVALID_PARAMETER
;
581 /* check for special properties */
582 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
585 WCHAR packagecode
[35];
587 r
= MSIREG_OpenUserProductsKey(szProduct
, &hkey
, FALSE
);
588 if (r
!= ERROR_SUCCESS
)
589 return ERROR_UNKNOWN_PRODUCT
;
591 regval
= msi_reg_get_val_str( hkey
, szAttribute
);
594 if (unsquash_guid(regval
, packagecode
))
595 val
= strdupW(packagecode
);
601 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
603 static const WCHAR one
[] = { '1',0 };
605 * FIXME: should be in the Product key (user or system?)
606 * but isn't written yet...
608 val
= strdupW( one
);
610 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
611 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONW
))
613 static const WCHAR fmt
[] = { '%','u',0 };
617 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
618 if (r
!= ERROR_SUCCESS
)
619 return ERROR_UNKNOWN_PRODUCT
;
621 if (msi_reg_get_val_dword( hkey
, szAttribute
, ®val
))
623 sprintfW(szVal
, fmt
, regval
);
624 val
= strdupW( szVal
);
629 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
))
631 r
= MSIREG_OpenUserProductsKey(szProduct
, &hkey
, FALSE
);
632 if (r
!= ERROR_SUCCESS
)
633 return ERROR_UNKNOWN_PRODUCT
;
635 val
= msi_reg_get_val_str( hkey
, szAttribute
);
639 else if (!szAttribute
[0])
641 return ERROR_UNKNOWN_PROPERTY
;
645 static const WCHAR szDisplayVersion
[] = {
646 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0 };
648 FIXME("%s\n", debugstr_w(szAttribute
));
649 /* FIXME: some attribute values not tested... */
651 if (!lstrcmpW( szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
652 szAttribute
= szDisplayVersion
;
654 r
= MSIREG_OpenUninstallKey( szProduct
, &hkey
, FALSE
);
655 if (r
!= ERROR_SUCCESS
)
656 return ERROR_UNKNOWN_PRODUCT
;
658 val
= msi_reg_get_val_str( hkey
, szAttribute
);
663 TRACE("returning %s\n", debugstr_w(val
));
666 return ERROR_UNKNOWN_PROPERTY
;
668 r
= msi_strcpy_to_awstring( val
, szValue
, pcchValueBuf
);
675 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
676 LPSTR szBuffer
, LPDWORD pcchValueBuf
)
678 LPWSTR szwProduct
, szwAttribute
= NULL
;
679 UINT r
= ERROR_OUTOFMEMORY
;
682 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
683 szBuffer
, pcchValueBuf
);
685 szwProduct
= strdupAtoW( szProduct
);
686 if( szProduct
&& !szwProduct
)
689 szwAttribute
= strdupAtoW( szAttribute
);
690 if( szAttribute
&& !szwAttribute
)
693 buffer
.unicode
= FALSE
;
694 buffer
.str
.a
= szBuffer
;
696 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
697 &buffer
, pcchValueBuf
);
700 msi_free( szwProduct
);
701 msi_free( szwAttribute
);
706 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
707 LPWSTR szBuffer
, LPDWORD pcchValueBuf
)
711 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
712 szBuffer
, pcchValueBuf
);
714 buffer
.unicode
= TRUE
;
715 buffer
.str
.w
= szBuffer
;
717 return MSI_GetProductInfo( szProduct
, szAttribute
,
718 &buffer
, pcchValueBuf
);
721 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
723 LPWSTR szwLogFile
= NULL
;
726 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
730 szwLogFile
= strdupAtoW( szLogFile
);
732 return ERROR_OUTOFMEMORY
;
734 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
735 msi_free( szwLogFile
);
739 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
741 HANDLE file
= INVALID_HANDLE_VALUE
;
743 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
747 lstrcpyW(gszLogFile
,szLogFile
);
748 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
749 DeleteFileW(szLogFile
);
750 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, 0, NULL
, OPEN_ALWAYS
,
751 FILE_ATTRIBUTE_NORMAL
, NULL
);
752 if (file
!= INVALID_HANDLE_VALUE
)
755 ERR("Unable to enable log %s\n",debugstr_w(szLogFile
));
758 gszLogFile
[0] = '\0';
760 return ERROR_SUCCESS
;
763 UINT WINAPI
MsiEnumComponentCostsW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
764 DWORD dwIndex
, INSTALLSTATE iState
,
765 LPWSTR lpDriveBuf
, DWORD
*pcchDriveBuf
,
766 int *piCost
, int *pTempCost
)
768 FIXME("(%ld, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall
,
769 debugstr_w(szComponent
), dwIndex
, iState
, lpDriveBuf
,
770 pcchDriveBuf
, piCost
, pTempCost
);
772 return ERROR_NO_MORE_ITEMS
;
775 UINT WINAPI
MsiQueryComponentStateA(LPCSTR szProductCode
,
776 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
777 LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
779 LPWSTR prodcode
= NULL
, usersid
= NULL
, comp
= NULL
;
782 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode
),
783 debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
785 if (szProductCode
&& !(prodcode
= strdupAtoW(szProductCode
)))
786 return ERROR_OUTOFMEMORY
;
788 if (szUserSid
&& !(usersid
= strdupAtoW(szUserSid
)))
789 return ERROR_OUTOFMEMORY
;
791 if (szComponent
&& !(comp
= strdupAtoW(szComponent
)))
792 return ERROR_OUTOFMEMORY
;
794 r
= MsiQueryComponentStateW(prodcode
, usersid
, dwContext
, comp
, pdwState
);
803 static BOOL
msi_comp_find_prod_key(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
808 if (context
== MSIINSTALLCONTEXT_MACHINE
)
809 r
= MSIREG_OpenLocalClassesProductKey(prodcode
, &hkey
, FALSE
);
810 else if (context
== MSIINSTALLCONTEXT_USERUNMANAGED
)
811 r
= MSIREG_OpenUserProductsKey(prodcode
, &hkey
, FALSE
);
813 r
= MSIREG_OpenLocalManagedProductKey(prodcode
, &hkey
, FALSE
);
816 return (r
== ERROR_SUCCESS
);
819 static BOOL
msi_comp_find_package(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
827 static const WCHAR local_package
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
828 static const WCHAR managed_local_package
[] = {
829 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
832 if (context
== MSIINSTALLCONTEXT_MACHINE
)
833 r
= MSIREG_OpenLocalSystemProductKey(prodcode
, &hkey
, FALSE
);
835 r
= MSIREG_OpenInstallPropertiesKey(prodcode
, &hkey
, FALSE
);
837 if (r
!= ERROR_SUCCESS
)
840 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
841 package
= managed_local_package
;
843 package
= local_package
;
846 res
= RegQueryValueExW(hkey
, package
, NULL
, NULL
, NULL
, &sz
);
849 return (res
== ERROR_SUCCESS
);
852 static BOOL
msi_comp_find_prodcode(LPCWSTR prodcode
, LPWSTR squished_pc
,
853 MSIINSTALLCONTEXT context
,
854 LPCWSTR comp
, DWORD
*sz
)
860 if (context
== MSIINSTALLCONTEXT_MACHINE
)
861 r
= MSIREG_OpenLocalSystemComponentKey(comp
, &hkey
, FALSE
);
863 r
= MSIREG_OpenUserDataComponentKey(comp
, &hkey
, FALSE
);
865 if (r
!= ERROR_SUCCESS
)
869 res
= RegQueryValueExW(hkey
, squished_pc
, NULL
, NULL
, NULL
, sz
);
870 if (res
!= ERROR_SUCCESS
)
877 UINT WINAPI
MsiQueryComponentStateW(LPCWSTR szProductCode
,
878 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
879 LPCWSTR szComponent
, INSTALLSTATE
*pdwState
)
881 WCHAR squished_pc
[GUID_SIZE
];
885 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode
),
886 debugstr_w(szUserSid
), dwContext
, debugstr_w(szComponent
), pdwState
);
889 return ERROR_INVALID_PARAMETER
;
891 if (!szProductCode
|| !*szProductCode
|| lstrlenW(szProductCode
) != GUID_SIZE
- 1)
892 return ERROR_INVALID_PARAMETER
;
894 if (!squash_guid(szProductCode
, squished_pc
))
895 return ERROR_INVALID_PARAMETER
;
897 found
= msi_comp_find_prod_key(szProductCode
, dwContext
);
899 if (!msi_comp_find_package(szProductCode
, dwContext
))
903 *pdwState
= INSTALLSTATE_UNKNOWN
;
904 return ERROR_UNKNOWN_COMPONENT
;
907 return ERROR_UNKNOWN_PRODUCT
;
910 *pdwState
= INSTALLSTATE_UNKNOWN
;
912 if (!msi_comp_find_prodcode(szProductCode
, squished_pc
, dwContext
, szComponent
, &sz
))
913 return ERROR_UNKNOWN_COMPONENT
;
916 *pdwState
= INSTALLSTATE_NOTUSED
;
918 *pdwState
= INSTALLSTATE_LOCAL
;
920 return ERROR_SUCCESS
;
923 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
925 LPWSTR szwProduct
= NULL
;
930 szwProduct
= strdupAtoW( szProduct
);
932 return ERROR_OUTOFMEMORY
;
934 r
= MsiQueryProductStateW( szwProduct
);
935 msi_free( szwProduct
);
939 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
942 INSTALLSTATE state
= INSTALLSTATE_UNKNOWN
;
943 HKEY hkey
= 0, props
= 0;
945 BOOL userkey_exists
= FALSE
;
947 static const int GUID_LEN
= 38;
948 static const WCHAR szInstallProperties
[] = {
949 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0
951 static const WCHAR szWindowsInstaller
[] = {
952 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0
955 TRACE("%s\n", debugstr_w(szProduct
));
957 if (!szProduct
|| !*szProduct
|| lstrlenW(szProduct
) != GUID_LEN
)
958 return INSTALLSTATE_INVALIDARG
;
960 rc
= MSIREG_OpenUserProductsKey(szProduct
,&hkey
,FALSE
);
961 if (rc
== ERROR_SUCCESS
)
963 userkey_exists
= TRUE
;
964 state
= INSTALLSTATE_ADVERTISED
;
968 rc
= MSIREG_OpenUserDataProductKey(szProduct
,&hkey
,FALSE
);
969 if (rc
!= ERROR_SUCCESS
)
972 rc
= RegOpenKeyW(hkey
, szInstallProperties
, &props
);
973 if (rc
!= ERROR_SUCCESS
)
977 rc
= RegQueryValueExW(props
,szWindowsInstaller
,NULL
,NULL
,(LPVOID
)&state
, &sz
);
978 if (rc
!= ERROR_SUCCESS
)
982 state
= INSTALLSTATE_DEFAULT
;
984 state
= INSTALLSTATE_UNKNOWN
;
986 if (state
== INSTALLSTATE_DEFAULT
&& !userkey_exists
)
987 state
= INSTALLSTATE_ABSENT
;
995 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
997 INSTALLUILEVEL old
= gUILevel
;
998 HWND oldwnd
= gUIhwnd
;
1000 TRACE("%08x %p\n", dwUILevel
, phWnd
);
1002 gUILevel
= dwUILevel
;
1011 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
1012 DWORD dwMessageFilter
, LPVOID pvContext
)
1014 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
1016 TRACE("%p %x %p\n",puiHandler
, dwMessageFilter
,pvContext
);
1017 gUIHandlerA
= puiHandler
;
1018 gUIFilter
= dwMessageFilter
;
1019 gUIContext
= pvContext
;
1024 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
1025 DWORD dwMessageFilter
, LPVOID pvContext
)
1027 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
1029 TRACE("%p %x %p\n",puiHandler
,dwMessageFilter
,pvContext
);
1030 gUIHandlerW
= puiHandler
;
1031 gUIFilter
= dwMessageFilter
;
1032 gUIContext
= pvContext
;
1037 /******************************************************************
1038 * MsiLoadStringW [MSI.@]
1040 * Loads a string from MSI's string resources.
1044 * handle [I] only -1 is handled currently
1045 * id [I] id of the string to be loaded
1046 * lpBuffer [O] buffer for the string to be written to
1047 * nBufferMax [I] maximum size of the buffer in characters
1048 * lang [I] the preferred language for the string
1052 * If successful, this function returns the language id of the string loaded
1053 * If the function fails, the function returns zero.
1057 * The type of the first parameter is unknown. LoadString's prototype
1058 * suggests that it might be a module handle. I have made it an MSI handle
1059 * for starters, as -1 is an invalid MSI handle, but not an invalid module
1060 * handle. Maybe strings can be stored in an MSI database somehow.
1062 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
1063 int nBufferMax
, LANGID lang
)
1070 TRACE("%ld %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
1073 FIXME("don't know how to deal with handle = %08lx\n", handle
);
1076 lang
= GetUserDefaultLangID();
1078 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
1082 hResData
= LoadResource( msi_hInstance
, hres
);
1085 p
= LockResource( hResData
);
1089 for (i
= 0; i
< (id
&0xf); i
++)
1093 if( nBufferMax
<= len
)
1096 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
1097 lpBuffer
[ len
] = 0;
1099 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
1104 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
1105 int nBufferMax
, LANGID lang
)
1111 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
1112 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
1115 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
1116 if( len
<= nBufferMax
)
1117 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
1118 lpBuffer
, nBufferMax
, NULL
, NULL
);
1126 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
1129 char szProduct
[GUID_SIZE
];
1131 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
1133 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
1134 return INSTALLSTATE_UNKNOWN
;
1136 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
1139 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
1142 WCHAR szProduct
[GUID_SIZE
];
1144 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
1146 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
1147 return INSTALLSTATE_UNKNOWN
;
1149 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
1152 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
1153 WORD wLanguageId
, DWORD f
)
1155 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
1156 uType
, wLanguageId
, f
);
1157 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
1160 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
1161 WORD wLanguageId
, DWORD f
)
1163 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
1164 uType
, wLanguageId
, f
);
1165 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
1168 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
1169 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
1170 LPDWORD pcchPathBuf
)
1172 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
1173 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
1175 return ERROR_CALL_NOT_IMPLEMENTED
;
1178 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
1179 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
1180 LPDWORD pcchPathBuf
)
1182 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
1183 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
1185 return ERROR_CALL_NOT_IMPLEMENTED
;
1188 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
1189 LPSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
1191 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
1192 return ERROR_CALL_NOT_IMPLEMENTED
;
1195 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
1196 LPWSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
1198 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
1199 return ERROR_CALL_NOT_IMPLEMENTED
;
1202 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
1203 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
1204 LPDWORD pcbHashData
)
1206 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
1207 ppcCertContext
, pbHashData
, pcbHashData
);
1208 return ERROR_CALL_NOT_IMPLEMENTED
;
1211 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
1212 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
1213 LPDWORD pcbHashData
)
1215 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
1216 ppcCertContext
, pbHashData
, pcbHashData
);
1217 return ERROR_CALL_NOT_IMPLEMENTED
;
1220 UINT WINAPI
MsiGetProductPropertyA( MSIHANDLE hProduct
, LPCSTR szProperty
,
1221 LPSTR szValue
, LPDWORD pccbValue
)
1223 FIXME("%ld %s %p %p\n", hProduct
, debugstr_a(szProperty
), szValue
, pccbValue
);
1224 return ERROR_CALL_NOT_IMPLEMENTED
;
1227 UINT WINAPI
MsiGetProductPropertyW( MSIHANDLE hProduct
, LPCWSTR szProperty
,
1228 LPWSTR szValue
, LPDWORD pccbValue
)
1230 FIXME("%ld %s %p %p\n", hProduct
, debugstr_w(szProperty
), szValue
, pccbValue
);
1231 return ERROR_CALL_NOT_IMPLEMENTED
;
1234 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
1237 LPWSTR szPack
= NULL
;
1239 TRACE("%s\n", debugstr_a(szPackage
) );
1243 szPack
= strdupAtoW( szPackage
);
1245 return ERROR_OUTOFMEMORY
;
1248 r
= MsiVerifyPackageW( szPack
);
1255 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
1260 TRACE("%s\n", debugstr_w(szPackage
) );
1262 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
1263 MsiCloseHandle( handle
);
1268 static INSTALLSTATE WINAPI
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
1269 awstring
* lpPathBuf
, LPDWORD pcchBuf
)
1271 WCHAR squished_pc
[GUID_SIZE
];
1272 WCHAR squished_comp
[GUID_SIZE
];
1278 static const WCHAR wininstaller
[] = {
1279 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1281 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
1282 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
1284 if (!szProduct
|| !szComponent
)
1285 return INSTALLSTATE_INVALIDARG
;
1287 if (lpPathBuf
->str
.w
&& !pcchBuf
)
1288 return INSTALLSTATE_INVALIDARG
;
1290 if (!squash_guid(szProduct
, squished_pc
) ||
1291 !squash_guid(szComponent
, squished_comp
))
1292 return INSTALLSTATE_INVALIDARG
;
1294 state
= INSTALLSTATE_UNKNOWN
;
1296 if (MSIREG_OpenLocalSystemComponentKey(szComponent
, &hkey
, FALSE
) == ERROR_SUCCESS
||
1297 MSIREG_OpenUserDataComponentKey(szComponent
, &hkey
, FALSE
) == ERROR_SUCCESS
)
1299 path
= msi_reg_get_val_str(hkey
, squished_pc
);
1302 state
= INSTALLSTATE_ABSENT
;
1304 if ((MSIREG_OpenLocalSystemProductKey(szProduct
, &hkey
, FALSE
) == ERROR_SUCCESS
||
1305 MSIREG_OpenUserDataProductKey(szProduct
, &hkey
, FALSE
) == ERROR_SUCCESS
) &&
1306 msi_reg_get_val_dword(hkey
, wininstaller
, &version
) &&
1307 GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
1310 state
= INSTALLSTATE_LOCAL
;
1314 if (state
!= INSTALLSTATE_LOCAL
&&
1315 (MSIREG_OpenUserProductsKey(szProduct
, &hkey
, FALSE
) == ERROR_SUCCESS
||
1316 MSIREG_OpenLocalClassesProductKey(szProduct
, &hkey
, FALSE
) == ERROR_SUCCESS
))
1320 if (MSIREG_OpenLocalSystemComponentKey(szComponent
, &hkey
, FALSE
) == ERROR_SUCCESS
||
1321 MSIREG_OpenUserDataComponentKey(szComponent
, &hkey
, FALSE
) == ERROR_SUCCESS
)
1324 path
= msi_reg_get_val_str(hkey
, squished_pc
);
1327 state
= INSTALLSTATE_ABSENT
;
1329 if (GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
1330 state
= INSTALLSTATE_LOCAL
;
1335 return INSTALLSTATE_UNKNOWN
;
1337 if (state
== INSTALLSTATE_LOCAL
&& !*path
)
1338 state
= INSTALLSTATE_NOTUSED
;
1340 msi_strcpy_to_awstring(path
, lpPathBuf
, pcchBuf
);
1345 /******************************************************************
1346 * MsiGetComponentPathW [MSI.@]
1348 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
1349 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
1353 path
.unicode
= TRUE
;
1354 path
.str
.w
= lpPathBuf
;
1356 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
1359 /******************************************************************
1360 * MsiGetComponentPathA [MSI.@]
1362 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
1363 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
1365 LPWSTR szwProduct
, szwComponent
= NULL
;
1366 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
1369 szwProduct
= strdupAtoW( szProduct
);
1370 if( szProduct
&& !szwProduct
)
1373 szwComponent
= strdupAtoW( szComponent
);
1374 if( szComponent
&& !szwComponent
)
1377 path
.unicode
= FALSE
;
1378 path
.str
.a
= lpPathBuf
;
1380 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
1383 msi_free( szwProduct
);
1384 msi_free( szwComponent
);
1389 /******************************************************************
1390 * MsiQueryFeatureStateA [MSI.@]
1392 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
1394 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
1395 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
1397 szwProduct
= strdupAtoW( szProduct
);
1398 if ( szProduct
&& !szwProduct
)
1401 szwFeature
= strdupAtoW( szFeature
);
1402 if ( szFeature
&& !szwFeature
)
1405 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
1408 msi_free( szwProduct
);
1409 msi_free( szwFeature
);
1414 /******************************************************************
1415 * MsiQueryFeatureStateW [MSI.@]
1417 * Checks the state of a feature
1420 * szProduct [I] Product's GUID string
1421 * szFeature [I] Feature's GUID string
1424 * INSTALLSTATE_LOCAL Feature is installed and useable
1425 * INSTALLSTATE_ABSENT Feature is absent
1426 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
1427 * INSTALLSTATE_UNKNOWN An error occurred
1428 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
1431 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
1433 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
1435 LPWSTR components
, p
, parent_feature
, path
;
1439 BOOL missing
= FALSE
;
1441 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
1443 if (!szProduct
|| !szFeature
)
1444 return INSTALLSTATE_INVALIDARG
;
1446 if (!squash_guid( szProduct
, squishProduct
))
1447 return INSTALLSTATE_INVALIDARG
;
1449 /* check that it's installed at all */
1450 rc
= MSIREG_OpenUserFeaturesKey(szProduct
, &hkey
, FALSE
);
1451 if (rc
!= ERROR_SUCCESS
)
1452 return INSTALLSTATE_UNKNOWN
;
1454 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
1457 if (!parent_feature
)
1458 return INSTALLSTATE_UNKNOWN
;
1460 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
1461 msi_free(parent_feature
);
1462 if (r
== INSTALLSTATE_ABSENT
)
1465 /* now check if it's complete or advertised */
1466 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
, &hkey
, FALSE
);
1467 if (rc
!= ERROR_SUCCESS
)
1468 return INSTALLSTATE_ADVERTISED
;
1470 components
= msi_reg_get_val_str( hkey
, szFeature
);
1473 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
1476 return INSTALLSTATE_ADVERTISED
;
1478 for( p
= components
; *p
&& *p
!= 2 ; p
+= 20)
1480 if (!decode_base85_guid( p
, &guid
))
1482 if (p
!= components
)
1485 msi_free(components
);
1486 return INSTALLSTATE_BADCONFIG
;
1489 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
1490 rc
= MSIREG_OpenUserDataComponentKey(comp
, &hkey
, FALSE
);
1491 if (rc
!= ERROR_SUCCESS
)
1493 msi_free(components
);
1494 return INSTALLSTATE_ADVERTISED
;
1497 path
= msi_reg_get_val_str(hkey
, squishProduct
);
1504 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
1505 msi_free(components
);
1508 return INSTALLSTATE_ADVERTISED
;
1510 return INSTALLSTATE_LOCAL
;
1513 /******************************************************************
1514 * MsiGetFileVersionA [MSI.@]
1516 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
1517 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
1519 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
1520 UINT ret
= ERROR_OUTOFMEMORY
;
1522 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
1523 (lpLangBuf
&& !pcchLangBuf
))
1524 return ERROR_INVALID_PARAMETER
;
1528 szwFilePath
= strdupAtoW( szFilePath
);
1533 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
1535 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
1536 if( !lpwVersionBuff
)
1540 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
1542 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
1547 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
1548 lpwLangBuff
, pcchLangBuf
);
1550 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
1551 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
1552 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
1553 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
1554 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
1555 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
1558 msi_free(szwFilePath
);
1559 msi_free(lpwVersionBuff
);
1560 msi_free(lpwLangBuff
);
1565 /******************************************************************
1566 * MsiGetFileVersionW [MSI.@]
1568 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
1569 LPDWORD pcchVersionBuf
, LPWSTR lpLangBuf
, LPDWORD pcchLangBuf
)
1571 static const WCHAR szVersionResource
[] = {'\\',0};
1572 static const WCHAR szVersionFormat
[] = {
1573 '%','d','.','%','d','.','%','d','.','%','d',0};
1574 static const WCHAR szLangFormat
[] = {'%','d',0};
1576 DWORD dwVerLen
, gle
;
1577 LPVOID lpVer
= NULL
;
1578 VS_FIXEDFILEINFO
*ffi
;
1582 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath
),
1583 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
1584 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
1586 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
1587 (lpLangBuf
&& !pcchLangBuf
))
1588 return ERROR_INVALID_PARAMETER
;
1590 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
1593 gle
= GetLastError();
1594 if (gle
== ERROR_BAD_PATHNAME
)
1595 return ERROR_FILE_NOT_FOUND
;
1596 else if (gle
== ERROR_RESOURCE_DATA_NOT_FOUND
)
1597 return ERROR_FILE_INVALID
;
1602 lpVer
= msi_alloc(dwVerLen
);
1605 ret
= ERROR_OUTOFMEMORY
;
1609 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
1611 ret
= GetLastError();
1617 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
1620 wsprintfW(tmp
, szVersionFormat
,
1621 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
1622 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
1623 if (lpVersionBuf
) lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
1625 if (lstrlenW(tmp
) >= *pcchVersionBuf
)
1626 ret
= ERROR_MORE_DATA
;
1628 *pcchVersionBuf
= lstrlenW(tmp
);
1632 if (lpVersionBuf
) *lpVersionBuf
= 0;
1633 *pcchVersionBuf
= 0;
1639 DWORD lang
= GetUserDefaultLangID();
1641 FIXME("Retrieve language from file\n");
1642 wsprintfW(tmp
, szLangFormat
, lang
);
1643 if (lpLangBuf
) lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
1645 if (lstrlenW(tmp
) >= *pcchLangBuf
)
1646 ret
= ERROR_MORE_DATA
;
1648 *pcchLangBuf
= lstrlenW(tmp
);
1656 /***********************************************************************
1657 * MsiGetFeatureUsageW [MSI.@]
1659 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1660 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
1662 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
1663 pdwUseCount
, pwDateUsed
);
1664 return ERROR_CALL_NOT_IMPLEMENTED
;
1667 /***********************************************************************
1668 * MsiGetFeatureUsageA [MSI.@]
1670 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
1671 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
1673 LPWSTR prod
= NULL
, feat
= NULL
;
1674 UINT ret
= ERROR_OUTOFMEMORY
;
1676 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1677 pdwUseCount
, pwDateUsed
);
1679 prod
= strdupAtoW( szProduct
);
1680 if (szProduct
&& !prod
)
1683 feat
= strdupAtoW( szFeature
);
1684 if (szFeature
&& !feat
)
1687 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
1696 /***********************************************************************
1697 * MsiUseFeatureExW [MSI.@]
1699 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
1700 DWORD dwInstallMode
, DWORD dwReserved
)
1704 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
1705 dwInstallMode
, dwReserved
);
1707 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
1710 return INSTALLSTATE_INVALIDARG
;
1712 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
1714 FIXME("mark product %s feature %s as used\n",
1715 debugstr_w(szProduct
), debugstr_w(szFeature
) );
1721 /***********************************************************************
1722 * MsiUseFeatureExA [MSI.@]
1724 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
1725 DWORD dwInstallMode
, DWORD dwReserved
)
1727 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
1728 LPWSTR prod
= NULL
, feat
= NULL
;
1730 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
1731 dwInstallMode
, dwReserved
);
1733 prod
= strdupAtoW( szProduct
);
1734 if (szProduct
&& !prod
)
1737 feat
= strdupAtoW( szFeature
);
1738 if (szFeature
&& !feat
)
1741 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
1750 /***********************************************************************
1751 * MsiUseFeatureW [MSI.@]
1753 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
1755 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
1758 /***********************************************************************
1759 * MsiUseFeatureA [MSI.@]
1761 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
1763 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
1766 /***********************************************************************
1767 * MSI_ProvideQualifiedComponentEx [internal]
1769 static UINT WINAPI
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
1770 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
1771 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
1772 LPDWORD pcchPathBuf
)
1774 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
1775 feature
[MAX_FEATURE_CHARS
+1];
1781 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent
),
1782 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
1783 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1785 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
1786 if (rc
!= ERROR_SUCCESS
)
1787 return ERROR_INDEX_ABSENT
;
1789 info
= msi_reg_get_val_str( hkey
, szQualifier
);
1793 return ERROR_INDEX_ABSENT
;
1795 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
1798 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
1800 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
1804 if (rc
!= INSTALLSTATE_LOCAL
)
1805 return ERROR_FILE_NOT_FOUND
;
1807 return ERROR_SUCCESS
;
1810 /***********************************************************************
1811 * MsiProvideQualifiedComponentExW [MSI.@]
1813 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
1814 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
1815 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
1816 LPDWORD pcchPathBuf
)
1820 path
.unicode
= TRUE
;
1821 path
.str
.w
= lpPathBuf
;
1823 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
1824 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
1827 /***********************************************************************
1828 * MsiProvideQualifiedComponentExA [MSI.@]
1830 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
1831 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
1832 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
1833 LPDWORD pcchPathBuf
)
1835 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
1836 UINT r
= ERROR_OUTOFMEMORY
;
1839 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
1840 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
1841 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
1843 szwComponent
= strdupAtoW( szComponent
);
1844 if (szComponent
&& !szwComponent
)
1847 szwQualifier
= strdupAtoW( szQualifier
);
1848 if (szQualifier
&& !szwQualifier
)
1851 szwProduct
= strdupAtoW( szProduct
);
1852 if (szProduct
&& !szwProduct
)
1855 path
.unicode
= FALSE
;
1856 path
.str
.a
= lpPathBuf
;
1858 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
1859 dwInstallMode
, szwProduct
, Unused1
,
1860 Unused2
, &path
, pcchPathBuf
);
1862 msi_free(szwProduct
);
1863 msi_free(szwComponent
);
1864 msi_free(szwQualifier
);
1869 /***********************************************************************
1870 * MsiProvideQualifiedComponentW [MSI.@]
1872 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
1873 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
1874 LPDWORD pcchPathBuf
)
1876 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
1877 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1880 /***********************************************************************
1881 * MsiProvideQualifiedComponentA [MSI.@]
1883 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
1884 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
1885 LPDWORD pcchPathBuf
)
1887 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
1888 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
1891 /***********************************************************************
1892 * MSI_GetUserInfo [internal]
1894 static USERINFOSTATE WINAPI
MSI_GetUserInfo(LPCWSTR szProduct
,
1895 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
1896 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
1897 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
1900 LPWSTR user
, org
, serial
;
1902 USERINFOSTATE state
;
1904 TRACE("%s %p %p %p %p %p %p\n",debugstr_w(szProduct
), lpUserNameBuf
,
1905 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
1909 return USERINFOSTATE_INVALIDARG
;
1911 r
= MSIREG_OpenUninstallKey(szProduct
, &hkey
, FALSE
);
1912 if (r
!= ERROR_SUCCESS
)
1913 return USERINFOSTATE_UNKNOWN
;
1915 user
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGOWNERW
);
1916 org
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_REGCOMPANYW
);
1917 serial
= msi_reg_get_val_str( hkey
, INSTALLPROPERTY_PRODUCTIDW
);
1921 state
= USERINFOSTATE_PRESENT
;
1925 r
= msi_strcpy_to_awstring( user
, lpUserNameBuf
, pcchUserNameBuf
);
1926 if (r
== ERROR_MORE_DATA
)
1927 state
= USERINFOSTATE_MOREDATA
;
1930 state
= USERINFOSTATE_ABSENT
;
1933 r
= msi_strcpy_to_awstring( org
, lpOrgNameBuf
, pcchOrgNameBuf
);
1934 if (r
== ERROR_MORE_DATA
&& state
== USERINFOSTATE_PRESENT
)
1935 state
= USERINFOSTATE_MOREDATA
;
1937 /* msdn states: The user information is considered to be present even in the absence of a company name. */
1940 r
= msi_strcpy_to_awstring( serial
, lpSerialBuf
, pcchSerialBuf
);
1941 if (r
== ERROR_MORE_DATA
&& state
== USERINFOSTATE_PRESENT
)
1942 state
= USERINFOSTATE_MOREDATA
;
1945 state
= USERINFOSTATE_ABSENT
;
1954 /***********************************************************************
1955 * MsiGetUserInfoW [MSI.@]
1957 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
1958 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
1959 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
1960 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
1962 awstring user
, org
, serial
;
1964 user
.unicode
= TRUE
;
1965 user
.str
.w
= lpUserNameBuf
;
1967 org
.str
.w
= lpOrgNameBuf
;
1968 serial
.unicode
= TRUE
;
1969 serial
.str
.w
= lpSerialBuf
;
1971 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
1972 &org
, pcchOrgNameBuf
,
1973 &serial
, pcchSerialBuf
);
1976 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
1977 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
1978 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
1979 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
1981 awstring user
, org
, serial
;
1985 prod
= strdupAtoW( szProduct
);
1986 if (szProduct
&& !prod
)
1987 return ERROR_OUTOFMEMORY
;
1989 user
.unicode
= FALSE
;
1990 user
.str
.a
= lpUserNameBuf
;
1991 org
.unicode
= FALSE
;
1992 org
.str
.a
= lpOrgNameBuf
;
1993 serial
.unicode
= FALSE
;
1994 serial
.str
.a
= lpSerialBuf
;
1996 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
1997 &org
, pcchOrgNameBuf
,
1998 &serial
, pcchSerialBuf
);
2005 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
2009 MSIPACKAGE
*package
;
2010 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
2012 TRACE("(%s)\n",debugstr_w(szProduct
));
2014 rc
= MsiOpenProductW(szProduct
,&handle
);
2015 if (rc
!= ERROR_SUCCESS
)
2016 return ERROR_INVALID_PARAMETER
;
2018 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
2019 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
2020 msiobj_release( &package
->hdr
);
2022 MsiCloseHandle(handle
);
2027 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
2031 MSIPACKAGE
*package
;
2032 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
2034 TRACE("(%s)\n",debugstr_a(szProduct
));
2036 rc
= MsiOpenProductA(szProduct
,&handle
);
2037 if (rc
!= ERROR_SUCCESS
)
2038 return ERROR_INVALID_PARAMETER
;
2040 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
2041 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
2042 msiobj_release( &package
->hdr
);
2044 MsiCloseHandle(handle
);
2049 /***********************************************************************
2050 * MsiConfigureFeatureA [MSI.@]
2052 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
2054 LPWSTR prod
, feat
= NULL
;
2055 UINT r
= ERROR_OUTOFMEMORY
;
2057 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
2059 prod
= strdupAtoW( szProduct
);
2060 if (szProduct
&& !prod
)
2063 feat
= strdupAtoW( szFeature
);
2064 if (szFeature
&& !feat
)
2067 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
2076 /***********************************************************************
2077 * MsiConfigureFeatureW [MSI.@]
2079 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
2081 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
2082 MSIPACKAGE
*package
= NULL
;
2084 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
2087 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
2089 if (!szProduct
|| !szFeature
)
2090 return ERROR_INVALID_PARAMETER
;
2092 switch (eInstallState
)
2094 case INSTALLSTATE_DEFAULT
:
2095 /* FIXME: how do we figure out the default location? */
2096 eInstallState
= INSTALLSTATE_LOCAL
;
2098 case INSTALLSTATE_LOCAL
:
2099 case INSTALLSTATE_SOURCE
:
2100 case INSTALLSTATE_ABSENT
:
2101 case INSTALLSTATE_ADVERTISED
:
2104 return ERROR_INVALID_PARAMETER
;
2107 r
= MSI_OpenProductW( szProduct
, &package
);
2108 if (r
!= ERROR_SUCCESS
)
2111 sz
= sizeof(sourcepath
);
2112 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2113 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
2115 sz
= sizeof(filename
);
2116 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2117 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
2119 lstrcatW( sourcepath
, filename
);
2121 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
2123 r
= ACTION_PerformUIAction( package
, szCostInit
, -1 );
2124 if (r
!= ERROR_SUCCESS
)
2127 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
2128 if (r
!= ERROR_SUCCESS
)
2131 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
2134 msiobj_release( &package
->hdr
);
2139 /***********************************************************************
2140 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
2142 * Notes: undocumented
2144 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
2146 WCHAR path
[MAX_PATH
];
2148 TRACE("%d\n", dwReserved
);
2152 FIXME("dwReserved=%d\n", dwReserved
);
2153 return ERROR_INVALID_PARAMETER
;
2156 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
2157 return ERROR_FUNCTION_FAILED
;
2159 lstrcatW(path
, installerW
);
2161 if (!CreateDirectoryW(path
, NULL
))
2162 return ERROR_FUNCTION_FAILED
;
2164 return ERROR_SUCCESS
;
2167 /***********************************************************************
2168 * MsiGetShortcutTargetA [MSI.@]
2170 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
2171 LPSTR szProductCode
, LPSTR szFeatureId
,
2172 LPSTR szComponentCode
)
2175 const int len
= MAX_FEATURE_CHARS
+1;
2176 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
2179 target
= strdupAtoW( szShortcutTarget
);
2180 if (szShortcutTarget
&& !target
)
2181 return ERROR_OUTOFMEMORY
;
2185 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
2187 if (r
== ERROR_SUCCESS
)
2189 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
2190 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
2191 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
2196 /***********************************************************************
2197 * MsiGetShortcutTargetW [MSI.@]
2199 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
2200 LPWSTR szProductCode
, LPWSTR szFeatureId
,
2201 LPWSTR szComponentCode
)
2203 IShellLinkDataList
*dl
= NULL
;
2204 IPersistFile
*pf
= NULL
;
2205 LPEXP_DARWIN_LINK darwin
= NULL
;
2208 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
2209 szProductCode
, szFeatureId
, szComponentCode
);
2211 init
= CoInitialize(NULL
);
2213 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
2214 &IID_IPersistFile
, (LPVOID
*) &pf
);
2215 if( SUCCEEDED( r
) )
2217 r
= IPersistFile_Load( pf
, szShortcutTarget
,
2218 STGM_READ
| STGM_SHARE_DENY_WRITE
);
2219 if( SUCCEEDED( r
) )
2221 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
2223 if( SUCCEEDED( r
) )
2225 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
2227 IShellLinkDataList_Release( dl
);
2230 IPersistFile_Release( pf
);
2233 if (SUCCEEDED(init
))
2236 TRACE("darwin = %p\n", darwin
);
2243 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
2244 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
2245 LocalFree( darwin
);
2249 return ERROR_FUNCTION_FAILED
;
2252 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2253 DWORD dwReinstallMode
)
2255 MSIPACKAGE
* package
= NULL
;
2257 WCHAR sourcepath
[MAX_PATH
];
2258 WCHAR filename
[MAX_PATH
];
2259 static const WCHAR szLogVerbose
[] = {
2260 ' ','L','O','G','V','E','R','B','O','S','E',0 };
2261 static const WCHAR szInstalled
[] = { 'I','n','s','t','a','l','l','e','d',0};
2262 static const WCHAR szReinstall
[] = {'R','E','I','N','S','T','A','L','L',0};
2263 static const WCHAR szReinstallMode
[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
2264 static const WCHAR szOne
[] = {'1',0};
2265 WCHAR reinstallmode
[11];
2269 FIXME("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
2272 ptr
= reinstallmode
;
2274 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
2276 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
2278 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
2280 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
2282 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
2284 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
2286 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
2288 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
2290 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
2292 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
2296 sz
= sizeof(sourcepath
);
2297 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2298 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
2300 sz
= sizeof(filename
);
2301 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
2302 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
2304 lstrcatW( sourcepath
, filename
);
2306 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
2307 r
= MSI_OpenPackageW( sourcepath
, &package
);
2309 r
= MSI_OpenProductW( szProduct
, &package
);
2311 if (r
!= ERROR_SUCCESS
)
2314 MSI_SetPropertyW( package
, szReinstallMode
, reinstallmode
);
2315 MSI_SetPropertyW( package
, szInstalled
, szOne
);
2316 MSI_SetPropertyW( package
, szLogVerbose
, szOne
);
2317 MSI_SetPropertyW( package
, szReinstall
, szFeature
);
2319 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
2321 msiobj_release( &package
->hdr
);
2326 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
2327 DWORD dwReinstallMode
)
2333 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2336 wszProduct
= strdupAtoW(szProduct
);
2337 wszFeature
= strdupAtoW(szFeature
);
2339 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
2341 msi_free(wszProduct
);
2342 msi_free(wszFeature
);
2349 unsigned int buf
[4];
2350 unsigned char in
[64];
2351 unsigned char digest
[16];
2354 extern VOID WINAPI
MD5Init( MD5_CTX
*);
2355 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
2356 extern VOID WINAPI
MD5Final( MD5_CTX
*);
2358 /***********************************************************************
2359 * MsiGetFileHashW [MSI.@]
2361 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
2362 PMSIFILEHASHINFO pHash
)
2364 HANDLE handle
, mapping
;
2367 UINT r
= ERROR_FUNCTION_FAILED
;
2369 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
2372 return ERROR_INVALID_PARAMETER
;
2375 return ERROR_PATH_NOT_FOUND
;
2378 return ERROR_INVALID_PARAMETER
;
2380 return ERROR_INVALID_PARAMETER
;
2381 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
2382 return ERROR_INVALID_PARAMETER
;
2384 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
2385 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
2386 if (handle
== INVALID_HANDLE_VALUE
)
2387 return ERROR_FILE_NOT_FOUND
;
2389 length
= GetFileSize( handle
, NULL
);
2391 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
2394 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
2400 MD5Update( &ctx
, p
, length
);
2402 UnmapViewOfFile( p
);
2404 memcpy( pHash
->dwData
, &ctx
.digest
, sizeof pHash
->dwData
);
2407 CloseHandle( mapping
);
2409 CloseHandle( handle
);
2414 /***********************************************************************
2415 * MsiGetFileHashA [MSI.@]
2417 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
2418 PMSIFILEHASHINFO pHash
)
2423 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
2425 file
= strdupAtoW( szFilePath
);
2426 if (szFilePath
&& !file
)
2427 return ERROR_OUTOFMEMORY
;
2429 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
2434 /***********************************************************************
2435 * MsiAdvertiseScriptW [MSI.@]
2437 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
2438 PHKEY phRegData
, BOOL fRemoveItems
)
2440 FIXME("%s %08x %p %d\n",
2441 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2442 return ERROR_CALL_NOT_IMPLEMENTED
;
2445 /***********************************************************************
2446 * MsiAdvertiseScriptA [MSI.@]
2448 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
2449 PHKEY phRegData
, BOOL fRemoveItems
)
2451 FIXME("%s %08x %p %d\n",
2452 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
2453 return ERROR_CALL_NOT_IMPLEMENTED
;