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 static UINT
msi_locate_product(LPCWSTR szProduct
, MSIINSTALLCONTEXT
*context
)
52 *context
= MSIINSTALLCONTEXT_NONE
;
54 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
55 &hkey
, FALSE
) == ERROR_SUCCESS
)
56 *context
= MSIINSTALLCONTEXT_USERMANAGED
;
57 else if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
58 &hkey
, FALSE
) == ERROR_SUCCESS
)
59 *context
= MSIINSTALLCONTEXT_MACHINE
;
60 else if (MSIREG_OpenProductKey(szProduct
, NULL
,
61 MSIINSTALLCONTEXT_USERUNMANAGED
,
62 &hkey
, FALSE
) == ERROR_SUCCESS
)
63 *context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
67 if (*context
== MSIINSTALLCONTEXT_NONE
)
68 return ERROR_UNKNOWN_PRODUCT
;
73 UINT WINAPI
MsiOpenProductA(LPCSTR szProduct
, MSIHANDLE
*phProduct
)
76 LPWSTR szwProd
= NULL
;
78 TRACE("%s %p\n",debugstr_a(szProduct
), phProduct
);
82 szwProd
= strdupAtoW( szProduct
);
84 return ERROR_OUTOFMEMORY
;
87 r
= MsiOpenProductW( szwProd
, phProduct
);
94 static UINT
MSI_OpenProductW(LPCWSTR szProduct
, MSIPACKAGE
**package
)
99 MSIINSTALLCONTEXT context
;
101 static const WCHAR managed
[] = {
102 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0};
103 static const WCHAR local
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
105 TRACE("%s %p\n", debugstr_w(szProduct
), package
);
107 r
= msi_locate_product(szProduct
, &context
);
108 if (r
!= ERROR_SUCCESS
)
111 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &props
, FALSE
);
112 if (r
!= ERROR_SUCCESS
)
113 return ERROR_UNKNOWN_PRODUCT
;
115 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
116 path
= msi_reg_get_val_str(props
, managed
);
118 path
= msi_reg_get_val_str(props
, local
);
120 r
= ERROR_UNKNOWN_PRODUCT
;
122 if (!path
|| GetFileAttributesW(path
) == INVALID_FILE_ATTRIBUTES
)
125 if (PathIsRelativeW(path
))
127 r
= ERROR_INSTALL_PACKAGE_OPEN_FAILED
;
131 r
= MSI_OpenPackageW(path
, package
);
139 UINT WINAPI
MsiOpenProductW(LPCWSTR szProduct
, MSIHANDLE
*phProduct
)
141 MSIPACKAGE
*package
= NULL
;
142 WCHAR squished_pc
[GUID_SIZE
];
145 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
146 return ERROR_INVALID_PARAMETER
;
149 return ERROR_INVALID_PARAMETER
;
151 r
= MSI_OpenProductW(szProduct
, &package
);
152 if (r
!= ERROR_SUCCESS
)
155 *phProduct
= alloc_msihandle(&package
->hdr
);
157 r
= ERROR_NOT_ENOUGH_MEMORY
;
159 msiobj_release(&package
->hdr
);
163 UINT WINAPI
MsiAdvertiseProductA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
164 LPCSTR szTransforms
, LANGID lgidLanguage
)
166 FIXME("%s %s %s %08x\n",debugstr_a(szPackagePath
),
167 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
), lgidLanguage
);
168 return ERROR_CALL_NOT_IMPLEMENTED
;
171 UINT WINAPI
MsiAdvertiseProductW(LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
172 LPCWSTR szTransforms
, LANGID lgidLanguage
)
174 FIXME("%s %s %s %08x\n",debugstr_w(szPackagePath
),
175 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
), lgidLanguage
);
176 return ERROR_CALL_NOT_IMPLEMENTED
;
179 UINT WINAPI
MsiAdvertiseProductExA(LPCSTR szPackagePath
, LPCSTR szScriptfilePath
,
180 LPCSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
182 FIXME("%s %s %s %08x %08x %08x\n", debugstr_a(szPackagePath
),
183 debugstr_a(szScriptfilePath
), debugstr_a(szTransforms
),
184 lgidLanguage
, dwPlatform
, dwOptions
);
185 return ERROR_CALL_NOT_IMPLEMENTED
;
188 UINT WINAPI
MsiAdvertiseProductExW( LPCWSTR szPackagePath
, LPCWSTR szScriptfilePath
,
189 LPCWSTR szTransforms
, LANGID lgidLanguage
, DWORD dwPlatform
, DWORD dwOptions
)
191 FIXME("%s %s %s %08x %08x %08x\n", debugstr_w(szPackagePath
),
192 debugstr_w(szScriptfilePath
), debugstr_w(szTransforms
),
193 lgidLanguage
, dwPlatform
, dwOptions
);
194 return ERROR_CALL_NOT_IMPLEMENTED
;
197 UINT WINAPI
MsiInstallProductA(LPCSTR szPackagePath
, LPCSTR szCommandLine
)
199 LPWSTR szwPath
= NULL
, szwCommand
= NULL
;
200 UINT r
= ERROR_OUTOFMEMORY
;
202 TRACE("%s %s\n",debugstr_a(szPackagePath
), debugstr_a(szCommandLine
));
206 szwPath
= strdupAtoW( szPackagePath
);
213 szwCommand
= strdupAtoW( szCommandLine
);
218 r
= MsiInstallProductW( szwPath
, szwCommand
);
222 msi_free( szwCommand
);
227 UINT WINAPI
MsiInstallProductW(LPCWSTR szPackagePath
, LPCWSTR szCommandLine
)
229 MSIPACKAGE
*package
= NULL
;
232 TRACE("%s %s\n",debugstr_w(szPackagePath
), debugstr_w(szCommandLine
));
235 return ERROR_INVALID_PARAMETER
;
238 return ERROR_PATH_NOT_FOUND
;
240 r
= MSI_OpenPackageW( szPackagePath
, &package
);
241 if (r
== ERROR_SUCCESS
)
243 r
= MSI_InstallPackage( package
, szPackagePath
, szCommandLine
);
244 msiobj_release( &package
->hdr
);
250 UINT WINAPI
MsiReinstallProductA(LPCSTR szProduct
, DWORD dwReinstallMode
)
255 TRACE("%s %08x\n", debugstr_a(szProduct
), dwReinstallMode
);
257 wszProduct
= strdupAtoW(szProduct
);
259 rc
= MsiReinstallProductW(wszProduct
, dwReinstallMode
);
261 msi_free(wszProduct
);
265 UINT WINAPI
MsiReinstallProductW(LPCWSTR szProduct
, DWORD dwReinstallMode
)
267 TRACE("%s %08x\n", debugstr_w(szProduct
), dwReinstallMode
);
269 return MsiReinstallFeatureW(szProduct
, szAll
, dwReinstallMode
);
272 UINT WINAPI
MsiApplyPatchA(LPCSTR szPatchPackage
, LPCSTR szInstallPackage
,
273 INSTALLTYPE eInstallType
, LPCSTR szCommandLine
)
275 LPWSTR patch_package
= NULL
;
276 LPWSTR install_package
= NULL
;
277 LPWSTR command_line
= NULL
;
278 UINT r
= ERROR_OUTOFMEMORY
;
280 TRACE("%s %s %d %s\n", debugstr_a(szPatchPackage
), debugstr_a(szInstallPackage
),
281 eInstallType
, debugstr_a(szCommandLine
));
283 if (szPatchPackage
&& !(patch_package
= strdupAtoW(szPatchPackage
)))
286 if (szInstallPackage
&& !(install_package
= strdupAtoW(szInstallPackage
)))
289 if (szCommandLine
&& !(command_line
= strdupAtoW(szCommandLine
)))
292 r
= MsiApplyPatchW(patch_package
, install_package
, eInstallType
, command_line
);
295 msi_free(patch_package
);
296 msi_free(install_package
);
297 msi_free(command_line
);
302 static UINT
MSI_ApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szProductCode
, LPCWSTR szCommandLine
)
304 MSIHANDLE patch
= 0, info
= 0;
305 UINT r
= ERROR_SUCCESS
, type
;
307 LPCWSTR cmd_ptr
= szCommandLine
;
308 LPCWSTR product_code
= szProductCode
;
310 LPWSTR cmd
= NULL
, codes
= NULL
;
312 static const WCHAR patcheq
[] = {'P','A','T','C','H','=',0};
313 static WCHAR empty
[] = {0};
315 if (!szPatchPackage
|| !szPatchPackage
[0])
316 return ERROR_INVALID_PARAMETER
;
320 r
= MsiOpenDatabaseW(szPatchPackage
, MSIDBOPEN_READONLY
, &patch
);
321 if (r
!= ERROR_SUCCESS
)
324 r
= MsiGetSummaryInformationW(patch
, NULL
, 0, &info
);
325 if (r
!= ERROR_SUCCESS
)
328 r
= MsiSummaryInfoGetPropertyW(info
, PID_TEMPLATE
, &type
, NULL
, NULL
, empty
, &size
);
329 if (r
!= ERROR_MORE_DATA
|| !size
|| type
!= VT_LPSTR
)
331 ERR("Failed to read product codes from patch\n");
335 codes
= msi_alloc(++size
* sizeof(WCHAR
));
338 r
= ERROR_OUTOFMEMORY
;
342 r
= MsiSummaryInfoGetPropertyW(info
, PID_TEMPLATE
, &type
, NULL
, NULL
, codes
, &size
);
343 if (r
!= ERROR_SUCCESS
)
346 product_code
= codes
;
352 size
= lstrlenW(cmd_ptr
) + lstrlenW(patcheq
) + lstrlenW(szPatchPackage
) + 1;
353 cmd
= msi_alloc(size
* sizeof(WCHAR
));
356 r
= ERROR_OUTOFMEMORY
;
360 lstrcpyW(cmd
, cmd_ptr
);
361 if (szCommandLine
) lstrcatW(cmd
, szSpace
);
362 lstrcatW(cmd
, patcheq
);
363 lstrcatW(cmd
, szPatchPackage
);
366 while ((end
= strchrW(beg
, '}')))
370 r
= MsiConfigureProductExW(beg
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
371 if (r
!= ERROR_SUCCESS
)
381 MsiCloseHandle(info
);
382 MsiCloseHandle(patch
);
387 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
388 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
390 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
391 eInstallType
, debugstr_w(szCommandLine
));
393 if (szInstallPackage
|| eInstallType
== INSTALLTYPE_NETWORK_IMAGE
||
394 eInstallType
== INSTALLTYPE_SINGLE_INSTANCE
)
396 FIXME("Only reading target products from patch\n");
397 return ERROR_CALL_NOT_IMPLEMENTED
;
400 return MSI_ApplyPatchW(szPatchPackage
, NULL
, szCommandLine
);
403 UINT WINAPI
MsiApplyMultiplePatchesA(LPCSTR szPatchPackages
,
404 LPCSTR szProductCode
, LPCSTR szPropertiesList
)
406 LPWSTR patch_packages
= NULL
;
407 LPWSTR product_code
= NULL
;
408 LPWSTR properties_list
= NULL
;
409 UINT r
= ERROR_OUTOFMEMORY
;
411 TRACE("%s %s %s\n", debugstr_a(szPatchPackages
), debugstr_a(szProductCode
),
412 debugstr_a(szPropertiesList
));
414 if (!szPatchPackages
|| !szPatchPackages
[0])
415 return ERROR_INVALID_PARAMETER
;
417 if (!(patch_packages
= strdupAtoW(szPatchPackages
)))
418 return ERROR_OUTOFMEMORY
;
420 if (szProductCode
&& !(product_code
= strdupAtoW(szProductCode
)))
423 if (szPropertiesList
&& !(properties_list
= strdupAtoW(szPropertiesList
)))
426 r
= MsiApplyMultiplePatchesW(patch_packages
, product_code
, properties_list
);
429 msi_free(patch_packages
);
430 msi_free(product_code
);
431 msi_free(properties_list
);
436 UINT WINAPI
MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages
,
437 LPCWSTR szProductCode
, LPCWSTR szPropertiesList
)
439 UINT r
= ERROR_SUCCESS
;
442 TRACE("%s %s %s\n", debugstr_w(szPatchPackages
), debugstr_w(szProductCode
),
443 debugstr_w(szPropertiesList
));
445 if (!szPatchPackages
|| !szPatchPackages
[0])
446 return ERROR_INVALID_PARAMETER
;
448 beg
= end
= szPatchPackages
;
454 while (*beg
== ' ') beg
++;
455 while (*end
&& *end
!= ';') end
++;
458 while (len
&& beg
[len
- 1] == ' ') len
--;
460 if (!len
) return ERROR_INVALID_NAME
;
462 patch
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
464 return ERROR_OUTOFMEMORY
;
466 memcpy(patch
, beg
, len
* sizeof(WCHAR
));
469 r
= MSI_ApplyPatchW(patch
, szProductCode
, szPropertiesList
);
472 if (r
!= ERROR_SUCCESS
)
480 UINT WINAPI
MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath
,
481 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
483 FIXME("(%s, %d, %p): stub!\n", debugstr_a(szProductPackagePath
),
484 cPatchInfo
, pPatchInfo
);
486 return ERROR_CALL_NOT_IMPLEMENTED
;
489 static UINT
MSI_ApplicablePatchW( MSIPACKAGE
*package
, LPCWSTR patch
)
492 MSIDATABASE
*patch_db
;
493 UINT r
= ERROR_SUCCESS
;
495 r
= MSI_OpenDatabaseW( patch
, MSIDBOPEN_READONLY
, &patch_db
);
496 if (r
!= ERROR_SUCCESS
)
498 WARN("failed to open patch file %s\n", debugstr_w(patch
));
502 si
= MSI_GetSummaryInformationW( patch_db
->storage
, 0 );
505 r
= ERROR_FUNCTION_FAILED
;
509 r
= msi_check_patch_applicable( package
, si
);
510 if (r
!= ERROR_SUCCESS
)
511 TRACE("patch not applicable\n");
514 msiobj_release( &patch_db
->hdr
);
515 msiobj_release( &si
->hdr
);
519 UINT WINAPI
MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath
,
520 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
522 UINT i
, r
, ret
= ERROR_FUNCTION_FAILED
;
525 TRACE("(%s, %d, %p)\n", debugstr_w(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
527 r
= MSI_OpenPackageW( szProductPackagePath
, &package
);
528 if (r
!= ERROR_SUCCESS
)
530 ERR("failed to open package %u\n", r
);
534 for (i
= 0; i
< cPatchInfo
; i
++)
536 switch (pPatchInfo
[i
].ePatchDataType
)
538 case MSIPATCH_DATATYPE_PATCHFILE
:
540 FIXME("patch ordering not supported\n");
541 r
= MSI_ApplicablePatchW( package
, pPatchInfo
[i
].szPatchData
);
542 if (r
!= ERROR_SUCCESS
)
544 pPatchInfo
[i
].dwOrder
= ~0u;
545 pPatchInfo
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
549 pPatchInfo
[i
].dwOrder
= i
;
550 pPatchInfo
[i
].uStatus
= ret
= ERROR_SUCCESS
;
556 FIXME("patch data type %u not supported\n", pPatchInfo
[i
].ePatchDataType
);
557 pPatchInfo
[i
].dwOrder
= ~0u;
558 pPatchInfo
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
563 TRACE(" szPatchData: %s\n", debugstr_w(pPatchInfo
[i
].szPatchData
));
564 TRACE("ePatchDataType: %u\n", pPatchInfo
[i
].ePatchDataType
);
565 TRACE(" dwOrder: %u\n", pPatchInfo
[i
].dwOrder
);
566 TRACE(" uStatus: %u\n", pPatchInfo
[i
].uStatus
);
571 UINT WINAPI
MsiDeterminePatchSequenceA(LPCSTR szProductCode
, LPCSTR szUserSid
,
572 MSIINSTALLCONTEXT dwContext
, DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
574 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_a(szProductCode
),
575 debugstr_a(szUserSid
), dwContext
, cPatchInfo
, pPatchInfo
);
577 return ERROR_CALL_NOT_IMPLEMENTED
;
580 UINT WINAPI
MsiDeterminePatchSequenceW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
581 MSIINSTALLCONTEXT dwContext
, DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
583 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_w(szProductCode
),
584 debugstr_w(szUserSid
), dwContext
, cPatchInfo
, pPatchInfo
);
586 return ERROR_CALL_NOT_IMPLEMENTED
;
589 static UINT
msi_open_package(LPCWSTR product
, MSIINSTALLCONTEXT context
,
590 MSIPACKAGE
**package
)
596 WCHAR sourcepath
[MAX_PATH
];
597 WCHAR filename
[MAX_PATH
];
599 static const WCHAR szLocalPackage
[] = {
600 'L','o','c','a','l','P','a','c','k','a','g','e',0};
603 r
= MSIREG_OpenInstallProps(product
, context
, NULL
, &props
, FALSE
);
604 if (r
!= ERROR_SUCCESS
)
605 return ERROR_BAD_CONFIGURATION
;
607 localpack
= msi_reg_get_val_str(props
, szLocalPackage
);
610 lstrcpyW(sourcepath
, localpack
);
614 if (!localpack
|| GetFileAttributesW(sourcepath
) == INVALID_FILE_ATTRIBUTES
)
616 sz
= sizeof(sourcepath
);
617 MsiSourceListGetInfoW(product
, NULL
, context
, MSICODE_PRODUCT
,
618 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
620 sz
= sizeof(filename
);
621 MsiSourceListGetInfoW(product
, NULL
, context
, MSICODE_PRODUCT
,
622 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
624 lstrcatW(sourcepath
, filename
);
627 if (GetFileAttributesW(sourcepath
) == INVALID_FILE_ATTRIBUTES
)
628 return ERROR_INSTALL_SOURCE_ABSENT
;
630 return MSI_OpenPackageW(sourcepath
, package
);
633 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
634 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
636 MSIPACKAGE
* package
= NULL
;
637 MSIINSTALLCONTEXT context
;
640 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
643 static const WCHAR szInstalled
[] = {
644 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
645 static const WCHAR szRemoveAll
[] = {
646 ' ','R','E','M','O','V','E','=','A','L','L',0};
647 static const WCHAR szMachine
[] = {
648 ' ','A','L','L','U','S','E','R','S','=','1',0};
650 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
651 debugstr_w(szCommandLine
));
653 if (!szProduct
|| lstrlenW(szProduct
) != GUID_SIZE
- 1)
654 return ERROR_INVALID_PARAMETER
;
656 if (eInstallState
== INSTALLSTATE_ADVERTISED
||
657 eInstallState
== INSTALLSTATE_SOURCE
)
659 FIXME("State %d not implemented\n", eInstallState
);
660 return ERROR_CALL_NOT_IMPLEMENTED
;
663 r
= msi_locate_product(szProduct
, &context
);
664 if (r
!= ERROR_SUCCESS
)
667 r
= msi_open_package(szProduct
, context
, &package
);
668 if (r
!= ERROR_SUCCESS
)
671 sz
= lstrlenW(szInstalled
) + 1;
674 sz
+= lstrlenW(szCommandLine
);
676 if (eInstallState
== INSTALLSTATE_ABSENT
)
677 sz
+= lstrlenW(szRemoveAll
);
679 if (context
== MSIINSTALLCONTEXT_MACHINE
)
680 sz
+= lstrlenW(szMachine
);
682 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
685 r
= ERROR_OUTOFMEMORY
;
691 lstrcpyW(commandline
,szCommandLine
);
693 if (eInstallState
== INSTALLSTATE_ABSENT
)
694 lstrcatW(commandline
, szRemoveAll
);
696 if (context
== MSIINSTALLCONTEXT_MACHINE
)
697 lstrcatW(commandline
, szMachine
);
699 sz
= sizeof(sourcepath
);
700 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
701 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
703 sz
= sizeof(filename
);
704 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
705 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
707 strcatW(sourcepath
, filename
);
709 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
711 msi_free(commandline
);
714 msiobj_release( &package
->hdr
);
719 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
720 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
722 LPWSTR szwProduct
= NULL
;
723 LPWSTR szwCommandLine
= NULL
;
724 UINT r
= ERROR_OUTOFMEMORY
;
728 szwProduct
= strdupAtoW( szProduct
);
735 szwCommandLine
= strdupAtoW( szCommandLine
);
740 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
743 msi_free( szwProduct
);
744 msi_free( szwCommandLine
);
749 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
750 INSTALLSTATE eInstallState
)
752 LPWSTR szwProduct
= NULL
;
755 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
759 szwProduct
= strdupAtoW( szProduct
);
761 return ERROR_OUTOFMEMORY
;
764 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
765 msi_free( szwProduct
);
770 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
771 INSTALLSTATE eInstallState
)
773 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
776 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
778 LPWSTR szwComponent
= NULL
;
780 WCHAR szwBuffer
[GUID_SIZE
];
782 TRACE("%s %s\n",debugstr_a(szComponent
), debugstr_a(szBuffer
));
786 szwComponent
= strdupAtoW( szComponent
);
788 return ERROR_OUTOFMEMORY
;
792 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
795 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
797 msi_free( szwComponent
);
802 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
805 HKEY compkey
, prodkey
;
806 WCHAR squished_comp
[GUID_SIZE
];
807 WCHAR squished_prod
[GUID_SIZE
];
808 DWORD sz
= GUID_SIZE
;
810 TRACE("%s %p\n", debugstr_w(szComponent
), szBuffer
);
812 if (!szComponent
|| !*szComponent
)
813 return ERROR_INVALID_PARAMETER
;
815 if (!squash_guid(szComponent
, squished_comp
))
816 return ERROR_INVALID_PARAMETER
;
818 if (MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &compkey
, FALSE
) != ERROR_SUCCESS
&&
819 MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &compkey
, FALSE
) != ERROR_SUCCESS
)
821 return ERROR_UNKNOWN_COMPONENT
;
824 rc
= RegEnumValueW(compkey
, 0, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
825 if (rc
!= ERROR_SUCCESS
)
827 RegCloseKey(compkey
);
828 return ERROR_UNKNOWN_COMPONENT
;
831 /* check simple case, only one product */
832 rc
= RegEnumValueW(compkey
, 1, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
833 if (rc
== ERROR_NO_MORE_ITEMS
)
840 while ((rc
= RegEnumValueW(compkey
, index
, squished_prod
, &sz
,
841 NULL
, NULL
, NULL
, NULL
)) != ERROR_NO_MORE_ITEMS
)
845 unsquash_guid(squished_prod
, szBuffer
);
847 if (MSIREG_OpenProductKey(szBuffer
, NULL
,
848 MSIINSTALLCONTEXT_USERMANAGED
,
849 &prodkey
, FALSE
) == ERROR_SUCCESS
||
850 MSIREG_OpenProductKey(szBuffer
, NULL
,
851 MSIINSTALLCONTEXT_USERUNMANAGED
,
852 &prodkey
, FALSE
) == ERROR_SUCCESS
||
853 MSIREG_OpenProductKey(szBuffer
, NULL
,
854 MSIINSTALLCONTEXT_MACHINE
,
855 &prodkey
, FALSE
) == ERROR_SUCCESS
)
857 RegCloseKey(prodkey
);
863 rc
= ERROR_INSTALL_FAILURE
;
866 RegCloseKey(compkey
);
867 unsquash_guid(squished_prod
, szBuffer
);
871 static LPWSTR
msi_reg_get_value(HKEY hkey
, LPCWSTR name
, DWORD
*type
)
877 static const WCHAR format
[] = {'%','d',0};
879 res
= RegQueryValueExW(hkey
, name
, NULL
, type
, NULL
, NULL
);
880 if (res
!= ERROR_SUCCESS
)
884 return msi_reg_get_val_str(hkey
, name
);
886 if (!msi_reg_get_val_dword(hkey
, name
, &dval
))
889 sprintfW(temp
, format
, dval
);
890 return strdupW(temp
);
893 static UINT
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
894 awstring
*szValue
, LPDWORD pcchValueBuf
)
896 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
897 UINT r
= ERROR_UNKNOWN_PROPERTY
;
898 HKEY prodkey
, userdata
, source
;
900 WCHAR squished_pc
[GUID_SIZE
];
901 WCHAR packagecode
[GUID_SIZE
];
902 BOOL badconfig
= FALSE
;
904 DWORD type
= REG_NONE
;
906 static WCHAR empty
[] = {0};
907 static const WCHAR sourcelist
[] = {
908 'S','o','u','r','c','e','L','i','s','t',0};
909 static const WCHAR display_name
[] = {
910 'D','i','s','p','l','a','y','N','a','m','e',0};
911 static const WCHAR display_version
[] = {
912 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
913 static const WCHAR assignment
[] = {
914 'A','s','s','i','g','n','m','e','n','t',0};
916 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
917 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
919 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
920 return ERROR_INVALID_PARAMETER
;
922 if (!squash_guid(szProduct
, squished_pc
))
923 return ERROR_INVALID_PARAMETER
;
925 if ((r
= MSIREG_OpenProductKey(szProduct
, NULL
,
926 MSIINSTALLCONTEXT_USERMANAGED
,
927 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
928 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
929 MSIINSTALLCONTEXT_USERUNMANAGED
,
930 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
931 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
932 MSIINSTALLCONTEXT_MACHINE
,
933 &prodkey
, FALSE
)) == ERROR_SUCCESS
)
935 context
= MSIINSTALLCONTEXT_MACHINE
;
938 MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
940 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_HELPLINKW
) ||
941 !lstrcmpW(szAttribute
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
942 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLDATEW
) ||
943 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
944 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
945 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
946 !lstrcmpW(szAttribute
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
947 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PUBLISHERW
) ||
948 !lstrcmpW(szAttribute
, INSTALLPROPERTY_URLINFOABOUTW
) ||
949 !lstrcmpW(szAttribute
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
950 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONMINORW
) ||
951 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONMAJORW
) ||
952 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
953 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTIDW
) ||
954 !lstrcmpW(szAttribute
, INSTALLPROPERTY_REGCOMPANYW
) ||
955 !lstrcmpW(szAttribute
, INSTALLPROPERTY_REGOWNERW
))
959 r
= ERROR_UNKNOWN_PRODUCT
;
964 return ERROR_UNKNOWN_PROPERTY
;
966 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
967 szAttribute
= display_name
;
968 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
969 szAttribute
= display_version
;
971 val
= msi_reg_get_value(userdata
, szAttribute
, &type
);
975 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTANCETYPEW
) ||
976 !lstrcmpW(szAttribute
, INSTALLPROPERTY_TRANSFORMSW
) ||
977 !lstrcmpW(szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
978 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
979 !lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
) ||
980 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
) ||
981 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONW
) ||
982 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTICONW
) ||
983 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
) ||
984 !lstrcmpW(szAttribute
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
988 r
= ERROR_UNKNOWN_PRODUCT
;
992 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
993 szAttribute
= assignment
;
995 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
))
997 res
= RegOpenKeyW(prodkey
, sourcelist
, &source
);
998 if (res
!= ERROR_SUCCESS
)
1000 r
= ERROR_UNKNOWN_PRODUCT
;
1004 val
= msi_reg_get_value(source
, szAttribute
, &type
);
1008 RegCloseKey(source
);
1012 val
= msi_reg_get_value(prodkey
, szAttribute
, &type
);
1017 if (val
!= empty
&& type
!= REG_DWORD
&&
1018 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
1020 if (lstrlenW(val
) != SQUISH_GUID_SIZE
- 1)
1024 unsquash_guid(val
, packagecode
);
1026 val
= strdupW(packagecode
);
1033 r
= ERROR_UNKNOWN_PROPERTY
;
1039 /* If szBuffer (szValue->str) is NULL, there's no need to copy the value
1040 * out. Also, *pcchValueBuf may be uninitialized in this case, so we
1041 * can't rely on its value.
1043 if (szValue
->str
.a
|| szValue
->str
.w
)
1045 DWORD size
= *pcchValueBuf
;
1046 if (strlenW(val
) < size
)
1047 r
= msi_strcpy_to_awstring(val
, szValue
, &size
);
1050 r
= ERROR_MORE_DATA
;
1055 *pcchValueBuf
= lstrlenW(val
);
1059 r
= ERROR_BAD_CONFIGURATION
;
1065 RegCloseKey(prodkey
);
1066 RegCloseKey(userdata
);
1070 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
1071 LPSTR szBuffer
, LPDWORD pcchValueBuf
)
1073 LPWSTR szwProduct
, szwAttribute
= NULL
;
1074 UINT r
= ERROR_OUTOFMEMORY
;
1077 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
1078 szBuffer
, pcchValueBuf
);
1080 szwProduct
= strdupAtoW( szProduct
);
1081 if( szProduct
&& !szwProduct
)
1084 szwAttribute
= strdupAtoW( szAttribute
);
1085 if( szAttribute
&& !szwAttribute
)
1088 buffer
.unicode
= FALSE
;
1089 buffer
.str
.a
= szBuffer
;
1091 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
1092 &buffer
, pcchValueBuf
);
1095 msi_free( szwProduct
);
1096 msi_free( szwAttribute
);
1101 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1102 LPWSTR szBuffer
, LPDWORD pcchValueBuf
)
1106 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
1107 szBuffer
, pcchValueBuf
);
1109 buffer
.unicode
= TRUE
;
1110 buffer
.str
.w
= szBuffer
;
1112 return MSI_GetProductInfo( szProduct
, szAttribute
,
1113 &buffer
, pcchValueBuf
);
1116 UINT WINAPI
MsiGetProductInfoExA(LPCSTR szProductCode
, LPCSTR szUserSid
,
1117 MSIINSTALLCONTEXT dwContext
, LPCSTR szProperty
,
1118 LPSTR szValue
, LPDWORD pcchValue
)
1120 LPWSTR product
= NULL
;
1121 LPWSTR usersid
= NULL
;
1122 LPWSTR property
= NULL
;
1123 LPWSTR value
= NULL
;
1127 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode
),
1128 debugstr_a(szUserSid
), dwContext
, debugstr_a(szProperty
),
1129 szValue
, pcchValue
);
1131 if (szValue
&& !pcchValue
)
1132 return ERROR_INVALID_PARAMETER
;
1134 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1135 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1136 if (szProperty
) property
= strdupAtoW(szProperty
);
1138 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1140 if (r
!= ERROR_SUCCESS
)
1143 value
= msi_alloc(++len
* sizeof(WCHAR
));
1146 r
= ERROR_OUTOFMEMORY
;
1150 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1152 if (r
!= ERROR_SUCCESS
)
1158 len
= WideCharToMultiByte(CP_ACP
, 0, value
, -1, NULL
, 0, NULL
, NULL
);
1159 if (*pcchValue
>= len
)
1160 WideCharToMultiByte(CP_ACP
, 0, value
, -1, szValue
, len
, NULL
, NULL
);
1163 r
= ERROR_MORE_DATA
;
1168 if (*pcchValue
<= len
|| !szValue
)
1169 len
= len
* sizeof(WCHAR
) - 1;
1171 *pcchValue
= len
- 1;
1182 static UINT
msi_copy_outval(LPWSTR val
, LPWSTR out
, LPDWORD size
)
1187 return ERROR_UNKNOWN_PROPERTY
;
1191 if (strlenW(val
) >= *size
)
1193 r
= ERROR_MORE_DATA
;
1202 *size
= lstrlenW(val
);
1204 return ERROR_SUCCESS
;
1207 UINT WINAPI
MsiGetProductInfoExW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1208 MSIINSTALLCONTEXT dwContext
, LPCWSTR szProperty
,
1209 LPWSTR szValue
, LPDWORD pcchValue
)
1211 WCHAR squished_pc
[GUID_SIZE
];
1213 LPCWSTR package
= NULL
;
1214 HKEY props
= NULL
, prod
;
1215 HKEY classes
= NULL
, managed
;
1218 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1220 static const WCHAR five
[] = {'5',0};
1221 static const WCHAR displayname
[] = {
1222 'D','i','s','p','l','a','y','N','a','m','e',0};
1223 static const WCHAR displayversion
[] = {
1224 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1225 static const WCHAR managed_local_package
[] = {
1226 'M','a','n','a','g','e','d','L','o','c','a','l',
1227 'P','a','c','k','a','g','e',0};
1229 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode
),
1230 debugstr_w(szUserSid
), dwContext
, debugstr_w(szProperty
),
1231 szValue
, pcchValue
);
1233 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1234 return ERROR_INVALID_PARAMETER
;
1236 if (szValue
&& !pcchValue
)
1237 return ERROR_INVALID_PARAMETER
;
1239 if (dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1240 dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1241 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1242 return ERROR_INVALID_PARAMETER
;
1244 if (!szProperty
|| !*szProperty
)
1245 return ERROR_INVALID_PARAMETER
;
1247 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1248 return ERROR_INVALID_PARAMETER
;
1250 /* FIXME: dwContext is provided, no need to search for it */
1251 MSIREG_OpenProductKey(szProductCode
, NULL
,MSIINSTALLCONTEXT_USERMANAGED
,
1253 MSIREG_OpenProductKey(szProductCode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1256 MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
, &props
, FALSE
);
1258 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1260 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1262 if (!props
&& !prod
)
1265 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1267 package
= managed_local_package
;
1269 if (!props
&& !managed
)
1272 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1274 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1275 MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
, &classes
, FALSE
);
1277 if (!props
&& !classes
)
1281 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_HELPLINKW
) ||
1282 !lstrcmpW(szProperty
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1283 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLDATEW
) ||
1284 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1285 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1286 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1287 !lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1288 !lstrcmpW(szProperty
, INSTALLPROPERTY_PUBLISHERW
) ||
1289 !lstrcmpW(szProperty
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1290 !lstrcmpW(szProperty
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1291 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONMINORW
) ||
1292 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1293 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1294 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTIDW
) ||
1295 !lstrcmpW(szProperty
, INSTALLPROPERTY_REGCOMPANYW
) ||
1296 !lstrcmpW(szProperty
, INSTALLPROPERTY_REGOWNERW
) ||
1297 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTANCETYPEW
))
1299 val
= msi_reg_get_value(props
, package
, &type
);
1302 if (prod
|| classes
)
1303 r
= ERROR_UNKNOWN_PROPERTY
;
1310 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1311 szProperty
= displayname
;
1312 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
))
1313 szProperty
= displayversion
;
1315 val
= msi_reg_get_value(props
, szProperty
, &type
);
1317 val
= strdupW(szEmpty
);
1319 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1321 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_TRANSFORMSW
) ||
1322 !lstrcmpW(szProperty
, INSTALLPROPERTY_LANGUAGEW
) ||
1323 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1324 !lstrcmpW(szProperty
, INSTALLPROPERTY_PACKAGECODEW
) ||
1325 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONW
) ||
1326 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTICONW
) ||
1327 !lstrcmpW(szProperty
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1328 !lstrcmpW(szProperty
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1330 if (!prod
&& !classes
)
1333 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1335 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1337 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1340 val
= msi_reg_get_value(hkey
, szProperty
, &type
);
1342 val
= strdupW(szEmpty
);
1344 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1346 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTSTATEW
))
1348 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1352 val
= msi_reg_get_value(props
, package
, &type
);
1357 val
= strdupW(five
);
1360 val
= strdupW(szOne
);
1362 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1365 else if (props
&& (val
= msi_reg_get_value(props
, package
, &type
)))
1368 val
= strdupW(five
);
1369 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1373 if (prod
|| managed
)
1374 val
= strdupW(szOne
);
1378 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1380 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1382 if (!prod
&& !classes
)
1386 val
= strdupW(szEmpty
);
1387 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1390 r
= ERROR_UNKNOWN_PROPERTY
;
1395 RegCloseKey(managed
);
1396 RegCloseKey(classes
);
1402 UINT WINAPI
MsiGetPatchInfoExA(LPCSTR szPatchCode
, LPCSTR szProductCode
,
1403 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1404 LPCSTR szProperty
, LPSTR lpValue
, DWORD
*pcchValue
)
1406 LPWSTR patch
= NULL
, product
= NULL
, usersid
= NULL
;
1407 LPWSTR property
= NULL
, val
= NULL
;
1411 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode
),
1412 debugstr_a(szProductCode
), debugstr_a(szUserSid
), dwContext
,
1413 debugstr_a(szProperty
), lpValue
, pcchValue
);
1415 if (lpValue
&& !pcchValue
)
1416 return ERROR_INVALID_PARAMETER
;
1418 if (szPatchCode
) patch
= strdupAtoW(szPatchCode
);
1419 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1420 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1421 if (szProperty
) property
= strdupAtoW(szProperty
);
1424 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1426 if (r
!= ERROR_SUCCESS
)
1429 val
= msi_alloc(++len
* sizeof(WCHAR
));
1432 r
= ERROR_OUTOFMEMORY
;
1436 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1438 if (r
!= ERROR_SUCCESS
|| !pcchValue
)
1442 WideCharToMultiByte(CP_ACP
, 0, val
, -1, lpValue
,
1443 *pcchValue
- 1, NULL
, NULL
);
1445 len
= lstrlenW(val
);
1446 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1450 r
= ERROR_MORE_DATA
;
1451 lpValue
[*pcchValue
- 1] = '\0';
1454 *pcchValue
= len
* sizeof(WCHAR
);
1469 UINT WINAPI
MsiGetPatchInfoExW(LPCWSTR szPatchCode
, LPCWSTR szProductCode
,
1470 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1471 LPCWSTR szProperty
, LPWSTR lpValue
, DWORD
*pcchValue
)
1473 WCHAR squished_pc
[GUID_SIZE
];
1474 WCHAR squished_patch
[GUID_SIZE
];
1475 HKEY udprod
= 0, prod
= 0, props
= 0;
1476 HKEY patch
= 0, patches
= 0;
1477 HKEY udpatch
= 0, datakey
= 0;
1478 HKEY prodpatches
= 0;
1480 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1484 static const WCHAR szManagedPackage
[] = {'M','a','n','a','g','e','d',
1485 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1487 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode
),
1488 debugstr_w(szProductCode
), debugstr_w(szUserSid
), dwContext
,
1489 debugstr_w(szProperty
), lpValue
, pcchValue
);
1491 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1492 return ERROR_INVALID_PARAMETER
;
1494 if (!szPatchCode
|| !squash_guid(szPatchCode
, squished_patch
))
1495 return ERROR_INVALID_PARAMETER
;
1498 return ERROR_INVALID_PARAMETER
;
1500 if (lpValue
&& !pcchValue
)
1501 return ERROR_INVALID_PARAMETER
;
1503 if (dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1504 dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1505 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1506 return ERROR_INVALID_PARAMETER
;
1508 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1509 return ERROR_INVALID_PARAMETER
;
1511 if (!lstrcmpW(szUserSid
, szLocalSid
))
1512 return ERROR_INVALID_PARAMETER
;
1514 if (MSIREG_OpenUserDataProductKey(szProductCode
, dwContext
, NULL
,
1515 &udprod
, FALSE
) != ERROR_SUCCESS
)
1518 if (MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
,
1519 &props
, FALSE
) != ERROR_SUCCESS
)
1522 r
= ERROR_UNKNOWN_PATCH
;
1524 res
= RegOpenKeyExW(udprod
, szPatches
, 0, KEY_READ
, &patches
);
1525 if (res
!= ERROR_SUCCESS
)
1528 res
= RegOpenKeyExW(patches
, squished_patch
, 0, KEY_READ
, &patch
);
1529 if (res
!= ERROR_SUCCESS
)
1532 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_TRANSFORMSW
))
1534 if (MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
,
1535 &prod
, FALSE
) != ERROR_SUCCESS
)
1538 res
= RegOpenKeyExW(prod
, szPatches
, 0, KEY_ALL_ACCESS
, &prodpatches
);
1539 if (res
!= ERROR_SUCCESS
)
1542 datakey
= prodpatches
;
1543 szProperty
= squished_patch
;
1547 if (MSIREG_OpenUserDataPatchKey(szPatchCode
, dwContext
,
1548 &udpatch
, FALSE
) != ERROR_SUCCESS
)
1551 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1553 if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1554 szProperty
= szManagedPackage
;
1557 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLDATEW
))
1560 szProperty
= szInstalled
;
1562 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1566 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_UNINSTALLABLEW
) ||
1567 !lstrcmpW(szProperty
, INSTALLPROPERTY_PATCHSTATEW
) ||
1568 !lstrcmpW(szProperty
, INSTALLPROPERTY_DISPLAYNAMEW
) ||
1569 !lstrcmpW(szProperty
, INSTALLPROPERTY_MOREINFOURLW
))
1575 r
= ERROR_UNKNOWN_PROPERTY
;
1580 val
= msi_reg_get_val_str(datakey
, szProperty
);
1582 val
= strdupW(szEmpty
);
1590 lstrcpynW(lpValue
, val
, *pcchValue
);
1592 len
= lstrlenW(val
);
1593 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1596 r
= ERROR_MORE_DATA
;
1598 *pcchValue
= len
* sizeof(WCHAR
);
1605 RegCloseKey(prodpatches
);
1608 RegCloseKey(patches
);
1609 RegCloseKey(udpatch
);
1611 RegCloseKey(udprod
);
1616 UINT WINAPI
MsiGetPatchInfoA( LPCSTR patch
, LPCSTR attr
, LPSTR buffer
, LPDWORD buflen
)
1618 UINT r
= ERROR_OUTOFMEMORY
;
1620 LPWSTR patchW
= NULL
, attrW
= NULL
, bufferW
= NULL
;
1622 TRACE("%s %s %p %p\n", debugstr_a(patch
), debugstr_a(attr
), buffer
, buflen
);
1624 if (!patch
|| !attr
)
1625 return ERROR_INVALID_PARAMETER
;
1627 if (!(patchW
= strdupAtoW( patch
)))
1630 if (!(attrW
= strdupAtoW( attr
)))
1634 r
= MsiGetPatchInfoW( patchW
, attrW
, NULL
, &size
);
1635 if (r
!= ERROR_SUCCESS
)
1639 if (!(bufferW
= msi_alloc( size
* sizeof(WCHAR
) )))
1641 r
= ERROR_OUTOFMEMORY
;
1645 r
= MsiGetPatchInfoW( patchW
, attrW
, bufferW
, &size
);
1646 if (r
== ERROR_SUCCESS
)
1648 int len
= WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, NULL
, 0, NULL
, NULL
);
1650 r
= ERROR_MORE_DATA
;
1652 WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, buffer
, *buflen
, NULL
, NULL
);
1660 msi_free( bufferW
);
1664 UINT WINAPI
MsiGetPatchInfoW( LPCWSTR patch
, LPCWSTR attr
, LPWSTR buffer
, LPDWORD buflen
)
1667 WCHAR product
[GUID_SIZE
];
1670 TRACE("%s %s %p %p\n", debugstr_w(patch
), debugstr_w(attr
), buffer
, buflen
);
1672 if (!patch
|| !attr
)
1673 return ERROR_INVALID_PARAMETER
;
1675 if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW
, attr
))
1676 return ERROR_UNKNOWN_PROPERTY
;
1681 r
= MsiEnumProductsW( index
, product
);
1682 if (r
!= ERROR_SUCCESS
)
1685 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, attr
, buffer
, buflen
);
1686 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1689 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, attr
, buffer
, buflen
);
1690 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1693 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_MACHINE
, attr
, buffer
, buflen
);
1694 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1700 return ERROR_UNKNOWN_PRODUCT
;
1703 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
1705 LPWSTR szwLogFile
= NULL
;
1708 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
1712 szwLogFile
= strdupAtoW( szLogFile
);
1714 return ERROR_OUTOFMEMORY
;
1716 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
1717 msi_free( szwLogFile
);
1721 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
1723 HANDLE file
= INVALID_HANDLE_VALUE
;
1725 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
1729 lstrcpyW(gszLogFile
,szLogFile
);
1730 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
1731 DeleteFileW(szLogFile
);
1732 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, 0, NULL
, OPEN_ALWAYS
,
1733 FILE_ATTRIBUTE_NORMAL
, NULL
);
1734 if (file
!= INVALID_HANDLE_VALUE
)
1737 ERR("Unable to enable log %s\n",debugstr_w(szLogFile
));
1740 gszLogFile
[0] = '\0';
1742 return ERROR_SUCCESS
;
1745 UINT WINAPI
MsiEnumComponentCostsW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
1746 DWORD dwIndex
, INSTALLSTATE iState
,
1747 LPWSTR lpDriveBuf
, DWORD
*pcchDriveBuf
,
1748 int *piCost
, int *pTempCost
)
1750 FIXME("(%d, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall
,
1751 debugstr_w(szComponent
), dwIndex
, iState
, lpDriveBuf
,
1752 pcchDriveBuf
, piCost
, pTempCost
);
1754 return ERROR_NO_MORE_ITEMS
;
1757 UINT WINAPI
MsiQueryComponentStateA(LPCSTR szProductCode
,
1758 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1759 LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
1761 LPWSTR prodcode
= NULL
, usersid
= NULL
, comp
= NULL
;
1764 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode
),
1765 debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
1767 if (szProductCode
&& !(prodcode
= strdupAtoW(szProductCode
)))
1768 return ERROR_OUTOFMEMORY
;
1770 if (szUserSid
&& !(usersid
= strdupAtoW(szUserSid
)))
1771 return ERROR_OUTOFMEMORY
;
1773 if (szComponent
&& !(comp
= strdupAtoW(szComponent
)))
1774 return ERROR_OUTOFMEMORY
;
1776 r
= MsiQueryComponentStateW(prodcode
, usersid
, dwContext
, comp
, pdwState
);
1785 static BOOL
msi_comp_find_prod_key(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
1790 r
= MSIREG_OpenProductKey(prodcode
, NULL
, context
, &hkey
, FALSE
);
1792 return (r
== ERROR_SUCCESS
);
1795 static BOOL
msi_comp_find_package(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
1803 static const WCHAR local_package
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
1804 static const WCHAR managed_local_package
[] = {
1805 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
1808 r
= MSIREG_OpenInstallProps(prodcode
, context
, NULL
, &hkey
, FALSE
);
1809 if (r
!= ERROR_SUCCESS
)
1812 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
1813 package
= managed_local_package
;
1815 package
= local_package
;
1818 res
= RegQueryValueExW(hkey
, package
, NULL
, NULL
, NULL
, &sz
);
1821 return (res
== ERROR_SUCCESS
);
1824 static BOOL
msi_comp_find_prodcode(LPWSTR squished_pc
,
1825 MSIINSTALLCONTEXT context
,
1826 LPCWSTR comp
, LPWSTR val
, DWORD
*sz
)
1832 if (context
== MSIINSTALLCONTEXT_MACHINE
)
1833 r
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
1835 r
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
1837 if (r
!= ERROR_SUCCESS
)
1840 res
= RegQueryValueExW(hkey
, squished_pc
, NULL
, NULL
, (BYTE
*)val
, sz
);
1841 if (res
!= ERROR_SUCCESS
)
1848 UINT WINAPI
MsiQueryComponentStateW(LPCWSTR szProductCode
,
1849 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1850 LPCWSTR szComponent
, INSTALLSTATE
*pdwState
)
1852 WCHAR squished_pc
[GUID_SIZE
];
1853 WCHAR val
[MAX_PATH
];
1857 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode
),
1858 debugstr_w(szUserSid
), dwContext
, debugstr_w(szComponent
), pdwState
);
1860 if (!pdwState
|| !szComponent
)
1861 return ERROR_INVALID_PARAMETER
;
1863 if (!szProductCode
|| !*szProductCode
|| lstrlenW(szProductCode
) != GUID_SIZE
- 1)
1864 return ERROR_INVALID_PARAMETER
;
1866 if (!squash_guid(szProductCode
, squished_pc
))
1867 return ERROR_INVALID_PARAMETER
;
1869 found
= msi_comp_find_prod_key(szProductCode
, dwContext
);
1871 if (!msi_comp_find_package(szProductCode
, dwContext
))
1875 *pdwState
= INSTALLSTATE_UNKNOWN
;
1876 return ERROR_UNKNOWN_COMPONENT
;
1879 return ERROR_UNKNOWN_PRODUCT
;
1882 *pdwState
= INSTALLSTATE_UNKNOWN
;
1885 if (!msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, val
, &sz
))
1886 return ERROR_UNKNOWN_COMPONENT
;
1889 *pdwState
= INSTALLSTATE_NOTUSED
;
1892 if (lstrlenW(val
) > 2 &&
1893 val
[0] >= '0' && val
[0] <= '9' && val
[1] >= '0' && val
[1] <= '9')
1895 *pdwState
= INSTALLSTATE_SOURCE
;
1898 *pdwState
= INSTALLSTATE_LOCAL
;
1901 return ERROR_SUCCESS
;
1904 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
1906 LPWSTR szwProduct
= NULL
;
1911 szwProduct
= strdupAtoW( szProduct
);
1913 return ERROR_OUTOFMEMORY
;
1915 r
= MsiQueryProductStateW( szwProduct
);
1916 msi_free( szwProduct
);
1920 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
1922 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
1923 INSTALLSTATE state
= INSTALLSTATE_ADVERTISED
;
1924 HKEY prodkey
= 0, userdata
= 0;
1928 static const WCHAR szWindowsInstaller
[] = {
1929 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1931 TRACE("%s\n", debugstr_w(szProduct
));
1933 if (!szProduct
|| !*szProduct
)
1934 return INSTALLSTATE_INVALIDARG
;
1936 if (lstrlenW(szProduct
) != GUID_SIZE
- 1)
1937 return INSTALLSTATE_INVALIDARG
;
1939 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1940 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
1941 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1942 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
1943 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
1944 &prodkey
, FALSE
) == ERROR_SUCCESS
)
1946 context
= MSIINSTALLCONTEXT_MACHINE
;
1949 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
1950 if (r
!= ERROR_SUCCESS
)
1953 if (!msi_reg_get_val_dword(userdata
, szWindowsInstaller
, &val
))
1957 state
= INSTALLSTATE_DEFAULT
;
1959 state
= INSTALLSTATE_UNKNOWN
;
1964 state
= INSTALLSTATE_UNKNOWN
;
1967 state
= INSTALLSTATE_ABSENT
;
1970 RegCloseKey(prodkey
);
1971 RegCloseKey(userdata
);
1975 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
1977 INSTALLUILEVEL old
= gUILevel
;
1978 HWND oldwnd
= gUIhwnd
;
1980 TRACE("%08x %p\n", dwUILevel
, phWnd
);
1982 gUILevel
= dwUILevel
;
1991 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
1992 DWORD dwMessageFilter
, LPVOID pvContext
)
1994 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
1996 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
1998 gUIHandlerA
= puiHandler
;
2000 gUIFilter
= dwMessageFilter
;
2001 gUIContext
= pvContext
;
2006 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
2007 DWORD dwMessageFilter
, LPVOID pvContext
)
2009 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
2011 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2014 gUIHandlerW
= puiHandler
;
2015 gUIFilter
= dwMessageFilter
;
2016 gUIContext
= pvContext
;
2021 /******************************************************************
2022 * MsiLoadStringW [MSI.@]
2024 * Loads a string from MSI's string resources.
2028 * handle [I] only -1 is handled currently
2029 * id [I] id of the string to be loaded
2030 * lpBuffer [O] buffer for the string to be written to
2031 * nBufferMax [I] maximum size of the buffer in characters
2032 * lang [I] the preferred language for the string
2036 * If successful, this function returns the language id of the string loaded
2037 * If the function fails, the function returns zero.
2041 * The type of the first parameter is unknown. LoadString's prototype
2042 * suggests that it might be a module handle. I have made it an MSI handle
2043 * for starters, as -1 is an invalid MSI handle, but not an invalid module
2044 * handle. Maybe strings can be stored in an MSI database somehow.
2046 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
2047 int nBufferMax
, LANGID lang
)
2054 TRACE("%d %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
2057 FIXME("don't know how to deal with handle = %08x\n", handle
);
2060 lang
= GetUserDefaultLangID();
2062 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
2066 hResData
= LoadResource( msi_hInstance
, hres
);
2069 p
= LockResource( hResData
);
2073 for (i
= 0; i
< (id
&0xf); i
++)
2077 if( nBufferMax
<= len
)
2080 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
2081 lpBuffer
[ len
] = 0;
2083 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
2088 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
2089 int nBufferMax
, LANGID lang
)
2095 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
2096 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
2099 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
2100 if( len
<= nBufferMax
)
2101 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
2102 lpBuffer
, nBufferMax
, NULL
, NULL
);
2110 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
2113 char szProduct
[GUID_SIZE
];
2115 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2117 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
2118 return INSTALLSTATE_UNKNOWN
;
2120 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2123 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
2126 WCHAR szProduct
[GUID_SIZE
];
2128 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2130 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
2131 return INSTALLSTATE_UNKNOWN
;
2133 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2136 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2137 WORD wLanguageId
, DWORD f
)
2139 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
2140 uType
, wLanguageId
, f
);
2141 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2144 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2145 WORD wLanguageId
, DWORD f
)
2147 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
2148 uType
, wLanguageId
, f
);
2149 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2152 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
2153 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
2154 LPDWORD pcchPathBuf
)
2156 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
2157 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2159 return ERROR_CALL_NOT_IMPLEMENTED
;
2162 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
2163 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
2164 LPDWORD pcchPathBuf
)
2166 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
2167 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2169 return ERROR_CALL_NOT_IMPLEMENTED
;
2172 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
2173 LPSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2175 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2176 return ERROR_CALL_NOT_IMPLEMENTED
;
2179 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
2180 LPWSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2182 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2183 return ERROR_CALL_NOT_IMPLEMENTED
;
2186 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
2187 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
2188 LPDWORD pcbHashData
)
2190 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
2191 ppcCertContext
, pbHashData
, pcbHashData
);
2192 return ERROR_CALL_NOT_IMPLEMENTED
;
2195 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
2196 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
2197 LPDWORD pcbHashData
)
2199 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
2200 ppcCertContext
, pbHashData
, pcbHashData
);
2201 return ERROR_CALL_NOT_IMPLEMENTED
;
2204 /******************************************************************
2205 * MsiGetProductPropertyA [MSI.@]
2207 UINT WINAPI
MsiGetProductPropertyA(MSIHANDLE hProduct
, LPCSTR szProperty
,
2208 LPSTR szValue
, LPDWORD pccbValue
)
2210 LPWSTR prop
= NULL
, val
= NULL
;
2214 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_a(szProperty
),
2215 szValue
, pccbValue
);
2217 if (szValue
&& !pccbValue
)
2218 return ERROR_INVALID_PARAMETER
;
2220 if (szProperty
) prop
= strdupAtoW(szProperty
);
2223 r
= MsiGetProductPropertyW(hProduct
, prop
, NULL
, &len
);
2224 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2227 if (r
== ERROR_SUCCESS
)
2229 if (szValue
) *szValue
= '\0';
2230 if (pccbValue
) *pccbValue
= 0;
2234 val
= msi_alloc(++len
* sizeof(WCHAR
));
2237 r
= ERROR_OUTOFMEMORY
;
2241 r
= MsiGetProductPropertyW(hProduct
, prop
, val
, &len
);
2242 if (r
!= ERROR_SUCCESS
)
2245 len
= WideCharToMultiByte(CP_ACP
, 0, val
, -1, NULL
, 0, NULL
, NULL
);
2248 WideCharToMultiByte(CP_ACP
, 0, val
, -1, szValue
,
2249 *pccbValue
, NULL
, NULL
);
2253 if (len
> *pccbValue
)
2254 r
= ERROR_MORE_DATA
;
2256 *pccbValue
= len
- 1;
2266 /******************************************************************
2267 * MsiGetProductPropertyW [MSI.@]
2269 UINT WINAPI
MsiGetProductPropertyW(MSIHANDLE hProduct
, LPCWSTR szProperty
,
2270 LPWSTR szValue
, LPDWORD pccbValue
)
2272 MSIPACKAGE
*package
;
2273 MSIQUERY
*view
= NULL
;
2274 MSIRECORD
*rec
= NULL
;
2278 static const WCHAR query
[] = {
2279 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2280 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2281 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2283 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_w(szProperty
),
2284 szValue
, pccbValue
);
2287 return ERROR_INVALID_PARAMETER
;
2289 if (szValue
&& !pccbValue
)
2290 return ERROR_INVALID_PARAMETER
;
2292 package
= msihandle2msiinfo(hProduct
, MSIHANDLETYPE_PACKAGE
);
2294 return ERROR_INVALID_HANDLE
;
2296 r
= MSI_OpenQuery(package
->db
, &view
, query
, szProperty
);
2297 if (r
!= ERROR_SUCCESS
)
2300 r
= MSI_ViewExecute(view
, 0);
2301 if (r
!= ERROR_SUCCESS
)
2304 r
= MSI_ViewFetch(view
, &rec
);
2305 if (r
!= ERROR_SUCCESS
)
2308 val
= MSI_RecordGetString(rec
, 2);
2312 if (lstrlenW(val
) >= *pccbValue
)
2314 lstrcpynW(szValue
, val
, *pccbValue
);
2315 *pccbValue
= lstrlenW(val
);
2316 r
= ERROR_MORE_DATA
;
2320 lstrcpyW(szValue
, val
);
2321 *pccbValue
= lstrlenW(val
);
2328 MSI_ViewClose(view
);
2329 msiobj_release(&view
->hdr
);
2330 if (rec
) msiobj_release(&rec
->hdr
);
2335 if (szValue
) *szValue
= '\0';
2336 if (pccbValue
) *pccbValue
= 0;
2343 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
2346 LPWSTR szPack
= NULL
;
2348 TRACE("%s\n", debugstr_a(szPackage
) );
2352 szPack
= strdupAtoW( szPackage
);
2354 return ERROR_OUTOFMEMORY
;
2357 r
= MsiVerifyPackageW( szPack
);
2364 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
2369 TRACE("%s\n", debugstr_w(szPackage
) );
2371 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
2372 MsiCloseHandle( handle
);
2377 static INSTALLSTATE
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
2378 awstring
* lpPathBuf
, LPDWORD pcchBuf
)
2380 WCHAR squished_pc
[GUID_SIZE
];
2381 WCHAR squished_comp
[GUID_SIZE
];
2387 static const WCHAR wininstaller
[] = {
2388 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2390 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
2391 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
2393 if (!szProduct
|| !szComponent
)
2394 return INSTALLSTATE_INVALIDARG
;
2396 if (lpPathBuf
->str
.w
&& !pcchBuf
)
2397 return INSTALLSTATE_INVALIDARG
;
2399 if (!squash_guid(szProduct
, squished_pc
) ||
2400 !squash_guid(szComponent
, squished_comp
))
2401 return INSTALLSTATE_INVALIDARG
;
2403 state
= INSTALLSTATE_UNKNOWN
;
2405 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2406 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2408 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2411 state
= INSTALLSTATE_ABSENT
;
2413 if ((MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
, NULL
,
2414 &hkey
, FALSE
) == ERROR_SUCCESS
||
2415 MSIREG_OpenUserDataProductKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2416 NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
) &&
2417 msi_reg_get_val_dword(hkey
, wininstaller
, &version
) &&
2418 GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2421 state
= INSTALLSTATE_LOCAL
;
2425 if (state
!= INSTALLSTATE_LOCAL
&&
2426 (MSIREG_OpenProductKey(szProduct
, NULL
,
2427 MSIINSTALLCONTEXT_USERUNMANAGED
,
2428 &hkey
, FALSE
) == ERROR_SUCCESS
||
2429 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2430 &hkey
, FALSE
) == ERROR_SUCCESS
))
2434 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2435 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2438 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2441 state
= INSTALLSTATE_ABSENT
;
2443 if (GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2444 state
= INSTALLSTATE_LOCAL
;
2449 return INSTALLSTATE_UNKNOWN
;
2451 if (state
== INSTALLSTATE_LOCAL
&& !*path
)
2452 state
= INSTALLSTATE_NOTUSED
;
2454 msi_strcpy_to_awstring(path
, lpPathBuf
, pcchBuf
);
2459 /******************************************************************
2460 * MsiGetComponentPathW [MSI.@]
2462 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
2463 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
2467 path
.unicode
= TRUE
;
2468 path
.str
.w
= lpPathBuf
;
2470 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
2473 /******************************************************************
2474 * MsiGetComponentPathA [MSI.@]
2476 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
2477 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
2479 LPWSTR szwProduct
, szwComponent
= NULL
;
2480 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
2483 szwProduct
= strdupAtoW( szProduct
);
2484 if( szProduct
&& !szwProduct
)
2487 szwComponent
= strdupAtoW( szComponent
);
2488 if( szComponent
&& !szwComponent
)
2491 path
.unicode
= FALSE
;
2492 path
.str
.a
= lpPathBuf
;
2494 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
2497 msi_free( szwProduct
);
2498 msi_free( szwComponent
);
2503 /******************************************************************
2504 * MsiQueryFeatureStateA [MSI.@]
2506 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
2508 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
2509 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
2511 szwProduct
= strdupAtoW( szProduct
);
2512 if ( szProduct
&& !szwProduct
)
2515 szwFeature
= strdupAtoW( szFeature
);
2516 if ( szFeature
&& !szwFeature
)
2519 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
2522 msi_free( szwProduct
);
2523 msi_free( szwFeature
);
2528 /******************************************************************
2529 * MsiQueryFeatureStateW [MSI.@]
2531 * Checks the state of a feature
2534 * szProduct [I] Product's GUID string
2535 * szFeature [I] Feature's GUID string
2538 * INSTALLSTATE_LOCAL Feature is installed and usable
2539 * INSTALLSTATE_ABSENT Feature is absent
2540 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
2541 * INSTALLSTATE_UNKNOWN An error occurred
2542 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
2545 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
2547 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
2549 LPWSTR components
, p
, parent_feature
, path
;
2553 BOOL missing
= FALSE
;
2554 BOOL machine
= FALSE
;
2555 BOOL source
= FALSE
;
2557 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
2559 if (!szProduct
|| !szFeature
)
2560 return INSTALLSTATE_INVALIDARG
;
2562 if (!squash_guid( szProduct
, squishProduct
))
2563 return INSTALLSTATE_INVALIDARG
;
2565 if (MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERMANAGED
,
2566 &hkey
, FALSE
) != ERROR_SUCCESS
&&
2567 MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2568 &hkey
, FALSE
) != ERROR_SUCCESS
)
2570 rc
= MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
2572 if (rc
!= ERROR_SUCCESS
)
2573 return INSTALLSTATE_UNKNOWN
;
2578 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
2581 if (!parent_feature
)
2582 return INSTALLSTATE_UNKNOWN
;
2584 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
2585 msi_free(parent_feature
);
2586 if (r
== INSTALLSTATE_ABSENT
)
2590 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
2591 MSIINSTALLCONTEXT_MACHINE
,
2594 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
2595 MSIINSTALLCONTEXT_USERUNMANAGED
,
2598 if (rc
!= ERROR_SUCCESS
)
2599 return INSTALLSTATE_ADVERTISED
;
2601 components
= msi_reg_get_val_str( hkey
, szFeature
);
2604 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
2607 return INSTALLSTATE_ADVERTISED
;
2609 for( p
= components
; *p
&& *p
!= 2 ; p
+= 20)
2611 if (!decode_base85_guid( p
, &guid
))
2613 if (p
!= components
)
2616 msi_free(components
);
2617 return INSTALLSTATE_BADCONFIG
;
2620 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
2623 rc
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
2625 rc
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
2627 if (rc
!= ERROR_SUCCESS
)
2629 msi_free(components
);
2630 return INSTALLSTATE_ADVERTISED
;
2633 path
= msi_reg_get_val_str(hkey
, squishProduct
);
2636 else if (lstrlenW(path
) > 2 &&
2637 path
[0] >= '0' && path
[0] <= '9' &&
2638 path
[1] >= '0' && path
[1] <= '9')
2646 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
2647 msi_free(components
);
2650 return INSTALLSTATE_ADVERTISED
;
2653 return INSTALLSTATE_SOURCE
;
2655 return INSTALLSTATE_LOCAL
;
2658 /******************************************************************
2659 * MsiGetFileVersionA [MSI.@]
2661 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
2662 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
2664 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
2665 UINT ret
= ERROR_OUTOFMEMORY
;
2667 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
2668 (lpLangBuf
&& !pcchLangBuf
))
2669 return ERROR_INVALID_PARAMETER
;
2673 szwFilePath
= strdupAtoW( szFilePath
);
2678 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
2680 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
2681 if( !lpwVersionBuff
)
2685 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
2687 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
2692 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
2693 lpwLangBuff
, pcchLangBuf
);
2695 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
2696 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
2697 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
2698 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
2699 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
2700 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
2703 msi_free(szwFilePath
);
2704 msi_free(lpwVersionBuff
);
2705 msi_free(lpwLangBuff
);
2710 /******************************************************************
2711 * MsiGetFileVersionW [MSI.@]
2713 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
2714 LPDWORD pcchVersionBuf
, LPWSTR lpLangBuf
, LPDWORD pcchLangBuf
)
2716 static const WCHAR szVersionResource
[] = {'\\',0};
2717 static const WCHAR szVersionFormat
[] = {
2718 '%','d','.','%','d','.','%','d','.','%','d',0};
2719 static const WCHAR szLangResource
[] = {
2720 '\\','V','a','r','F','i','l','e','I','n','f','o','\\',
2721 'T','r','a','n','s','l','a','t','i','o','n',0};
2722 static const WCHAR szLangFormat
[] = {'%','d',0};
2724 DWORD dwVerLen
, gle
;
2725 LPVOID lpVer
= NULL
;
2726 VS_FIXEDFILEINFO
*ffi
;
2731 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath
),
2732 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
2733 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
2735 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
2736 (lpLangBuf
&& !pcchLangBuf
))
2737 return ERROR_INVALID_PARAMETER
;
2739 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
2742 gle
= GetLastError();
2743 if (gle
== ERROR_BAD_PATHNAME
)
2744 return ERROR_FILE_NOT_FOUND
;
2745 else if (gle
== ERROR_RESOURCE_DATA_NOT_FOUND
)
2746 return ERROR_FILE_INVALID
;
2751 lpVer
= msi_alloc(dwVerLen
);
2754 ret
= ERROR_OUTOFMEMORY
;
2758 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
2760 ret
= GetLastError();
2766 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
2769 wsprintfW(tmp
, szVersionFormat
,
2770 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
2771 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
2772 if (lpVersionBuf
) lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
2774 if (strlenW(tmp
) >= *pcchVersionBuf
)
2775 ret
= ERROR_MORE_DATA
;
2777 *pcchVersionBuf
= lstrlenW(tmp
);
2781 if (lpVersionBuf
) *lpVersionBuf
= 0;
2782 *pcchVersionBuf
= 0;
2788 if (VerQueryValueW(lpVer
, szLangResource
, (LPVOID
*)&lang
, &puLen
) &&
2791 wsprintfW(tmp
, szLangFormat
, *lang
);
2792 if (lpLangBuf
) lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
2794 if (strlenW(tmp
) >= *pcchLangBuf
)
2795 ret
= ERROR_MORE_DATA
;
2797 *pcchLangBuf
= lstrlenW(tmp
);
2801 if (lpLangBuf
) *lpLangBuf
= 0;
2811 /***********************************************************************
2812 * MsiGetFeatureUsageW [MSI.@]
2814 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2815 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
2817 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
2818 pdwUseCount
, pwDateUsed
);
2819 return ERROR_CALL_NOT_IMPLEMENTED
;
2822 /***********************************************************************
2823 * MsiGetFeatureUsageA [MSI.@]
2825 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
2826 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
2828 LPWSTR prod
= NULL
, feat
= NULL
;
2829 UINT ret
= ERROR_OUTOFMEMORY
;
2831 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2832 pdwUseCount
, pwDateUsed
);
2834 prod
= strdupAtoW( szProduct
);
2835 if (szProduct
&& !prod
)
2838 feat
= strdupAtoW( szFeature
);
2839 if (szFeature
&& !feat
)
2842 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
2851 /***********************************************************************
2852 * MsiUseFeatureExW [MSI.@]
2854 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2855 DWORD dwInstallMode
, DWORD dwReserved
)
2859 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
2860 dwInstallMode
, dwReserved
);
2862 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
2865 return INSTALLSTATE_INVALIDARG
;
2867 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
2869 FIXME("mark product %s feature %s as used\n",
2870 debugstr_w(szProduct
), debugstr_w(szFeature
) );
2876 /***********************************************************************
2877 * MsiUseFeatureExA [MSI.@]
2879 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
2880 DWORD dwInstallMode
, DWORD dwReserved
)
2882 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
2883 LPWSTR prod
= NULL
, feat
= NULL
;
2885 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2886 dwInstallMode
, dwReserved
);
2888 prod
= strdupAtoW( szProduct
);
2889 if (szProduct
&& !prod
)
2892 feat
= strdupAtoW( szFeature
);
2893 if (szFeature
&& !feat
)
2896 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
2905 /***********************************************************************
2906 * MsiUseFeatureW [MSI.@]
2908 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
2910 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
2913 /***********************************************************************
2914 * MsiUseFeatureA [MSI.@]
2916 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
2918 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
2921 /***********************************************************************
2922 * MSI_ProvideQualifiedComponentEx [internal]
2924 static UINT
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
2925 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
2926 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
2927 LPDWORD pcchPathBuf
)
2929 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
2930 feature
[MAX_FEATURE_CHARS
+1];
2936 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent
),
2937 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
2938 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
2940 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
2941 if (rc
!= ERROR_SUCCESS
)
2942 return ERROR_INDEX_ABSENT
;
2944 info
= msi_reg_get_val_str( hkey
, szQualifier
);
2948 return ERROR_INDEX_ABSENT
;
2950 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
2953 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
2955 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
2959 if (rc
!= INSTALLSTATE_LOCAL
)
2960 return ERROR_FILE_NOT_FOUND
;
2962 return ERROR_SUCCESS
;
2965 /***********************************************************************
2966 * MsiProvideQualifiedComponentExW [MSI.@]
2968 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
2969 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
2970 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
2971 LPDWORD pcchPathBuf
)
2975 path
.unicode
= TRUE
;
2976 path
.str
.w
= lpPathBuf
;
2978 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
2979 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
2982 /***********************************************************************
2983 * MsiProvideQualifiedComponentExA [MSI.@]
2985 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
2986 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
2987 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
2988 LPDWORD pcchPathBuf
)
2990 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
2991 UINT r
= ERROR_OUTOFMEMORY
;
2994 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
2995 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
2996 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
2998 szwComponent
= strdupAtoW( szComponent
);
2999 if (szComponent
&& !szwComponent
)
3002 szwQualifier
= strdupAtoW( szQualifier
);
3003 if (szQualifier
&& !szwQualifier
)
3006 szwProduct
= strdupAtoW( szProduct
);
3007 if (szProduct
&& !szwProduct
)
3010 path
.unicode
= FALSE
;
3011 path
.str
.a
= lpPathBuf
;
3013 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
3014 dwInstallMode
, szwProduct
, Unused1
,
3015 Unused2
, &path
, pcchPathBuf
);
3017 msi_free(szwProduct
);
3018 msi_free(szwComponent
);
3019 msi_free(szwQualifier
);
3024 /***********************************************************************
3025 * MsiProvideQualifiedComponentW [MSI.@]
3027 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
3028 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
3029 LPDWORD pcchPathBuf
)
3031 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
3032 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3035 /***********************************************************************
3036 * MsiProvideQualifiedComponentA [MSI.@]
3038 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
3039 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
3040 LPDWORD pcchPathBuf
)
3042 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
3043 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3046 /***********************************************************************
3047 * MSI_GetUserInfo [internal]
3049 static USERINFOSTATE
MSI_GetUserInfo(LPCWSTR szProduct
,
3050 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3051 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3052 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
3054 WCHAR squished_pc
[SQUISH_GUID_SIZE
];
3055 LPWSTR user
, org
, serial
;
3056 USERINFOSTATE state
;
3061 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct
), lpUserNameBuf
,
3062 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
3065 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
3066 return USERINFOSTATE_INVALIDARG
;
3068 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
3069 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3070 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3071 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3072 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3073 &hkey
, FALSE
) != ERROR_SUCCESS
)
3075 return USERINFOSTATE_UNKNOWN
;
3078 if (MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3079 NULL
, &props
, FALSE
) != ERROR_SUCCESS
&&
3080 MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
3081 NULL
, &props
, FALSE
) != ERROR_SUCCESS
)
3084 return USERINFOSTATE_ABSENT
;
3087 user
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGOWNERW
);
3088 org
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGCOMPANYW
);
3089 serial
= msi_reg_get_val_str(props
, INSTALLPROPERTY_PRODUCTIDW
);
3090 state
= USERINFOSTATE_ABSENT
;
3096 state
= USERINFOSTATE_PRESENT
;
3098 if (pcchUserNameBuf
)
3100 if (lpUserNameBuf
&& !user
)
3102 (*pcchUserNameBuf
)--;
3106 r
= msi_strcpy_to_awstring(user
, lpUserNameBuf
, pcchUserNameBuf
);
3107 if (r
== ERROR_MORE_DATA
)
3109 state
= USERINFOSTATE_MOREDATA
;
3117 if (!orgptr
) orgptr
= szEmpty
;
3119 r
= msi_strcpy_to_awstring(orgptr
, lpOrgNameBuf
, pcchOrgNameBuf
);
3120 if (r
== ERROR_MORE_DATA
)
3122 state
= USERINFOSTATE_MOREDATA
;
3135 r
= msi_strcpy_to_awstring(serial
, lpSerialBuf
, pcchSerialBuf
);
3136 if (r
== ERROR_MORE_DATA
)
3137 state
= USERINFOSTATE_MOREDATA
;
3148 /***********************************************************************
3149 * MsiGetUserInfoW [MSI.@]
3151 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
3152 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3153 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3154 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3156 awstring user
, org
, serial
;
3158 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3159 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3160 (lpSerialBuf
&& !pcchSerialBuf
))
3161 return USERINFOSTATE_INVALIDARG
;
3163 user
.unicode
= TRUE
;
3164 user
.str
.w
= lpUserNameBuf
;
3166 org
.str
.w
= lpOrgNameBuf
;
3167 serial
.unicode
= TRUE
;
3168 serial
.str
.w
= lpSerialBuf
;
3170 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
3171 &org
, pcchOrgNameBuf
,
3172 &serial
, pcchSerialBuf
);
3175 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
3176 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3177 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3178 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3180 awstring user
, org
, serial
;
3184 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3185 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3186 (lpSerialBuf
&& !pcchSerialBuf
))
3187 return USERINFOSTATE_INVALIDARG
;
3189 prod
= strdupAtoW( szProduct
);
3190 if (szProduct
&& !prod
)
3191 return ERROR_OUTOFMEMORY
;
3193 user
.unicode
= FALSE
;
3194 user
.str
.a
= lpUserNameBuf
;
3195 org
.unicode
= FALSE
;
3196 org
.str
.a
= lpOrgNameBuf
;
3197 serial
.unicode
= FALSE
;
3198 serial
.str
.a
= lpSerialBuf
;
3200 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
3201 &org
, pcchOrgNameBuf
,
3202 &serial
, pcchSerialBuf
);
3209 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
3213 MSIPACKAGE
*package
;
3214 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3216 TRACE("(%s)\n",debugstr_w(szProduct
));
3218 rc
= MsiOpenProductW(szProduct
,&handle
);
3219 if (rc
!= ERROR_SUCCESS
)
3220 return ERROR_INVALID_PARAMETER
;
3222 /* MsiCollectUserInfo cannot be called from a custom action. */
3223 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3225 return ERROR_CALL_NOT_IMPLEMENTED
;
3227 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
3228 msiobj_release( &package
->hdr
);
3230 MsiCloseHandle(handle
);
3235 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
3239 MSIPACKAGE
*package
;
3240 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3242 TRACE("(%s)\n",debugstr_a(szProduct
));
3244 rc
= MsiOpenProductA(szProduct
,&handle
);
3245 if (rc
!= ERROR_SUCCESS
)
3246 return ERROR_INVALID_PARAMETER
;
3248 /* MsiCollectUserInfo cannot be called from a custom action. */
3249 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3251 return ERROR_CALL_NOT_IMPLEMENTED
;
3253 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
3254 msiobj_release( &package
->hdr
);
3256 MsiCloseHandle(handle
);
3261 /***********************************************************************
3262 * MsiConfigureFeatureA [MSI.@]
3264 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
3266 LPWSTR prod
, feat
= NULL
;
3267 UINT r
= ERROR_OUTOFMEMORY
;
3269 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
3271 prod
= strdupAtoW( szProduct
);
3272 if (szProduct
&& !prod
)
3275 feat
= strdupAtoW( szFeature
);
3276 if (szFeature
&& !feat
)
3279 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
3288 /***********************************************************************
3289 * MsiConfigureFeatureW [MSI.@]
3291 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
3293 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
3294 MSIPACKAGE
*package
= NULL
;
3296 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
3299 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
3301 if (!szProduct
|| !szFeature
)
3302 return ERROR_INVALID_PARAMETER
;
3304 switch (eInstallState
)
3306 case INSTALLSTATE_DEFAULT
:
3307 /* FIXME: how do we figure out the default location? */
3308 eInstallState
= INSTALLSTATE_LOCAL
;
3310 case INSTALLSTATE_LOCAL
:
3311 case INSTALLSTATE_SOURCE
:
3312 case INSTALLSTATE_ABSENT
:
3313 case INSTALLSTATE_ADVERTISED
:
3316 return ERROR_INVALID_PARAMETER
;
3319 r
= MSI_OpenProductW( szProduct
, &package
);
3320 if (r
!= ERROR_SUCCESS
)
3323 sz
= sizeof(sourcepath
);
3324 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3325 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3327 sz
= sizeof(filename
);
3328 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3329 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3331 lstrcatW( sourcepath
, filename
);
3333 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
3335 r
= ACTION_PerformUIAction( package
, szCostInit
, -1 );
3336 if (r
!= ERROR_SUCCESS
)
3339 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
3340 if (r
!= ERROR_SUCCESS
)
3343 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3346 msiobj_release( &package
->hdr
);
3351 /***********************************************************************
3352 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3354 * Notes: undocumented
3356 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
3358 WCHAR path
[MAX_PATH
];
3360 TRACE("%d\n", dwReserved
);
3364 FIXME("dwReserved=%d\n", dwReserved
);
3365 return ERROR_INVALID_PARAMETER
;
3368 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
3369 return ERROR_FUNCTION_FAILED
;
3371 lstrcatW(path
, installerW
);
3373 if (!CreateDirectoryW(path
, NULL
))
3374 return ERROR_FUNCTION_FAILED
;
3376 return ERROR_SUCCESS
;
3379 /***********************************************************************
3380 * MsiGetShortcutTargetA [MSI.@]
3382 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
3383 LPSTR szProductCode
, LPSTR szFeatureId
,
3384 LPSTR szComponentCode
)
3387 const int len
= MAX_FEATURE_CHARS
+1;
3388 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
3391 target
= strdupAtoW( szShortcutTarget
);
3392 if (szShortcutTarget
&& !target
)
3393 return ERROR_OUTOFMEMORY
;
3397 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
3399 if (r
== ERROR_SUCCESS
)
3401 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
3402 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
3403 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
3408 /***********************************************************************
3409 * MsiGetShortcutTargetW [MSI.@]
3411 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
3412 LPWSTR szProductCode
, LPWSTR szFeatureId
,
3413 LPWSTR szComponentCode
)
3415 IShellLinkDataList
*dl
= NULL
;
3416 IPersistFile
*pf
= NULL
;
3417 LPEXP_DARWIN_LINK darwin
= NULL
;
3420 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
3421 szProductCode
, szFeatureId
, szComponentCode
);
3423 init
= CoInitialize(NULL
);
3425 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
3426 &IID_IPersistFile
, (LPVOID
*) &pf
);
3427 if( SUCCEEDED( r
) )
3429 r
= IPersistFile_Load( pf
, szShortcutTarget
,
3430 STGM_READ
| STGM_SHARE_DENY_WRITE
);
3431 if( SUCCEEDED( r
) )
3433 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
3435 if( SUCCEEDED( r
) )
3437 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
3439 IShellLinkDataList_Release( dl
);
3442 IPersistFile_Release( pf
);
3445 if (SUCCEEDED(init
))
3448 TRACE("darwin = %p\n", darwin
);
3455 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
3456 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
3457 LocalFree( darwin
);
3461 return ERROR_FUNCTION_FAILED
;
3464 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3465 DWORD dwReinstallMode
)
3467 MSIPACKAGE
* package
= NULL
;
3469 WCHAR sourcepath
[MAX_PATH
];
3470 WCHAR filename
[MAX_PATH
];
3471 static const WCHAR szLogVerbose
[] = {
3472 ' ','L','O','G','V','E','R','B','O','S','E',0 };
3473 WCHAR reinstallmode
[11];
3477 FIXME("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
3480 ptr
= reinstallmode
;
3482 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
3484 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
3486 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
3488 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
3490 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
3492 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
3494 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
3496 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
3498 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
3500 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3504 sz
= sizeof(sourcepath
);
3505 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3506 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3508 sz
= sizeof(filename
);
3509 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3510 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3512 lstrcatW( sourcepath
, filename
);
3514 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3515 r
= MSI_OpenPackageW( sourcepath
, &package
);
3517 r
= MSI_OpenProductW( szProduct
, &package
);
3519 if (r
!= ERROR_SUCCESS
)
3522 MSI_SetPropertyW( package
, szReinstallMode
, reinstallmode
);
3523 MSI_SetPropertyW( package
, szInstalled
, szOne
);
3524 MSI_SetPropertyW( package
, szLogVerbose
, szOne
);
3525 MSI_SetPropertyW( package
, szReinstall
, szFeature
);
3527 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3529 msiobj_release( &package
->hdr
);
3534 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
3535 DWORD dwReinstallMode
)
3541 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3544 wszProduct
= strdupAtoW(szProduct
);
3545 wszFeature
= strdupAtoW(szFeature
);
3547 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
3549 msi_free(wszProduct
);
3550 msi_free(wszFeature
);
3557 unsigned int buf
[4];
3558 unsigned char in
[64];
3559 unsigned char digest
[16];
3562 extern VOID WINAPI
MD5Init( MD5_CTX
*);
3563 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
3564 extern VOID WINAPI
MD5Final( MD5_CTX
*);
3566 /***********************************************************************
3567 * MsiGetFileHashW [MSI.@]
3569 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
3570 PMSIFILEHASHINFO pHash
)
3572 HANDLE handle
, mapping
;
3575 UINT r
= ERROR_FUNCTION_FAILED
;
3577 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
3580 return ERROR_INVALID_PARAMETER
;
3583 return ERROR_PATH_NOT_FOUND
;
3586 return ERROR_INVALID_PARAMETER
;
3588 return ERROR_INVALID_PARAMETER
;
3589 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
3590 return ERROR_INVALID_PARAMETER
;
3592 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
3593 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
3594 if (handle
== INVALID_HANDLE_VALUE
)
3595 return ERROR_FILE_NOT_FOUND
;
3597 length
= GetFileSize( handle
, NULL
);
3599 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
3602 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
3608 MD5Update( &ctx
, p
, length
);
3610 UnmapViewOfFile( p
);
3612 memcpy( pHash
->dwData
, ctx
.digest
, sizeof pHash
->dwData
);
3615 CloseHandle( mapping
);
3617 CloseHandle( handle
);
3622 /***********************************************************************
3623 * MsiGetFileHashA [MSI.@]
3625 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
3626 PMSIFILEHASHINFO pHash
)
3631 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
3633 file
= strdupAtoW( szFilePath
);
3634 if (szFilePath
&& !file
)
3635 return ERROR_OUTOFMEMORY
;
3637 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
3642 /***********************************************************************
3643 * MsiAdvertiseScriptW [MSI.@]
3645 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
3646 PHKEY phRegData
, BOOL fRemoveItems
)
3648 FIXME("%s %08x %p %d\n",
3649 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
3650 return ERROR_CALL_NOT_IMPLEMENTED
;
3653 /***********************************************************************
3654 * MsiAdvertiseScriptA [MSI.@]
3656 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
3657 PHKEY phRegData
, BOOL fRemoveItems
)
3659 FIXME("%s %08x %p %d\n",
3660 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
3661 return ERROR_CALL_NOT_IMPLEMENTED
;
3664 /***********************************************************************
3665 * MsiIsProductElevatedW [MSI.@]
3667 UINT WINAPI
MsiIsProductElevatedW( LPCWSTR szProduct
, BOOL
*pfElevated
)
3669 FIXME("%s %p - stub\n",
3670 debugstr_w( szProduct
), pfElevated
);
3672 return ERROR_SUCCESS
;
3675 /***********************************************************************
3676 * MsiIsProductElevatedA [MSI.@]
3678 UINT WINAPI
MsiIsProductElevatedA( LPCSTR szProduct
, BOOL
*pfElevated
)
3680 FIXME("%s %p - stub\n",
3681 debugstr_a( szProduct
), pfElevated
);
3683 return ERROR_SUCCESS
;
3686 /***********************************************************************
3687 * MsiSetExternalUIRecord [MSI.@]
3689 UINT WINAPI
MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler
,
3690 DWORD filter
, LPVOID context
,
3691 PINSTALLUI_HANDLER_RECORD prev
)
3693 TRACE("%p %08x %p %p\n", handler
, filter
, context
, prev
);
3696 *prev
= gUIHandlerRecord
;
3698 gUIHandlerRecord
= handler
;
3700 gUIContext
= context
;
3702 return ERROR_SUCCESS
;
3705 /***********************************************************************
3706 * MsiInstallMissingComponentW [MSI.@]
3708 UINT WINAPI
MsiInstallMissingComponentW(LPCWSTR szProduct
, LPCWSTR szComponent
, INSTALLSTATE eInstallState
)
3710 FIXME("(%s %s %d\n", debugstr_w(szProduct
), debugstr_w(szComponent
), eInstallState
);
3711 return ERROR_SUCCESS
;