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 LPWSTR beg
, end
, cmd
= NULL
, codes
= NULL
;
309 BOOL succeeded
= FALSE
;
311 static const WCHAR patcheq
[] = {'P','A','T','C','H','=',0};
312 static WCHAR empty
[] = {0};
314 if (!szPatchPackage
|| !szPatchPackage
[0])
315 return ERROR_INVALID_PARAMETER
;
319 r
= MsiOpenDatabaseW(szPatchPackage
, MSIDBOPEN_READONLY
, &patch
);
320 if (r
!= ERROR_SUCCESS
)
323 r
= MsiGetSummaryInformationW(patch
, NULL
, 0, &info
);
324 if (r
!= ERROR_SUCCESS
)
327 r
= MsiSummaryInfoGetPropertyW(info
, PID_TEMPLATE
, &type
, NULL
, NULL
, empty
, &size
);
328 if (r
!= ERROR_MORE_DATA
|| !size
|| type
!= VT_LPSTR
)
330 ERR("Failed to read product codes from patch\n");
334 codes
= msi_alloc(++size
* sizeof(WCHAR
));
337 r
= ERROR_OUTOFMEMORY
;
341 r
= MsiSummaryInfoGetPropertyW(info
, PID_TEMPLATE
, &type
, NULL
, NULL
, codes
, &size
);
342 if (r
!= ERROR_SUCCESS
)
349 size
= lstrlenW(cmd_ptr
) + lstrlenW(patcheq
) + lstrlenW(szPatchPackage
) + 1;
350 cmd
= msi_alloc(size
* sizeof(WCHAR
));
353 r
= ERROR_OUTOFMEMORY
;
357 lstrcpyW(cmd
, cmd_ptr
);
358 if (szCommandLine
) lstrcatW(cmd
, szSpace
);
359 lstrcatW(cmd
, patcheq
);
360 lstrcatW(cmd
, szPatchPackage
);
363 r
= MsiConfigureProductExW(szProductCode
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
367 while ((end
= strchrW(beg
, '}')))
370 r
= MsiConfigureProductExW(beg
, INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
, cmd
);
371 if (r
== ERROR_SUCCESS
)
373 TRACE("patch applied\n");
387 MsiCloseHandle(info
);
388 MsiCloseHandle(patch
);
393 UINT WINAPI
MsiApplyPatchW(LPCWSTR szPatchPackage
, LPCWSTR szInstallPackage
,
394 INSTALLTYPE eInstallType
, LPCWSTR szCommandLine
)
396 TRACE("%s %s %d %s\n", debugstr_w(szPatchPackage
), debugstr_w(szInstallPackage
),
397 eInstallType
, debugstr_w(szCommandLine
));
399 if (szInstallPackage
|| eInstallType
== INSTALLTYPE_NETWORK_IMAGE
||
400 eInstallType
== INSTALLTYPE_SINGLE_INSTANCE
)
402 FIXME("Only reading target products from patch\n");
403 return ERROR_CALL_NOT_IMPLEMENTED
;
406 return MSI_ApplyPatchW(szPatchPackage
, NULL
, szCommandLine
);
409 UINT WINAPI
MsiApplyMultiplePatchesA(LPCSTR szPatchPackages
,
410 LPCSTR szProductCode
, LPCSTR szPropertiesList
)
412 LPWSTR patch_packages
= NULL
;
413 LPWSTR product_code
= NULL
;
414 LPWSTR properties_list
= NULL
;
415 UINT r
= ERROR_OUTOFMEMORY
;
417 TRACE("%s %s %s\n", debugstr_a(szPatchPackages
), debugstr_a(szProductCode
),
418 debugstr_a(szPropertiesList
));
420 if (!szPatchPackages
|| !szPatchPackages
[0])
421 return ERROR_INVALID_PARAMETER
;
423 if (!(patch_packages
= strdupAtoW(szPatchPackages
)))
424 return ERROR_OUTOFMEMORY
;
426 if (szProductCode
&& !(product_code
= strdupAtoW(szProductCode
)))
429 if (szPropertiesList
&& !(properties_list
= strdupAtoW(szPropertiesList
)))
432 r
= MsiApplyMultiplePatchesW(patch_packages
, product_code
, properties_list
);
435 msi_free(patch_packages
);
436 msi_free(product_code
);
437 msi_free(properties_list
);
442 UINT WINAPI
MsiApplyMultiplePatchesW(LPCWSTR szPatchPackages
,
443 LPCWSTR szProductCode
, LPCWSTR szPropertiesList
)
445 UINT r
= ERROR_SUCCESS
;
448 TRACE("%s %s %s\n", debugstr_w(szPatchPackages
), debugstr_w(szProductCode
),
449 debugstr_w(szPropertiesList
));
451 if (!szPatchPackages
|| !szPatchPackages
[0])
452 return ERROR_INVALID_PARAMETER
;
454 beg
= end
= szPatchPackages
;
460 while (*beg
== ' ') beg
++;
461 while (*end
&& *end
!= ';') end
++;
464 while (len
&& beg
[len
- 1] == ' ') len
--;
466 if (!len
) return ERROR_INVALID_NAME
;
468 patch
= msi_alloc((len
+ 1) * sizeof(WCHAR
));
470 return ERROR_OUTOFMEMORY
;
472 memcpy(patch
, beg
, len
* sizeof(WCHAR
));
475 r
= MSI_ApplyPatchW(patch
, szProductCode
, szPropertiesList
);
478 if (r
!= ERROR_SUCCESS
)
486 UINT WINAPI
MsiDetermineApplicablePatchesA(LPCSTR szProductPackagePath
,
487 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
489 FIXME("(%s, %d, %p): stub!\n", debugstr_a(szProductPackagePath
),
490 cPatchInfo
, pPatchInfo
);
492 return ERROR_CALL_NOT_IMPLEMENTED
;
495 static UINT
MSI_ApplicablePatchW( MSIPACKAGE
*package
, LPCWSTR patch
)
498 MSIDATABASE
*patch_db
;
499 UINT r
= ERROR_SUCCESS
;
501 r
= MSI_OpenDatabaseW( patch
, MSIDBOPEN_READONLY
, &patch_db
);
502 if (r
!= ERROR_SUCCESS
)
504 WARN("failed to open patch file %s\n", debugstr_w(patch
));
508 si
= MSI_GetSummaryInformationW( patch_db
->storage
, 0 );
511 r
= ERROR_FUNCTION_FAILED
;
515 r
= msi_check_patch_applicable( package
, si
);
516 if (r
!= ERROR_SUCCESS
)
517 TRACE("patch not applicable\n");
520 msiobj_release( &patch_db
->hdr
);
521 msiobj_release( &si
->hdr
);
525 UINT WINAPI
MsiDetermineApplicablePatchesW(LPCWSTR szProductPackagePath
,
526 DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
528 UINT i
, r
, ret
= ERROR_FUNCTION_FAILED
;
531 TRACE("(%s, %d, %p)\n", debugstr_w(szProductPackagePath
), cPatchInfo
, pPatchInfo
);
533 r
= MSI_OpenPackageW( szProductPackagePath
, &package
);
534 if (r
!= ERROR_SUCCESS
)
536 ERR("failed to open package %u\n", r
);
540 for (i
= 0; i
< cPatchInfo
; i
++)
542 switch (pPatchInfo
[i
].ePatchDataType
)
544 case MSIPATCH_DATATYPE_PATCHFILE
:
546 FIXME("patch ordering not supported\n");
547 r
= MSI_ApplicablePatchW( package
, pPatchInfo
[i
].szPatchData
);
548 if (r
!= ERROR_SUCCESS
)
550 pPatchInfo
[i
].dwOrder
= ~0u;
551 pPatchInfo
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
555 pPatchInfo
[i
].dwOrder
= i
;
556 pPatchInfo
[i
].uStatus
= ret
= ERROR_SUCCESS
;
562 FIXME("patch data type %u not supported\n", pPatchInfo
[i
].ePatchDataType
);
563 pPatchInfo
[i
].dwOrder
= ~0u;
564 pPatchInfo
[i
].uStatus
= ERROR_PATCH_TARGET_NOT_FOUND
;
569 TRACE(" szPatchData: %s\n", debugstr_w(pPatchInfo
[i
].szPatchData
));
570 TRACE("ePatchDataType: %u\n", pPatchInfo
[i
].ePatchDataType
);
571 TRACE(" dwOrder: %u\n", pPatchInfo
[i
].dwOrder
);
572 TRACE(" uStatus: %u\n", pPatchInfo
[i
].uStatus
);
577 UINT WINAPI
MsiDeterminePatchSequenceA(LPCSTR szProductCode
, LPCSTR szUserSid
,
578 MSIINSTALLCONTEXT dwContext
, DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOA pPatchInfo
)
580 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_a(szProductCode
),
581 debugstr_a(szUserSid
), dwContext
, cPatchInfo
, pPatchInfo
);
583 return ERROR_CALL_NOT_IMPLEMENTED
;
586 UINT WINAPI
MsiDeterminePatchSequenceW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
587 MSIINSTALLCONTEXT dwContext
, DWORD cPatchInfo
, PMSIPATCHSEQUENCEINFOW pPatchInfo
)
589 FIXME("(%s, %s, %d, %d, %p): stub!\n", debugstr_w(szProductCode
),
590 debugstr_w(szUserSid
), dwContext
, cPatchInfo
, pPatchInfo
);
592 return ERROR_CALL_NOT_IMPLEMENTED
;
595 static UINT
msi_open_package(LPCWSTR product
, MSIINSTALLCONTEXT context
,
596 MSIPACKAGE
**package
)
602 WCHAR sourcepath
[MAX_PATH
];
603 WCHAR filename
[MAX_PATH
];
605 r
= MSIREG_OpenInstallProps(product
, context
, NULL
, &props
, FALSE
);
606 if (r
!= ERROR_SUCCESS
)
607 return ERROR_BAD_CONFIGURATION
;
609 localpack
= msi_reg_get_val_str(props
, szLocalPackage
);
612 lstrcpyW(sourcepath
, localpack
);
616 if (!localpack
|| GetFileAttributesW(sourcepath
) == INVALID_FILE_ATTRIBUTES
)
618 sz
= sizeof(sourcepath
);
619 MsiSourceListGetInfoW(product
, NULL
, context
, MSICODE_PRODUCT
,
620 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
622 sz
= sizeof(filename
);
623 MsiSourceListGetInfoW(product
, NULL
, context
, MSICODE_PRODUCT
,
624 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
626 lstrcatW(sourcepath
, filename
);
629 if (GetFileAttributesW(sourcepath
) == INVALID_FILE_ATTRIBUTES
)
630 return ERROR_INSTALL_SOURCE_ABSENT
;
632 return MSI_OpenPackageW(sourcepath
, package
);
635 UINT WINAPI
MsiConfigureProductExW(LPCWSTR szProduct
, int iInstallLevel
,
636 INSTALLSTATE eInstallState
, LPCWSTR szCommandLine
)
638 MSIPACKAGE
* package
= NULL
;
639 MSIINSTALLCONTEXT context
;
642 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
645 static const WCHAR szInstalled
[] = {
646 ' ','I','n','s','t','a','l','l','e','d','=','1',0};
647 static const WCHAR szRemoveAll
[] = {
648 ' ','R','E','M','O','V','E','=','A','L','L',0};
649 static const WCHAR szMachine
[] = {
650 ' ','A','L','L','U','S','E','R','S','=','1',0};
652 TRACE("%s %d %d %s\n",debugstr_w(szProduct
), iInstallLevel
, eInstallState
,
653 debugstr_w(szCommandLine
));
655 if (!szProduct
|| lstrlenW(szProduct
) != GUID_SIZE
- 1)
656 return ERROR_INVALID_PARAMETER
;
658 if (eInstallState
== INSTALLSTATE_ADVERTISED
||
659 eInstallState
== INSTALLSTATE_SOURCE
)
661 FIXME("State %d not implemented\n", eInstallState
);
662 return ERROR_CALL_NOT_IMPLEMENTED
;
665 r
= msi_locate_product(szProduct
, &context
);
666 if (r
!= ERROR_SUCCESS
)
669 r
= msi_open_package(szProduct
, context
, &package
);
670 if (r
!= ERROR_SUCCESS
)
673 sz
= lstrlenW(szInstalled
) + 1;
676 sz
+= lstrlenW(szCommandLine
);
678 if (eInstallState
== INSTALLSTATE_ABSENT
)
679 sz
+= lstrlenW(szRemoveAll
);
681 if (context
== MSIINSTALLCONTEXT_MACHINE
)
682 sz
+= lstrlenW(szMachine
);
684 commandline
= msi_alloc(sz
* sizeof(WCHAR
));
687 r
= ERROR_OUTOFMEMORY
;
693 lstrcpyW(commandline
,szCommandLine
);
695 if (eInstallState
== INSTALLSTATE_ABSENT
)
696 lstrcatW(commandline
, szRemoveAll
);
698 if (context
== MSIINSTALLCONTEXT_MACHINE
)
699 lstrcatW(commandline
, szMachine
);
701 sz
= sizeof(sourcepath
);
702 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
703 INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
705 sz
= sizeof(filename
);
706 MsiSourceListGetInfoW(szProduct
, NULL
, context
, MSICODE_PRODUCT
,
707 INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
709 strcatW(sourcepath
, filename
);
711 r
= MSI_InstallPackage( package
, sourcepath
, commandline
);
713 msi_free(commandline
);
716 msiobj_release( &package
->hdr
);
721 UINT WINAPI
MsiConfigureProductExA(LPCSTR szProduct
, int iInstallLevel
,
722 INSTALLSTATE eInstallState
, LPCSTR szCommandLine
)
724 LPWSTR szwProduct
= NULL
;
725 LPWSTR szwCommandLine
= NULL
;
726 UINT r
= ERROR_OUTOFMEMORY
;
730 szwProduct
= strdupAtoW( szProduct
);
737 szwCommandLine
= strdupAtoW( szCommandLine
);
742 r
= MsiConfigureProductExW( szwProduct
, iInstallLevel
, eInstallState
,
745 msi_free( szwProduct
);
746 msi_free( szwCommandLine
);
751 UINT WINAPI
MsiConfigureProductA(LPCSTR szProduct
, int iInstallLevel
,
752 INSTALLSTATE eInstallState
)
754 LPWSTR szwProduct
= NULL
;
757 TRACE("%s %d %d\n",debugstr_a(szProduct
), iInstallLevel
, eInstallState
);
761 szwProduct
= strdupAtoW( szProduct
);
763 return ERROR_OUTOFMEMORY
;
766 r
= MsiConfigureProductW( szwProduct
, iInstallLevel
, eInstallState
);
767 msi_free( szwProduct
);
772 UINT WINAPI
MsiConfigureProductW(LPCWSTR szProduct
, int iInstallLevel
,
773 INSTALLSTATE eInstallState
)
775 return MsiConfigureProductExW(szProduct
, iInstallLevel
, eInstallState
, NULL
);
778 UINT WINAPI
MsiGetProductCodeA(LPCSTR szComponent
, LPSTR szBuffer
)
780 LPWSTR szwComponent
= NULL
;
782 WCHAR szwBuffer
[GUID_SIZE
];
784 TRACE("%s %s\n",debugstr_a(szComponent
), debugstr_a(szBuffer
));
788 szwComponent
= strdupAtoW( szComponent
);
790 return ERROR_OUTOFMEMORY
;
794 r
= MsiGetProductCodeW( szwComponent
, szwBuffer
);
797 WideCharToMultiByte(CP_ACP
, 0, szwBuffer
, -1, szBuffer
, GUID_SIZE
, NULL
, NULL
);
799 msi_free( szwComponent
);
804 UINT WINAPI
MsiGetProductCodeW(LPCWSTR szComponent
, LPWSTR szBuffer
)
807 HKEY compkey
, prodkey
;
808 WCHAR squished_comp
[GUID_SIZE
];
809 WCHAR squished_prod
[GUID_SIZE
];
810 DWORD sz
= GUID_SIZE
;
812 TRACE("%s %p\n", debugstr_w(szComponent
), szBuffer
);
814 if (!szComponent
|| !*szComponent
)
815 return ERROR_INVALID_PARAMETER
;
817 if (!squash_guid(szComponent
, squished_comp
))
818 return ERROR_INVALID_PARAMETER
;
820 if (MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &compkey
, FALSE
) != ERROR_SUCCESS
&&
821 MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &compkey
, FALSE
) != ERROR_SUCCESS
)
823 return ERROR_UNKNOWN_COMPONENT
;
826 rc
= RegEnumValueW(compkey
, 0, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
827 if (rc
!= ERROR_SUCCESS
)
829 RegCloseKey(compkey
);
830 return ERROR_UNKNOWN_COMPONENT
;
833 /* check simple case, only one product */
834 rc
= RegEnumValueW(compkey
, 1, squished_prod
, &sz
, NULL
, NULL
, NULL
, NULL
);
835 if (rc
== ERROR_NO_MORE_ITEMS
)
842 while ((rc
= RegEnumValueW(compkey
, index
, squished_prod
, &sz
,
843 NULL
, NULL
, NULL
, NULL
)) != ERROR_NO_MORE_ITEMS
)
847 unsquash_guid(squished_prod
, szBuffer
);
849 if (MSIREG_OpenProductKey(szBuffer
, NULL
,
850 MSIINSTALLCONTEXT_USERMANAGED
,
851 &prodkey
, FALSE
) == ERROR_SUCCESS
||
852 MSIREG_OpenProductKey(szBuffer
, NULL
,
853 MSIINSTALLCONTEXT_USERUNMANAGED
,
854 &prodkey
, FALSE
) == ERROR_SUCCESS
||
855 MSIREG_OpenProductKey(szBuffer
, NULL
,
856 MSIINSTALLCONTEXT_MACHINE
,
857 &prodkey
, FALSE
) == ERROR_SUCCESS
)
859 RegCloseKey(prodkey
);
865 rc
= ERROR_INSTALL_FAILURE
;
868 RegCloseKey(compkey
);
869 unsquash_guid(squished_prod
, szBuffer
);
873 static LPWSTR
msi_reg_get_value(HKEY hkey
, LPCWSTR name
, DWORD
*type
)
879 static const WCHAR format
[] = {'%','d',0};
881 res
= RegQueryValueExW(hkey
, name
, NULL
, type
, NULL
, NULL
);
882 if (res
!= ERROR_SUCCESS
)
886 return msi_reg_get_val_str(hkey
, name
);
888 if (!msi_reg_get_val_dword(hkey
, name
, &dval
))
891 sprintfW(temp
, format
, dval
);
892 return strdupW(temp
);
895 static UINT
MSI_GetProductInfo(LPCWSTR szProduct
, LPCWSTR szAttribute
,
896 awstring
*szValue
, LPDWORD pcchValueBuf
)
898 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
899 UINT r
= ERROR_UNKNOWN_PROPERTY
;
900 HKEY prodkey
, userdata
, source
;
902 WCHAR squished_pc
[GUID_SIZE
];
903 WCHAR packagecode
[GUID_SIZE
];
904 BOOL badconfig
= FALSE
;
906 DWORD type
= REG_NONE
;
908 static WCHAR empty
[] = {0};
909 static const WCHAR sourcelist
[] = {
910 'S','o','u','r','c','e','L','i','s','t',0};
911 static const WCHAR display_name
[] = {
912 'D','i','s','p','l','a','y','N','a','m','e',0};
913 static const WCHAR display_version
[] = {
914 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
915 static const WCHAR assignment
[] = {
916 'A','s','s','i','g','n','m','e','n','t',0};
918 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
919 debugstr_w(szAttribute
), szValue
, pcchValueBuf
);
921 if ((szValue
->str
.w
&& !pcchValueBuf
) || !szProduct
|| !szAttribute
)
922 return ERROR_INVALID_PARAMETER
;
924 if (!squash_guid(szProduct
, squished_pc
))
925 return ERROR_INVALID_PARAMETER
;
927 if ((r
= MSIREG_OpenProductKey(szProduct
, NULL
,
928 MSIINSTALLCONTEXT_USERMANAGED
,
929 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
930 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
931 MSIINSTALLCONTEXT_USERUNMANAGED
,
932 &prodkey
, FALSE
)) != ERROR_SUCCESS
&&
933 (r
= MSIREG_OpenProductKey(szProduct
, NULL
,
934 MSIINSTALLCONTEXT_MACHINE
,
935 &prodkey
, FALSE
)) == ERROR_SUCCESS
)
937 context
= MSIINSTALLCONTEXT_MACHINE
;
940 MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
942 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_HELPLINKW
) ||
943 !lstrcmpW(szAttribute
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
944 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLDATEW
) ||
945 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
946 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
947 !lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
948 !lstrcmpW(szAttribute
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
949 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PUBLISHERW
) ||
950 !lstrcmpW(szAttribute
, INSTALLPROPERTY_URLINFOABOUTW
) ||
951 !lstrcmpW(szAttribute
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
952 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONMINORW
) ||
953 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONMAJORW
) ||
954 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
955 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTIDW
) ||
956 !lstrcmpW(szAttribute
, INSTALLPROPERTY_REGCOMPANYW
) ||
957 !lstrcmpW(szAttribute
, INSTALLPROPERTY_REGOWNERW
))
961 r
= ERROR_UNKNOWN_PRODUCT
;
966 return ERROR_UNKNOWN_PROPERTY
;
968 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
969 szAttribute
= display_name
;
970 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONSTRINGW
))
971 szAttribute
= display_version
;
973 val
= msi_reg_get_value(userdata
, szAttribute
, &type
);
977 else if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_INSTANCETYPEW
) ||
978 !lstrcmpW(szAttribute
, INSTALLPROPERTY_TRANSFORMSW
) ||
979 !lstrcmpW(szAttribute
, INSTALLPROPERTY_LANGUAGEW
) ||
980 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
981 !lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
) ||
982 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
) ||
983 !lstrcmpW(szAttribute
, INSTALLPROPERTY_VERSIONW
) ||
984 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PRODUCTICONW
) ||
985 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
) ||
986 !lstrcmpW(szAttribute
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
990 r
= ERROR_UNKNOWN_PRODUCT
;
994 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
995 szAttribute
= assignment
;
997 if (!lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGENAMEW
))
999 res
= RegOpenKeyW(prodkey
, sourcelist
, &source
);
1000 if (res
!= ERROR_SUCCESS
)
1002 r
= ERROR_UNKNOWN_PRODUCT
;
1006 val
= msi_reg_get_value(source
, szAttribute
, &type
);
1010 RegCloseKey(source
);
1014 val
= msi_reg_get_value(prodkey
, szAttribute
, &type
);
1019 if (val
!= empty
&& type
!= REG_DWORD
&&
1020 !lstrcmpW(szAttribute
, INSTALLPROPERTY_PACKAGECODEW
))
1022 if (lstrlenW(val
) != SQUISH_GUID_SIZE
- 1)
1026 unsquash_guid(val
, packagecode
);
1028 val
= strdupW(packagecode
);
1035 r
= ERROR_UNKNOWN_PROPERTY
;
1041 /* If szBuffer (szValue->str) is NULL, there's no need to copy the value
1042 * out. Also, *pcchValueBuf may be uninitialized in this case, so we
1043 * can't rely on its value.
1045 if (szValue
->str
.a
|| szValue
->str
.w
)
1047 DWORD size
= *pcchValueBuf
;
1048 if (strlenW(val
) < size
)
1049 r
= msi_strcpy_to_awstring(val
, szValue
, &size
);
1052 r
= ERROR_MORE_DATA
;
1057 *pcchValueBuf
= lstrlenW(val
);
1061 r
= ERROR_BAD_CONFIGURATION
;
1067 RegCloseKey(prodkey
);
1068 RegCloseKey(userdata
);
1072 UINT WINAPI
MsiGetProductInfoA(LPCSTR szProduct
, LPCSTR szAttribute
,
1073 LPSTR szBuffer
, LPDWORD pcchValueBuf
)
1075 LPWSTR szwProduct
, szwAttribute
= NULL
;
1076 UINT r
= ERROR_OUTOFMEMORY
;
1079 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szAttribute
),
1080 szBuffer
, pcchValueBuf
);
1082 szwProduct
= strdupAtoW( szProduct
);
1083 if( szProduct
&& !szwProduct
)
1086 szwAttribute
= strdupAtoW( szAttribute
);
1087 if( szAttribute
&& !szwAttribute
)
1090 buffer
.unicode
= FALSE
;
1091 buffer
.str
.a
= szBuffer
;
1093 r
= MSI_GetProductInfo( szwProduct
, szwAttribute
,
1094 &buffer
, pcchValueBuf
);
1097 msi_free( szwProduct
);
1098 msi_free( szwAttribute
);
1103 UINT WINAPI
MsiGetProductInfoW(LPCWSTR szProduct
, LPCWSTR szAttribute
,
1104 LPWSTR szBuffer
, LPDWORD pcchValueBuf
)
1108 TRACE("%s %s %p %p\n", debugstr_w(szProduct
), debugstr_w(szAttribute
),
1109 szBuffer
, pcchValueBuf
);
1111 buffer
.unicode
= TRUE
;
1112 buffer
.str
.w
= szBuffer
;
1114 return MSI_GetProductInfo( szProduct
, szAttribute
,
1115 &buffer
, pcchValueBuf
);
1118 UINT WINAPI
MsiGetProductInfoExA(LPCSTR szProductCode
, LPCSTR szUserSid
,
1119 MSIINSTALLCONTEXT dwContext
, LPCSTR szProperty
,
1120 LPSTR szValue
, LPDWORD pcchValue
)
1122 LPWSTR product
= NULL
;
1123 LPWSTR usersid
= NULL
;
1124 LPWSTR property
= NULL
;
1125 LPWSTR value
= NULL
;
1129 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_a(szProductCode
),
1130 debugstr_a(szUserSid
), dwContext
, debugstr_a(szProperty
),
1131 szValue
, pcchValue
);
1133 if (szValue
&& !pcchValue
)
1134 return ERROR_INVALID_PARAMETER
;
1136 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1137 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1138 if (szProperty
) property
= strdupAtoW(szProperty
);
1140 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1142 if (r
!= ERROR_SUCCESS
)
1145 value
= msi_alloc(++len
* sizeof(WCHAR
));
1148 r
= ERROR_OUTOFMEMORY
;
1152 r
= MsiGetProductInfoExW(product
, usersid
, dwContext
, property
,
1154 if (r
!= ERROR_SUCCESS
)
1160 len
= WideCharToMultiByte(CP_ACP
, 0, value
, -1, NULL
, 0, NULL
, NULL
);
1161 if (*pcchValue
>= len
)
1162 WideCharToMultiByte(CP_ACP
, 0, value
, -1, szValue
, len
, NULL
, NULL
);
1165 r
= ERROR_MORE_DATA
;
1170 if (*pcchValue
<= len
|| !szValue
)
1171 len
= len
* sizeof(WCHAR
) - 1;
1173 *pcchValue
= len
- 1;
1184 static UINT
msi_copy_outval(LPWSTR val
, LPWSTR out
, LPDWORD size
)
1189 return ERROR_UNKNOWN_PROPERTY
;
1193 if (strlenW(val
) >= *size
)
1195 r
= ERROR_MORE_DATA
;
1204 *size
= lstrlenW(val
);
1206 return ERROR_SUCCESS
;
1209 UINT WINAPI
MsiGetProductInfoExW(LPCWSTR szProductCode
, LPCWSTR szUserSid
,
1210 MSIINSTALLCONTEXT dwContext
, LPCWSTR szProperty
,
1211 LPWSTR szValue
, LPDWORD pcchValue
)
1213 WCHAR squished_pc
[GUID_SIZE
];
1215 LPCWSTR package
= NULL
;
1216 HKEY props
= NULL
, prod
;
1217 HKEY classes
= NULL
, managed
;
1220 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1222 static const WCHAR five
[] = {'5',0};
1223 static const WCHAR displayname
[] = {
1224 'D','i','s','p','l','a','y','N','a','m','e',0};
1225 static const WCHAR displayversion
[] = {
1226 'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
1227 static const WCHAR managed_local_package
[] = {
1228 'M','a','n','a','g','e','d','L','o','c','a','l',
1229 'P','a','c','k','a','g','e',0};
1231 TRACE("(%s, %s, %d, %s, %p, %p)\n", debugstr_w(szProductCode
),
1232 debugstr_w(szUserSid
), dwContext
, debugstr_w(szProperty
),
1233 szValue
, pcchValue
);
1235 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1236 return ERROR_INVALID_PARAMETER
;
1238 if (szValue
&& !pcchValue
)
1239 return ERROR_INVALID_PARAMETER
;
1241 if (dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1242 dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1243 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1244 return ERROR_INVALID_PARAMETER
;
1246 if (!szProperty
|| !*szProperty
)
1247 return ERROR_INVALID_PARAMETER
;
1249 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1250 return ERROR_INVALID_PARAMETER
;
1252 /* FIXME: dwContext is provided, no need to search for it */
1253 MSIREG_OpenProductKey(szProductCode
, NULL
,MSIINSTALLCONTEXT_USERMANAGED
,
1255 MSIREG_OpenProductKey(szProductCode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1258 MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
, &props
, FALSE
);
1260 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1262 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1264 if (!props
&& !prod
)
1267 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1269 package
= managed_local_package
;
1271 if (!props
&& !managed
)
1274 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1276 package
= INSTALLPROPERTY_LOCALPACKAGEW
;
1277 MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
, &classes
, FALSE
);
1279 if (!props
&& !classes
)
1283 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_HELPLINKW
) ||
1284 !lstrcmpW(szProperty
, INSTALLPROPERTY_HELPTELEPHONEW
) ||
1285 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLDATEW
) ||
1286 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
) ||
1287 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLLOCATIONW
) ||
1288 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLSOURCEW
) ||
1289 !lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
) ||
1290 !lstrcmpW(szProperty
, INSTALLPROPERTY_PUBLISHERW
) ||
1291 !lstrcmpW(szProperty
, INSTALLPROPERTY_URLINFOABOUTW
) ||
1292 !lstrcmpW(szProperty
, INSTALLPROPERTY_URLUPDATEINFOW
) ||
1293 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONMINORW
) ||
1294 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONMAJORW
) ||
1295 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
) ||
1296 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTIDW
) ||
1297 !lstrcmpW(szProperty
, INSTALLPROPERTY_REGCOMPANYW
) ||
1298 !lstrcmpW(szProperty
, INSTALLPROPERTY_REGOWNERW
) ||
1299 !lstrcmpW(szProperty
, INSTALLPROPERTY_INSTANCETYPEW
))
1301 val
= msi_reg_get_value(props
, package
, &type
);
1304 if (prod
|| classes
)
1305 r
= ERROR_UNKNOWN_PROPERTY
;
1312 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEW
))
1313 szProperty
= displayname
;
1314 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONSTRINGW
))
1315 szProperty
= displayversion
;
1317 val
= msi_reg_get_value(props
, szProperty
, &type
);
1319 val
= strdupW(szEmpty
);
1321 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1323 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_TRANSFORMSW
) ||
1324 !lstrcmpW(szProperty
, INSTALLPROPERTY_LANGUAGEW
) ||
1325 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTNAMEW
) ||
1326 !lstrcmpW(szProperty
, INSTALLPROPERTY_PACKAGECODEW
) ||
1327 !lstrcmpW(szProperty
, INSTALLPROPERTY_VERSIONW
) ||
1328 !lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTICONW
) ||
1329 !lstrcmpW(szProperty
, INSTALLPROPERTY_PACKAGENAMEW
) ||
1330 !lstrcmpW(szProperty
, INSTALLPROPERTY_AUTHORIZED_LUA_APPW
))
1332 if (!prod
&& !classes
)
1335 if (dwContext
== MSIINSTALLCONTEXT_USERUNMANAGED
)
1337 else if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1339 else if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1342 val
= msi_reg_get_value(hkey
, szProperty
, &type
);
1344 val
= strdupW(szEmpty
);
1346 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1348 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_PRODUCTSTATEW
))
1350 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
)
1354 val
= msi_reg_get_value(props
, package
, &type
);
1359 val
= strdupW(five
);
1362 val
= strdupW(szOne
);
1364 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1367 else if (props
&& (val
= msi_reg_get_value(props
, package
, &type
)))
1370 val
= strdupW(five
);
1371 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1375 if (prod
|| managed
)
1376 val
= strdupW(szOne
);
1380 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1382 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_ASSIGNMENTTYPEW
))
1384 if (!prod
&& !classes
)
1388 val
= strdupW(szEmpty
);
1389 r
= msi_copy_outval(val
, szValue
, pcchValue
);
1392 r
= ERROR_UNKNOWN_PROPERTY
;
1397 RegCloseKey(managed
);
1398 RegCloseKey(classes
);
1404 UINT WINAPI
MsiGetPatchInfoExA(LPCSTR szPatchCode
, LPCSTR szProductCode
,
1405 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1406 LPCSTR szProperty
, LPSTR lpValue
, DWORD
*pcchValue
)
1408 LPWSTR patch
= NULL
, product
= NULL
, usersid
= NULL
;
1409 LPWSTR property
= NULL
, val
= NULL
;
1413 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_a(szPatchCode
),
1414 debugstr_a(szProductCode
), debugstr_a(szUserSid
), dwContext
,
1415 debugstr_a(szProperty
), lpValue
, pcchValue
);
1417 if (lpValue
&& !pcchValue
)
1418 return ERROR_INVALID_PARAMETER
;
1420 if (szPatchCode
) patch
= strdupAtoW(szPatchCode
);
1421 if (szProductCode
) product
= strdupAtoW(szProductCode
);
1422 if (szUserSid
) usersid
= strdupAtoW(szUserSid
);
1423 if (szProperty
) property
= strdupAtoW(szProperty
);
1426 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1428 if (r
!= ERROR_SUCCESS
)
1431 val
= msi_alloc(++len
* sizeof(WCHAR
));
1434 r
= ERROR_OUTOFMEMORY
;
1438 r
= MsiGetPatchInfoExW(patch
, product
, usersid
, dwContext
, property
,
1440 if (r
!= ERROR_SUCCESS
|| !pcchValue
)
1444 WideCharToMultiByte(CP_ACP
, 0, val
, -1, lpValue
,
1445 *pcchValue
- 1, NULL
, NULL
);
1447 len
= lstrlenW(val
);
1448 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1452 r
= ERROR_MORE_DATA
;
1453 lpValue
[*pcchValue
- 1] = '\0';
1456 *pcchValue
= len
* sizeof(WCHAR
);
1471 UINT WINAPI
MsiGetPatchInfoExW(LPCWSTR szPatchCode
, LPCWSTR szProductCode
,
1472 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1473 LPCWSTR szProperty
, LPWSTR lpValue
, DWORD
*pcchValue
)
1475 WCHAR squished_pc
[GUID_SIZE
];
1476 WCHAR squished_patch
[GUID_SIZE
];
1477 HKEY udprod
= 0, prod
= 0, props
= 0;
1478 HKEY patch
= 0, patches
= 0;
1479 HKEY udpatch
= 0, datakey
= 0;
1480 HKEY prodpatches
= 0;
1482 UINT r
= ERROR_UNKNOWN_PRODUCT
;
1486 static const WCHAR szManagedPackage
[] = {'M','a','n','a','g','e','d',
1487 'L','o','c','a','l','P','a','c','k','a','g','e',0};
1489 TRACE("(%s, %s, %s, %d, %s, %p, %p)\n", debugstr_w(szPatchCode
),
1490 debugstr_w(szProductCode
), debugstr_w(szUserSid
), dwContext
,
1491 debugstr_w(szProperty
), lpValue
, pcchValue
);
1493 if (!szProductCode
|| !squash_guid(szProductCode
, squished_pc
))
1494 return ERROR_INVALID_PARAMETER
;
1496 if (!szPatchCode
|| !squash_guid(szPatchCode
, squished_patch
))
1497 return ERROR_INVALID_PARAMETER
;
1500 return ERROR_INVALID_PARAMETER
;
1502 if (lpValue
&& !pcchValue
)
1503 return ERROR_INVALID_PARAMETER
;
1505 if (dwContext
!= MSIINSTALLCONTEXT_USERMANAGED
&&
1506 dwContext
!= MSIINSTALLCONTEXT_USERUNMANAGED
&&
1507 dwContext
!= MSIINSTALLCONTEXT_MACHINE
)
1508 return ERROR_INVALID_PARAMETER
;
1510 if (dwContext
== MSIINSTALLCONTEXT_MACHINE
&& szUserSid
)
1511 return ERROR_INVALID_PARAMETER
;
1513 if (!lstrcmpW(szUserSid
, szLocalSid
))
1514 return ERROR_INVALID_PARAMETER
;
1516 if (MSIREG_OpenUserDataProductKey(szProductCode
, dwContext
, NULL
,
1517 &udprod
, FALSE
) != ERROR_SUCCESS
)
1520 if (MSIREG_OpenInstallProps(szProductCode
, dwContext
, NULL
,
1521 &props
, FALSE
) != ERROR_SUCCESS
)
1524 r
= ERROR_UNKNOWN_PATCH
;
1526 res
= RegOpenKeyExW(udprod
, szPatches
, 0, KEY_READ
, &patches
);
1527 if (res
!= ERROR_SUCCESS
)
1530 res
= RegOpenKeyExW(patches
, squished_patch
, 0, KEY_READ
, &patch
);
1531 if (res
!= ERROR_SUCCESS
)
1534 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_TRANSFORMSW
))
1536 if (MSIREG_OpenProductKey(szProductCode
, NULL
, dwContext
,
1537 &prod
, FALSE
) != ERROR_SUCCESS
)
1540 res
= RegOpenKeyExW(prod
, szPatches
, 0, KEY_ALL_ACCESS
, &prodpatches
);
1541 if (res
!= ERROR_SUCCESS
)
1544 datakey
= prodpatches
;
1545 szProperty
= squished_patch
;
1549 if (MSIREG_OpenUserDataPatchKey(szPatchCode
, dwContext
,
1550 &udpatch
, FALSE
) != ERROR_SUCCESS
)
1553 if (!lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1555 if (dwContext
== MSIINSTALLCONTEXT_USERMANAGED
)
1556 szProperty
= szManagedPackage
;
1559 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_INSTALLDATEW
))
1562 szProperty
= szInstalled
;
1564 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_LOCALPACKAGEW
))
1568 else if (!lstrcmpW(szProperty
, INSTALLPROPERTY_UNINSTALLABLEW
) ||
1569 !lstrcmpW(szProperty
, INSTALLPROPERTY_PATCHSTATEW
) ||
1570 !lstrcmpW(szProperty
, INSTALLPROPERTY_DISPLAYNAMEW
) ||
1571 !lstrcmpW(szProperty
, INSTALLPROPERTY_MOREINFOURLW
))
1577 r
= ERROR_UNKNOWN_PROPERTY
;
1582 val
= msi_reg_get_val_str(datakey
, szProperty
);
1584 val
= strdupW(szEmpty
);
1592 lstrcpynW(lpValue
, val
, *pcchValue
);
1594 len
= lstrlenW(val
);
1595 if ((*val
&& *pcchValue
< len
+ 1) || !lpValue
)
1598 r
= ERROR_MORE_DATA
;
1600 *pcchValue
= len
* sizeof(WCHAR
);
1607 RegCloseKey(prodpatches
);
1610 RegCloseKey(patches
);
1611 RegCloseKey(udpatch
);
1613 RegCloseKey(udprod
);
1618 UINT WINAPI
MsiGetPatchInfoA( LPCSTR patch
, LPCSTR attr
, LPSTR buffer
, LPDWORD buflen
)
1620 UINT r
= ERROR_OUTOFMEMORY
;
1622 LPWSTR patchW
= NULL
, attrW
= NULL
, bufferW
= NULL
;
1624 TRACE("%s %s %p %p\n", debugstr_a(patch
), debugstr_a(attr
), buffer
, buflen
);
1626 if (!patch
|| !attr
)
1627 return ERROR_INVALID_PARAMETER
;
1629 if (!(patchW
= strdupAtoW( patch
)))
1632 if (!(attrW
= strdupAtoW( attr
)))
1636 r
= MsiGetPatchInfoW( patchW
, attrW
, NULL
, &size
);
1637 if (r
!= ERROR_SUCCESS
)
1641 if (!(bufferW
= msi_alloc( size
* sizeof(WCHAR
) )))
1643 r
= ERROR_OUTOFMEMORY
;
1647 r
= MsiGetPatchInfoW( patchW
, attrW
, bufferW
, &size
);
1648 if (r
== ERROR_SUCCESS
)
1650 int len
= WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, NULL
, 0, NULL
, NULL
);
1652 r
= ERROR_MORE_DATA
;
1654 WideCharToMultiByte( CP_ACP
, 0, bufferW
, -1, buffer
, *buflen
, NULL
, NULL
);
1662 msi_free( bufferW
);
1666 UINT WINAPI
MsiGetPatchInfoW( LPCWSTR patch
, LPCWSTR attr
, LPWSTR buffer
, LPDWORD buflen
)
1669 WCHAR product
[GUID_SIZE
];
1672 TRACE("%s %s %p %p\n", debugstr_w(patch
), debugstr_w(attr
), buffer
, buflen
);
1674 if (!patch
|| !attr
)
1675 return ERROR_INVALID_PARAMETER
;
1677 if (strcmpW( INSTALLPROPERTY_LOCALPACKAGEW
, attr
))
1678 return ERROR_UNKNOWN_PROPERTY
;
1683 r
= MsiEnumProductsW( index
, product
);
1684 if (r
!= ERROR_SUCCESS
)
1687 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, attr
, buffer
, buflen
);
1688 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1691 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, attr
, buffer
, buflen
);
1692 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1695 r
= MsiGetPatchInfoExW( patch
, product
, NULL
, MSIINSTALLCONTEXT_MACHINE
, attr
, buffer
, buflen
);
1696 if (r
== ERROR_SUCCESS
|| r
== ERROR_MORE_DATA
)
1702 return ERROR_UNKNOWN_PRODUCT
;
1705 UINT WINAPI
MsiEnableLogA(DWORD dwLogMode
, LPCSTR szLogFile
, DWORD attributes
)
1707 LPWSTR szwLogFile
= NULL
;
1710 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_a(szLogFile
), attributes
);
1714 szwLogFile
= strdupAtoW( szLogFile
);
1716 return ERROR_OUTOFMEMORY
;
1718 r
= MsiEnableLogW( dwLogMode
, szwLogFile
, attributes
);
1719 msi_free( szwLogFile
);
1723 UINT WINAPI
MsiEnableLogW(DWORD dwLogMode
, LPCWSTR szLogFile
, DWORD attributes
)
1725 HANDLE file
= INVALID_HANDLE_VALUE
;
1727 TRACE("%08x %s %08x\n", dwLogMode
, debugstr_w(szLogFile
), attributes
);
1731 lstrcpyW(gszLogFile
,szLogFile
);
1732 if (!(attributes
& INSTALLLOGATTRIBUTES_APPEND
))
1733 DeleteFileW(szLogFile
);
1734 file
= CreateFileW(szLogFile
, GENERIC_WRITE
, 0, NULL
, OPEN_ALWAYS
,
1735 FILE_ATTRIBUTE_NORMAL
, NULL
);
1736 if (file
!= INVALID_HANDLE_VALUE
)
1739 ERR("Unable to enable log %s\n",debugstr_w(szLogFile
));
1742 gszLogFile
[0] = '\0';
1744 return ERROR_SUCCESS
;
1747 UINT WINAPI
MsiEnumComponentCostsW(MSIHANDLE hInstall
, LPCWSTR szComponent
,
1748 DWORD dwIndex
, INSTALLSTATE iState
,
1749 LPWSTR lpDriveBuf
, DWORD
*pcchDriveBuf
,
1750 int *piCost
, int *pTempCost
)
1752 FIXME("(%d, %s, %d, %d, %p, %p, %p %p): stub!\n", hInstall
,
1753 debugstr_w(szComponent
), dwIndex
, iState
, lpDriveBuf
,
1754 pcchDriveBuf
, piCost
, pTempCost
);
1756 return ERROR_NO_MORE_ITEMS
;
1759 UINT WINAPI
MsiQueryComponentStateA(LPCSTR szProductCode
,
1760 LPCSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1761 LPCSTR szComponent
, INSTALLSTATE
*pdwState
)
1763 LPWSTR prodcode
= NULL
, usersid
= NULL
, comp
= NULL
;
1766 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_a(szProductCode
),
1767 debugstr_a(szUserSid
), dwContext
, debugstr_a(szComponent
), pdwState
);
1769 if (szProductCode
&& !(prodcode
= strdupAtoW(szProductCode
)))
1770 return ERROR_OUTOFMEMORY
;
1772 if (szUserSid
&& !(usersid
= strdupAtoW(szUserSid
)))
1773 return ERROR_OUTOFMEMORY
;
1775 if (szComponent
&& !(comp
= strdupAtoW(szComponent
)))
1776 return ERROR_OUTOFMEMORY
;
1778 r
= MsiQueryComponentStateW(prodcode
, usersid
, dwContext
, comp
, pdwState
);
1787 static BOOL
msi_comp_find_prod_key(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
1792 r
= MSIREG_OpenProductKey(prodcode
, NULL
, context
, &hkey
, FALSE
);
1794 return (r
== ERROR_SUCCESS
);
1797 static BOOL
msi_comp_find_package(LPCWSTR prodcode
, MSIINSTALLCONTEXT context
)
1805 static const WCHAR local_package
[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0};
1806 static const WCHAR managed_local_package
[] = {
1807 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0
1810 r
= MSIREG_OpenInstallProps(prodcode
, context
, NULL
, &hkey
, FALSE
);
1811 if (r
!= ERROR_SUCCESS
)
1814 if (context
== MSIINSTALLCONTEXT_USERMANAGED
)
1815 package
= managed_local_package
;
1817 package
= local_package
;
1820 res
= RegQueryValueExW(hkey
, package
, NULL
, NULL
, NULL
, &sz
);
1823 return (res
== ERROR_SUCCESS
);
1826 static BOOL
msi_comp_find_prodcode(LPWSTR squished_pc
,
1827 MSIINSTALLCONTEXT context
,
1828 LPCWSTR comp
, LPWSTR val
, DWORD
*sz
)
1834 if (context
== MSIINSTALLCONTEXT_MACHINE
)
1835 r
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
1837 r
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
1839 if (r
!= ERROR_SUCCESS
)
1842 res
= RegQueryValueExW(hkey
, squished_pc
, NULL
, NULL
, (BYTE
*)val
, sz
);
1843 if (res
!= ERROR_SUCCESS
)
1850 UINT WINAPI
MsiQueryComponentStateW(LPCWSTR szProductCode
,
1851 LPCWSTR szUserSid
, MSIINSTALLCONTEXT dwContext
,
1852 LPCWSTR szComponent
, INSTALLSTATE
*pdwState
)
1854 WCHAR squished_pc
[GUID_SIZE
];
1855 WCHAR val
[MAX_PATH
];
1859 TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode
),
1860 debugstr_w(szUserSid
), dwContext
, debugstr_w(szComponent
), pdwState
);
1862 if (!pdwState
|| !szComponent
)
1863 return ERROR_INVALID_PARAMETER
;
1865 if (!szProductCode
|| !*szProductCode
|| lstrlenW(szProductCode
) != GUID_SIZE
- 1)
1866 return ERROR_INVALID_PARAMETER
;
1868 if (!squash_guid(szProductCode
, squished_pc
))
1869 return ERROR_INVALID_PARAMETER
;
1871 found
= msi_comp_find_prod_key(szProductCode
, dwContext
);
1873 if (!msi_comp_find_package(szProductCode
, dwContext
))
1877 *pdwState
= INSTALLSTATE_UNKNOWN
;
1878 return ERROR_UNKNOWN_COMPONENT
;
1881 return ERROR_UNKNOWN_PRODUCT
;
1884 *pdwState
= INSTALLSTATE_UNKNOWN
;
1887 if (!msi_comp_find_prodcode(squished_pc
, dwContext
, szComponent
, val
, &sz
))
1888 return ERROR_UNKNOWN_COMPONENT
;
1891 *pdwState
= INSTALLSTATE_NOTUSED
;
1894 if (lstrlenW(val
) > 2 &&
1895 val
[0] >= '0' && val
[0] <= '9' && val
[1] >= '0' && val
[1] <= '9')
1897 *pdwState
= INSTALLSTATE_SOURCE
;
1900 *pdwState
= INSTALLSTATE_LOCAL
;
1903 return ERROR_SUCCESS
;
1906 INSTALLSTATE WINAPI
MsiQueryProductStateA(LPCSTR szProduct
)
1908 LPWSTR szwProduct
= NULL
;
1913 szwProduct
= strdupAtoW( szProduct
);
1915 return ERROR_OUTOFMEMORY
;
1917 r
= MsiQueryProductStateW( szwProduct
);
1918 msi_free( szwProduct
);
1922 INSTALLSTATE WINAPI
MsiQueryProductStateW(LPCWSTR szProduct
)
1924 MSIINSTALLCONTEXT context
= MSIINSTALLCONTEXT_USERUNMANAGED
;
1925 INSTALLSTATE state
= INSTALLSTATE_ADVERTISED
;
1926 HKEY prodkey
= 0, userdata
= 0;
1930 static const WCHAR szWindowsInstaller
[] = {
1931 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
1933 TRACE("%s\n", debugstr_w(szProduct
));
1935 if (!szProduct
|| !*szProduct
)
1936 return INSTALLSTATE_INVALIDARG
;
1938 if (lstrlenW(szProduct
) != GUID_SIZE
- 1)
1939 return INSTALLSTATE_INVALIDARG
;
1941 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
1942 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
1943 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1944 &prodkey
, FALSE
) != ERROR_SUCCESS
&&
1945 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
1946 &prodkey
, FALSE
) == ERROR_SUCCESS
)
1948 context
= MSIINSTALLCONTEXT_MACHINE
;
1951 r
= MSIREG_OpenInstallProps(szProduct
, context
, NULL
, &userdata
, FALSE
);
1952 if (r
!= ERROR_SUCCESS
)
1955 if (!msi_reg_get_val_dword(userdata
, szWindowsInstaller
, &val
))
1959 state
= INSTALLSTATE_DEFAULT
;
1961 state
= INSTALLSTATE_UNKNOWN
;
1966 state
= INSTALLSTATE_UNKNOWN
;
1969 state
= INSTALLSTATE_ABSENT
;
1972 RegCloseKey(prodkey
);
1973 RegCloseKey(userdata
);
1977 INSTALLUILEVEL WINAPI
MsiSetInternalUI(INSTALLUILEVEL dwUILevel
, HWND
*phWnd
)
1979 INSTALLUILEVEL old
= gUILevel
;
1980 HWND oldwnd
= gUIhwnd
;
1982 TRACE("%08x %p\n", dwUILevel
, phWnd
);
1984 gUILevel
= dwUILevel
;
1993 INSTALLUI_HANDLERA WINAPI
MsiSetExternalUIA(INSTALLUI_HANDLERA puiHandler
,
1994 DWORD dwMessageFilter
, LPVOID pvContext
)
1996 INSTALLUI_HANDLERA prev
= gUIHandlerA
;
1998 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2000 gUIHandlerA
= puiHandler
;
2002 gUIFilter
= dwMessageFilter
;
2003 gUIContext
= pvContext
;
2008 INSTALLUI_HANDLERW WINAPI
MsiSetExternalUIW(INSTALLUI_HANDLERW puiHandler
,
2009 DWORD dwMessageFilter
, LPVOID pvContext
)
2011 INSTALLUI_HANDLERW prev
= gUIHandlerW
;
2013 TRACE("%p %08x %p\n", puiHandler
, dwMessageFilter
, pvContext
);
2016 gUIHandlerW
= puiHandler
;
2017 gUIFilter
= dwMessageFilter
;
2018 gUIContext
= pvContext
;
2023 /******************************************************************
2024 * MsiLoadStringW [MSI.@]
2026 * Loads a string from MSI's string resources.
2030 * handle [I] only -1 is handled currently
2031 * id [I] id of the string to be loaded
2032 * lpBuffer [O] buffer for the string to be written to
2033 * nBufferMax [I] maximum size of the buffer in characters
2034 * lang [I] the preferred language for the string
2038 * If successful, this function returns the language id of the string loaded
2039 * If the function fails, the function returns zero.
2043 * The type of the first parameter is unknown. LoadString's prototype
2044 * suggests that it might be a module handle. I have made it an MSI handle
2045 * for starters, as -1 is an invalid MSI handle, but not an invalid module
2046 * handle. Maybe strings can be stored in an MSI database somehow.
2048 LANGID WINAPI
MsiLoadStringW( MSIHANDLE handle
, UINT id
, LPWSTR lpBuffer
,
2049 int nBufferMax
, LANGID lang
)
2056 TRACE("%d %u %p %d %d\n", handle
, id
, lpBuffer
, nBufferMax
, lang
);
2059 FIXME("don't know how to deal with handle = %08x\n", handle
);
2062 lang
= GetUserDefaultLangID();
2064 hres
= FindResourceExW( msi_hInstance
, (LPCWSTR
) RT_STRING
,
2068 hResData
= LoadResource( msi_hInstance
, hres
);
2071 p
= LockResource( hResData
);
2075 for (i
= 0; i
< (id
&0xf); i
++)
2079 if( nBufferMax
<= len
)
2082 memcpy( lpBuffer
, p
+1, len
* sizeof(WCHAR
));
2083 lpBuffer
[ len
] = 0;
2085 TRACE("found -> %s\n", debugstr_w(lpBuffer
));
2090 LANGID WINAPI
MsiLoadStringA( MSIHANDLE handle
, UINT id
, LPSTR lpBuffer
,
2091 int nBufferMax
, LANGID lang
)
2097 bufW
= msi_alloc(nBufferMax
*sizeof(WCHAR
));
2098 r
= MsiLoadStringW(handle
, id
, bufW
, nBufferMax
, lang
);
2101 len
= WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, NULL
, 0, NULL
, NULL
);
2102 if( len
<= nBufferMax
)
2103 WideCharToMultiByte( CP_ACP
, 0, bufW
, -1,
2104 lpBuffer
, nBufferMax
, NULL
, NULL
);
2112 INSTALLSTATE WINAPI
MsiLocateComponentA(LPCSTR szComponent
, LPSTR lpPathBuf
,
2115 char szProduct
[GUID_SIZE
];
2117 TRACE("%s %p %p\n", debugstr_a(szComponent
), lpPathBuf
, pcchBuf
);
2119 if (MsiGetProductCodeA( szComponent
, szProduct
) != ERROR_SUCCESS
)
2120 return INSTALLSTATE_UNKNOWN
;
2122 return MsiGetComponentPathA( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2125 INSTALLSTATE WINAPI
MsiLocateComponentW(LPCWSTR szComponent
, LPWSTR lpPathBuf
,
2128 WCHAR szProduct
[GUID_SIZE
];
2130 TRACE("%s %p %p\n", debugstr_w(szComponent
), lpPathBuf
, pcchBuf
);
2132 if (MsiGetProductCodeW( szComponent
, szProduct
) != ERROR_SUCCESS
)
2133 return INSTALLSTATE_UNKNOWN
;
2135 return MsiGetComponentPathW( szProduct
, szComponent
, lpPathBuf
, pcchBuf
);
2138 UINT WINAPI
MsiMessageBoxA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2139 WORD wLanguageId
, DWORD f
)
2141 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_a(lpText
), debugstr_a(lpCaption
),
2142 uType
, wLanguageId
, f
);
2143 return MessageBoxExA(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2146 UINT WINAPI
MsiMessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2147 WORD wLanguageId
, DWORD f
)
2149 FIXME("%p %s %s %u %08x %08x\n", hWnd
, debugstr_w(lpText
), debugstr_w(lpCaption
),
2150 uType
, wLanguageId
, f
);
2151 return MessageBoxExW(hWnd
,lpText
,lpCaption
,uType
,wLanguageId
);
2154 UINT WINAPI
MsiMessageBoxExA(HWND hWnd
, LPCSTR lpText
, LPCSTR lpCaption
, UINT uType
,
2155 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2157 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_a(lpText
),
2158 debugstr_a(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2159 return MessageBoxExA(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2162 UINT WINAPI
MsiMessageBoxExW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
,
2163 DWORD unknown
, WORD wLanguageId
, DWORD f
)
2165 FIXME("(%p, %s, %s, %u, 0x%08x, 0x%08x, 0x%08x): semi-stub\n", hWnd
, debugstr_w(lpText
),
2166 debugstr_w(lpCaption
), uType
, unknown
, wLanguageId
, f
);
2167 return MessageBoxExW(hWnd
, lpText
, lpCaption
, uType
, wLanguageId
);
2170 UINT WINAPI
MsiProvideAssemblyA( LPCSTR szAssemblyName
, LPCSTR szAppContext
,
2171 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPSTR lpPathBuf
,
2172 LPDWORD pcchPathBuf
)
2174 FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName
),
2175 debugstr_a(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2177 return ERROR_CALL_NOT_IMPLEMENTED
;
2180 UINT WINAPI
MsiProvideAssemblyW( LPCWSTR szAssemblyName
, LPCWSTR szAppContext
,
2181 DWORD dwInstallMode
, DWORD dwAssemblyInfo
, LPWSTR lpPathBuf
,
2182 LPDWORD pcchPathBuf
)
2184 FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName
),
2185 debugstr_w(szAppContext
), dwInstallMode
, dwAssemblyInfo
, lpPathBuf
,
2187 return ERROR_CALL_NOT_IMPLEMENTED
;
2190 UINT WINAPI
MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor
,
2191 LPSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2193 FIXME("%s %p %p %p\n", debugstr_a(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2194 return ERROR_CALL_NOT_IMPLEMENTED
;
2197 UINT WINAPI
MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor
,
2198 LPWSTR szPath
, LPDWORD pcchPath
, LPDWORD pcchArgs
)
2200 FIXME("%s %p %p %p\n", debugstr_w(szDescriptor
), szPath
, pcchPath
, pcchArgs
);
2201 return ERROR_CALL_NOT_IMPLEMENTED
;
2204 HRESULT WINAPI
MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath
,
2205 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
2206 LPDWORD pcbHashData
)
2208 FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath
), dwFlags
,
2209 ppcCertContext
, pbHashData
, pcbHashData
);
2210 return ERROR_CALL_NOT_IMPLEMENTED
;
2213 HRESULT WINAPI
MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath
,
2214 DWORD dwFlags
, PCCERT_CONTEXT
* ppcCertContext
, LPBYTE pbHashData
,
2215 LPDWORD pcbHashData
)
2217 FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath
), dwFlags
,
2218 ppcCertContext
, pbHashData
, pcbHashData
);
2219 return ERROR_CALL_NOT_IMPLEMENTED
;
2222 /******************************************************************
2223 * MsiGetProductPropertyA [MSI.@]
2225 UINT WINAPI
MsiGetProductPropertyA(MSIHANDLE hProduct
, LPCSTR szProperty
,
2226 LPSTR szValue
, LPDWORD pccbValue
)
2228 LPWSTR prop
= NULL
, val
= NULL
;
2232 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_a(szProperty
),
2233 szValue
, pccbValue
);
2235 if (szValue
&& !pccbValue
)
2236 return ERROR_INVALID_PARAMETER
;
2238 if (szProperty
) prop
= strdupAtoW(szProperty
);
2241 r
= MsiGetProductPropertyW(hProduct
, prop
, NULL
, &len
);
2242 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
2245 if (r
== ERROR_SUCCESS
)
2247 if (szValue
) *szValue
= '\0';
2248 if (pccbValue
) *pccbValue
= 0;
2252 val
= msi_alloc(++len
* sizeof(WCHAR
));
2255 r
= ERROR_OUTOFMEMORY
;
2259 r
= MsiGetProductPropertyW(hProduct
, prop
, val
, &len
);
2260 if (r
!= ERROR_SUCCESS
)
2263 len
= WideCharToMultiByte(CP_ACP
, 0, val
, -1, NULL
, 0, NULL
, NULL
);
2266 WideCharToMultiByte(CP_ACP
, 0, val
, -1, szValue
,
2267 *pccbValue
, NULL
, NULL
);
2271 if (len
> *pccbValue
)
2272 r
= ERROR_MORE_DATA
;
2274 *pccbValue
= len
- 1;
2284 /******************************************************************
2285 * MsiGetProductPropertyW [MSI.@]
2287 UINT WINAPI
MsiGetProductPropertyW(MSIHANDLE hProduct
, LPCWSTR szProperty
,
2288 LPWSTR szValue
, LPDWORD pccbValue
)
2290 MSIPACKAGE
*package
;
2291 MSIQUERY
*view
= NULL
;
2292 MSIRECORD
*rec
= NULL
;
2296 static const WCHAR query
[] = {
2297 'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
2298 '`','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
2299 '`','P','r','o','p','e','r','t','y','`','=','\'','%','s','\'',0};
2301 TRACE("(%d, %s, %p, %p)\n", hProduct
, debugstr_w(szProperty
),
2302 szValue
, pccbValue
);
2305 return ERROR_INVALID_PARAMETER
;
2307 if (szValue
&& !pccbValue
)
2308 return ERROR_INVALID_PARAMETER
;
2310 package
= msihandle2msiinfo(hProduct
, MSIHANDLETYPE_PACKAGE
);
2312 return ERROR_INVALID_HANDLE
;
2314 r
= MSI_OpenQuery(package
->db
, &view
, query
, szProperty
);
2315 if (r
!= ERROR_SUCCESS
)
2318 r
= MSI_ViewExecute(view
, 0);
2319 if (r
!= ERROR_SUCCESS
)
2322 r
= MSI_ViewFetch(view
, &rec
);
2323 if (r
!= ERROR_SUCCESS
)
2326 val
= MSI_RecordGetString(rec
, 2);
2330 if (lstrlenW(val
) >= *pccbValue
)
2332 lstrcpynW(szValue
, val
, *pccbValue
);
2333 *pccbValue
= lstrlenW(val
);
2334 r
= ERROR_MORE_DATA
;
2338 lstrcpyW(szValue
, val
);
2339 *pccbValue
= lstrlenW(val
);
2346 MSI_ViewClose(view
);
2347 msiobj_release(&view
->hdr
);
2348 if (rec
) msiobj_release(&rec
->hdr
);
2353 if (szValue
) *szValue
= '\0';
2354 if (pccbValue
) *pccbValue
= 0;
2361 UINT WINAPI
MsiVerifyPackageA( LPCSTR szPackage
)
2364 LPWSTR szPack
= NULL
;
2366 TRACE("%s\n", debugstr_a(szPackage
) );
2370 szPack
= strdupAtoW( szPackage
);
2372 return ERROR_OUTOFMEMORY
;
2375 r
= MsiVerifyPackageW( szPack
);
2382 UINT WINAPI
MsiVerifyPackageW( LPCWSTR szPackage
)
2387 TRACE("%s\n", debugstr_w(szPackage
) );
2389 r
= MsiOpenDatabaseW( szPackage
, MSIDBOPEN_READONLY
, &handle
);
2390 MsiCloseHandle( handle
);
2395 static INSTALLSTATE
MSI_GetComponentPath(LPCWSTR szProduct
, LPCWSTR szComponent
,
2396 awstring
* lpPathBuf
, LPDWORD pcchBuf
)
2398 WCHAR squished_pc
[GUID_SIZE
];
2399 WCHAR squished_comp
[GUID_SIZE
];
2405 static const WCHAR wininstaller
[] = {
2406 'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
2408 TRACE("%s %s %p %p\n", debugstr_w(szProduct
),
2409 debugstr_w(szComponent
), lpPathBuf
->str
.w
, pcchBuf
);
2411 if (!szProduct
|| !szComponent
)
2412 return INSTALLSTATE_INVALIDARG
;
2414 if (lpPathBuf
->str
.w
&& !pcchBuf
)
2415 return INSTALLSTATE_INVALIDARG
;
2417 if (!squash_guid(szProduct
, squished_pc
) ||
2418 !squash_guid(szComponent
, squished_comp
))
2419 return INSTALLSTATE_INVALIDARG
;
2421 state
= INSTALLSTATE_UNKNOWN
;
2423 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2424 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2426 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2429 state
= INSTALLSTATE_ABSENT
;
2431 if ((MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
, NULL
,
2432 &hkey
, FALSE
) == ERROR_SUCCESS
||
2433 MSIREG_OpenUserDataProductKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2434 NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
) &&
2435 msi_reg_get_val_dword(hkey
, wininstaller
, &version
) &&
2436 GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2439 state
= INSTALLSTATE_LOCAL
;
2443 if (state
!= INSTALLSTATE_LOCAL
&&
2444 (MSIREG_OpenProductKey(szProduct
, NULL
,
2445 MSIINSTALLCONTEXT_USERUNMANAGED
,
2446 &hkey
, FALSE
) == ERROR_SUCCESS
||
2447 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
2448 &hkey
, FALSE
) == ERROR_SUCCESS
))
2452 if (MSIREG_OpenUserDataComponentKey(szComponent
, szLocalSid
, &hkey
, FALSE
) == ERROR_SUCCESS
||
2453 MSIREG_OpenUserDataComponentKey(szComponent
, NULL
, &hkey
, FALSE
) == ERROR_SUCCESS
)
2456 path
= msi_reg_get_val_str(hkey
, squished_pc
);
2459 state
= INSTALLSTATE_ABSENT
;
2461 if (GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
)
2462 state
= INSTALLSTATE_LOCAL
;
2467 return INSTALLSTATE_UNKNOWN
;
2469 if (state
== INSTALLSTATE_LOCAL
&& !*path
)
2470 state
= INSTALLSTATE_NOTUSED
;
2472 msi_strcpy_to_awstring(path
, lpPathBuf
, pcchBuf
);
2477 /******************************************************************
2478 * MsiGetComponentPathW [MSI.@]
2480 INSTALLSTATE WINAPI
MsiGetComponentPathW(LPCWSTR szProduct
, LPCWSTR szComponent
,
2481 LPWSTR lpPathBuf
, LPDWORD pcchBuf
)
2485 path
.unicode
= TRUE
;
2486 path
.str
.w
= lpPathBuf
;
2488 return MSI_GetComponentPath( szProduct
, szComponent
, &path
, pcchBuf
);
2491 /******************************************************************
2492 * MsiGetComponentPathA [MSI.@]
2494 INSTALLSTATE WINAPI
MsiGetComponentPathA(LPCSTR szProduct
, LPCSTR szComponent
,
2495 LPSTR lpPathBuf
, LPDWORD pcchBuf
)
2497 LPWSTR szwProduct
, szwComponent
= NULL
;
2498 INSTALLSTATE r
= INSTALLSTATE_UNKNOWN
;
2501 szwProduct
= strdupAtoW( szProduct
);
2502 if( szProduct
&& !szwProduct
)
2505 szwComponent
= strdupAtoW( szComponent
);
2506 if( szComponent
&& !szwComponent
)
2509 path
.unicode
= FALSE
;
2510 path
.str
.a
= lpPathBuf
;
2512 r
= MSI_GetComponentPath( szwProduct
, szwComponent
, &path
, pcchBuf
);
2515 msi_free( szwProduct
);
2516 msi_free( szwComponent
);
2521 /******************************************************************
2522 * MsiQueryFeatureStateA [MSI.@]
2524 INSTALLSTATE WINAPI
MsiQueryFeatureStateA(LPCSTR szProduct
, LPCSTR szFeature
)
2526 LPWSTR szwProduct
= NULL
, szwFeature
= NULL
;
2527 INSTALLSTATE rc
= INSTALLSTATE_UNKNOWN
;
2529 szwProduct
= strdupAtoW( szProduct
);
2530 if ( szProduct
&& !szwProduct
)
2533 szwFeature
= strdupAtoW( szFeature
);
2534 if ( szFeature
&& !szwFeature
)
2537 rc
= MsiQueryFeatureStateW(szwProduct
, szwFeature
);
2540 msi_free( szwProduct
);
2541 msi_free( szwFeature
);
2546 /******************************************************************
2547 * MsiQueryFeatureStateW [MSI.@]
2549 * Checks the state of a feature
2552 * szProduct [I] Product's GUID string
2553 * szFeature [I] Feature's GUID string
2556 * INSTALLSTATE_LOCAL Feature is installed and usable
2557 * INSTALLSTATE_ABSENT Feature is absent
2558 * INSTALLSTATE_ADVERTISED Feature should be installed on demand
2559 * INSTALLSTATE_UNKNOWN An error occurred
2560 * INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
2563 INSTALLSTATE WINAPI
MsiQueryFeatureStateW(LPCWSTR szProduct
, LPCWSTR szFeature
)
2565 WCHAR squishProduct
[33], comp
[GUID_SIZE
];
2567 LPWSTR components
, p
, parent_feature
, path
;
2571 BOOL missing
= FALSE
;
2572 BOOL machine
= FALSE
;
2573 BOOL source
= FALSE
;
2575 TRACE("%s %s\n", debugstr_w(szProduct
), debugstr_w(szFeature
));
2577 if (!szProduct
|| !szFeature
)
2578 return INSTALLSTATE_INVALIDARG
;
2580 if (!squash_guid( szProduct
, squishProduct
))
2581 return INSTALLSTATE_INVALIDARG
;
2583 if (MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERMANAGED
,
2584 &hkey
, FALSE
) != ERROR_SUCCESS
&&
2585 MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2586 &hkey
, FALSE
) != ERROR_SUCCESS
)
2588 rc
= MSIREG_OpenFeaturesKey(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
2590 if (rc
!= ERROR_SUCCESS
)
2591 return INSTALLSTATE_UNKNOWN
;
2596 parent_feature
= msi_reg_get_val_str( hkey
, szFeature
);
2599 if (!parent_feature
)
2600 return INSTALLSTATE_UNKNOWN
;
2602 r
= (parent_feature
[0] == 6) ? INSTALLSTATE_ABSENT
: INSTALLSTATE_LOCAL
;
2603 msi_free(parent_feature
);
2604 if (r
== INSTALLSTATE_ABSENT
)
2608 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
2609 MSIINSTALLCONTEXT_MACHINE
,
2612 rc
= MSIREG_OpenUserDataFeaturesKey(szProduct
,
2613 MSIINSTALLCONTEXT_USERUNMANAGED
,
2616 if (rc
!= ERROR_SUCCESS
)
2617 return INSTALLSTATE_ADVERTISED
;
2619 components
= msi_reg_get_val_str( hkey
, szFeature
);
2622 TRACE("rc = %d buffer = %s\n", rc
, debugstr_w(components
));
2625 return INSTALLSTATE_ADVERTISED
;
2627 for( p
= components
; *p
&& *p
!= 2 ; p
+= 20)
2629 if (!decode_base85_guid( p
, &guid
))
2631 if (p
!= components
)
2634 msi_free(components
);
2635 return INSTALLSTATE_BADCONFIG
;
2638 StringFromGUID2(&guid
, comp
, GUID_SIZE
);
2641 rc
= MSIREG_OpenUserDataComponentKey(comp
, szLocalSid
, &hkey
, FALSE
);
2643 rc
= MSIREG_OpenUserDataComponentKey(comp
, NULL
, &hkey
, FALSE
);
2645 if (rc
!= ERROR_SUCCESS
)
2647 msi_free(components
);
2648 return INSTALLSTATE_ADVERTISED
;
2651 path
= msi_reg_get_val_str(hkey
, squishProduct
);
2654 else if (lstrlenW(path
) > 2 &&
2655 path
[0] >= '0' && path
[0] <= '9' &&
2656 path
[1] >= '0' && path
[1] <= '9')
2664 TRACE("%s %s -> %d\n", debugstr_w(szProduct
), debugstr_w(szFeature
), r
);
2665 msi_free(components
);
2668 return INSTALLSTATE_ADVERTISED
;
2671 return INSTALLSTATE_SOURCE
;
2673 return INSTALLSTATE_LOCAL
;
2676 /******************************************************************
2677 * MsiGetFileVersionA [MSI.@]
2679 UINT WINAPI
MsiGetFileVersionA(LPCSTR szFilePath
, LPSTR lpVersionBuf
,
2680 LPDWORD pcchVersionBuf
, LPSTR lpLangBuf
, LPDWORD pcchLangBuf
)
2682 LPWSTR szwFilePath
= NULL
, lpwVersionBuff
= NULL
, lpwLangBuff
= NULL
;
2683 UINT ret
= ERROR_OUTOFMEMORY
;
2685 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
2686 (lpLangBuf
&& !pcchLangBuf
))
2687 return ERROR_INVALID_PARAMETER
;
2691 szwFilePath
= strdupAtoW( szFilePath
);
2696 if( lpVersionBuf
&& pcchVersionBuf
&& *pcchVersionBuf
)
2698 lpwVersionBuff
= msi_alloc(*pcchVersionBuf
*sizeof(WCHAR
));
2699 if( !lpwVersionBuff
)
2703 if( lpLangBuf
&& pcchLangBuf
&& *pcchLangBuf
)
2705 lpwLangBuff
= msi_alloc(*pcchLangBuf
*sizeof(WCHAR
));
2710 ret
= MsiGetFileVersionW(szwFilePath
, lpwVersionBuff
, pcchVersionBuf
,
2711 lpwLangBuff
, pcchLangBuf
);
2713 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwVersionBuff
)
2714 WideCharToMultiByte(CP_ACP
, 0, lpwVersionBuff
, -1,
2715 lpVersionBuf
, *pcchVersionBuf
+ 1, NULL
, NULL
);
2716 if( (ret
== ERROR_SUCCESS
|| ret
== ERROR_MORE_DATA
) && lpwLangBuff
)
2717 WideCharToMultiByte(CP_ACP
, 0, lpwLangBuff
, -1,
2718 lpLangBuf
, *pcchLangBuf
+ 1, NULL
, NULL
);
2721 msi_free(szwFilePath
);
2722 msi_free(lpwVersionBuff
);
2723 msi_free(lpwLangBuff
);
2728 /******************************************************************
2729 * MsiGetFileVersionW [MSI.@]
2731 UINT WINAPI
MsiGetFileVersionW(LPCWSTR szFilePath
, LPWSTR lpVersionBuf
,
2732 LPDWORD pcchVersionBuf
, LPWSTR lpLangBuf
, LPDWORD pcchLangBuf
)
2734 static const WCHAR szVersionResource
[] = {'\\',0};
2735 static const WCHAR szVersionFormat
[] = {
2736 '%','d','.','%','d','.','%','d','.','%','d',0};
2737 static const WCHAR szLangResource
[] = {
2738 '\\','V','a','r','F','i','l','e','I','n','f','o','\\',
2739 'T','r','a','n','s','l','a','t','i','o','n',0};
2740 static const WCHAR szLangFormat
[] = {'%','d',0};
2742 DWORD dwVerLen
, gle
;
2743 LPVOID lpVer
= NULL
;
2744 VS_FIXEDFILEINFO
*ffi
;
2749 TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath
),
2750 lpVersionBuf
, pcchVersionBuf
?*pcchVersionBuf
:0,
2751 lpLangBuf
, pcchLangBuf
?*pcchLangBuf
:0);
2753 if ((lpVersionBuf
&& !pcchVersionBuf
) ||
2754 (lpLangBuf
&& !pcchLangBuf
))
2755 return ERROR_INVALID_PARAMETER
;
2757 dwVerLen
= GetFileVersionInfoSizeW(szFilePath
, NULL
);
2760 gle
= GetLastError();
2761 if (gle
== ERROR_BAD_PATHNAME
)
2762 return ERROR_FILE_NOT_FOUND
;
2763 else if (gle
== ERROR_RESOURCE_DATA_NOT_FOUND
)
2764 return ERROR_FILE_INVALID
;
2769 lpVer
= msi_alloc(dwVerLen
);
2772 ret
= ERROR_OUTOFMEMORY
;
2776 if( !GetFileVersionInfoW(szFilePath
, 0, dwVerLen
, lpVer
) )
2778 ret
= GetLastError();
2784 if( VerQueryValueW(lpVer
, szVersionResource
, (LPVOID
*)&ffi
, &puLen
) &&
2787 wsprintfW(tmp
, szVersionFormat
,
2788 HIWORD(ffi
->dwFileVersionMS
), LOWORD(ffi
->dwFileVersionMS
),
2789 HIWORD(ffi
->dwFileVersionLS
), LOWORD(ffi
->dwFileVersionLS
));
2790 if (lpVersionBuf
) lstrcpynW(lpVersionBuf
, tmp
, *pcchVersionBuf
);
2792 if (strlenW(tmp
) >= *pcchVersionBuf
)
2793 ret
= ERROR_MORE_DATA
;
2795 *pcchVersionBuf
= lstrlenW(tmp
);
2799 if (lpVersionBuf
) *lpVersionBuf
= 0;
2800 *pcchVersionBuf
= 0;
2806 if (VerQueryValueW(lpVer
, szLangResource
, (LPVOID
*)&lang
, &puLen
) &&
2809 wsprintfW(tmp
, szLangFormat
, *lang
);
2810 if (lpLangBuf
) lstrcpynW(lpLangBuf
, tmp
, *pcchLangBuf
);
2812 if (strlenW(tmp
) >= *pcchLangBuf
)
2813 ret
= ERROR_MORE_DATA
;
2815 *pcchLangBuf
= lstrlenW(tmp
);
2819 if (lpLangBuf
) *lpLangBuf
= 0;
2829 /***********************************************************************
2830 * MsiGetFeatureUsageW [MSI.@]
2832 UINT WINAPI
MsiGetFeatureUsageW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2833 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
2835 FIXME("%s %s %p %p\n",debugstr_w(szProduct
), debugstr_w(szFeature
),
2836 pdwUseCount
, pwDateUsed
);
2837 return ERROR_CALL_NOT_IMPLEMENTED
;
2840 /***********************************************************************
2841 * MsiGetFeatureUsageA [MSI.@]
2843 UINT WINAPI
MsiGetFeatureUsageA( LPCSTR szProduct
, LPCSTR szFeature
,
2844 LPDWORD pdwUseCount
, LPWORD pwDateUsed
)
2846 LPWSTR prod
= NULL
, feat
= NULL
;
2847 UINT ret
= ERROR_OUTOFMEMORY
;
2849 TRACE("%s %s %p %p\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2850 pdwUseCount
, pwDateUsed
);
2852 prod
= strdupAtoW( szProduct
);
2853 if (szProduct
&& !prod
)
2856 feat
= strdupAtoW( szFeature
);
2857 if (szFeature
&& !feat
)
2860 ret
= MsiGetFeatureUsageW( prod
, feat
, pdwUseCount
, pwDateUsed
);
2869 /***********************************************************************
2870 * MsiUseFeatureExW [MSI.@]
2872 INSTALLSTATE WINAPI
MsiUseFeatureExW( LPCWSTR szProduct
, LPCWSTR szFeature
,
2873 DWORD dwInstallMode
, DWORD dwReserved
)
2877 TRACE("%s %s %i %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
2878 dwInstallMode
, dwReserved
);
2880 state
= MsiQueryFeatureStateW( szProduct
, szFeature
);
2883 return INSTALLSTATE_INVALIDARG
;
2885 if (state
== INSTALLSTATE_LOCAL
&& dwInstallMode
!= INSTALLMODE_NODETECTION
)
2887 FIXME("mark product %s feature %s as used\n",
2888 debugstr_w(szProduct
), debugstr_w(szFeature
) );
2894 /***********************************************************************
2895 * MsiUseFeatureExA [MSI.@]
2897 INSTALLSTATE WINAPI
MsiUseFeatureExA( LPCSTR szProduct
, LPCSTR szFeature
,
2898 DWORD dwInstallMode
, DWORD dwReserved
)
2900 INSTALLSTATE ret
= INSTALLSTATE_UNKNOWN
;
2901 LPWSTR prod
= NULL
, feat
= NULL
;
2903 TRACE("%s %s %i %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
2904 dwInstallMode
, dwReserved
);
2906 prod
= strdupAtoW( szProduct
);
2907 if (szProduct
&& !prod
)
2910 feat
= strdupAtoW( szFeature
);
2911 if (szFeature
&& !feat
)
2914 ret
= MsiUseFeatureExW( prod
, feat
, dwInstallMode
, dwReserved
);
2923 /***********************************************************************
2924 * MsiUseFeatureW [MSI.@]
2926 INSTALLSTATE WINAPI
MsiUseFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
)
2928 return MsiUseFeatureExW(szProduct
, szFeature
, 0, 0);
2931 /***********************************************************************
2932 * MsiUseFeatureA [MSI.@]
2934 INSTALLSTATE WINAPI
MsiUseFeatureA( LPCSTR szProduct
, LPCSTR szFeature
)
2936 return MsiUseFeatureExA(szProduct
, szFeature
, 0, 0);
2939 /***********************************************************************
2940 * MSI_ProvideQualifiedComponentEx [internal]
2942 static UINT
MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent
,
2943 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
2944 DWORD Unused1
, DWORD Unused2
, awstring
*lpPathBuf
,
2945 LPDWORD pcchPathBuf
)
2947 WCHAR product
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1],
2948 feature
[MAX_FEATURE_CHARS
+1];
2954 TRACE("%s %s %i %s %i %i %p %p\n", debugstr_w(szComponent
),
2955 debugstr_w(szQualifier
), dwInstallMode
, debugstr_w(szProduct
),
2956 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
2958 rc
= MSIREG_OpenUserComponentsKey(szComponent
, &hkey
, FALSE
);
2959 if (rc
!= ERROR_SUCCESS
)
2960 return ERROR_INDEX_ABSENT
;
2962 info
= msi_reg_get_val_str( hkey
, szQualifier
);
2966 return ERROR_INDEX_ABSENT
;
2968 MsiDecomposeDescriptorW(info
, product
, feature
, component
, &sz
);
2971 rc
= MSI_GetComponentPath(product
, component
, lpPathBuf
, pcchPathBuf
);
2973 rc
= MSI_GetComponentPath(szProduct
, component
, lpPathBuf
, pcchPathBuf
);
2977 if (rc
!= INSTALLSTATE_LOCAL
)
2978 return ERROR_FILE_NOT_FOUND
;
2980 return ERROR_SUCCESS
;
2983 /***********************************************************************
2984 * MsiProvideQualifiedComponentExW [MSI.@]
2986 UINT WINAPI
MsiProvideQualifiedComponentExW(LPCWSTR szComponent
,
2987 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPCWSTR szProduct
,
2988 DWORD Unused1
, DWORD Unused2
, LPWSTR lpPathBuf
,
2989 LPDWORD pcchPathBuf
)
2993 path
.unicode
= TRUE
;
2994 path
.str
.w
= lpPathBuf
;
2996 return MSI_ProvideQualifiedComponentEx(szComponent
, szQualifier
,
2997 dwInstallMode
, szProduct
, Unused1
, Unused2
, &path
, pcchPathBuf
);
3000 /***********************************************************************
3001 * MsiProvideQualifiedComponentExA [MSI.@]
3003 UINT WINAPI
MsiProvideQualifiedComponentExA(LPCSTR szComponent
,
3004 LPCSTR szQualifier
, DWORD dwInstallMode
, LPCSTR szProduct
,
3005 DWORD Unused1
, DWORD Unused2
, LPSTR lpPathBuf
,
3006 LPDWORD pcchPathBuf
)
3008 LPWSTR szwComponent
, szwQualifier
= NULL
, szwProduct
= NULL
;
3009 UINT r
= ERROR_OUTOFMEMORY
;
3012 TRACE("%s %s %u %s %u %u %p %p\n", debugstr_a(szComponent
),
3013 debugstr_a(szQualifier
), dwInstallMode
, debugstr_a(szProduct
),
3014 Unused1
, Unused2
, lpPathBuf
, pcchPathBuf
);
3016 szwComponent
= strdupAtoW( szComponent
);
3017 if (szComponent
&& !szwComponent
)
3020 szwQualifier
= strdupAtoW( szQualifier
);
3021 if (szQualifier
&& !szwQualifier
)
3024 szwProduct
= strdupAtoW( szProduct
);
3025 if (szProduct
&& !szwProduct
)
3028 path
.unicode
= FALSE
;
3029 path
.str
.a
= lpPathBuf
;
3031 r
= MSI_ProvideQualifiedComponentEx(szwComponent
, szwQualifier
,
3032 dwInstallMode
, szwProduct
, Unused1
,
3033 Unused2
, &path
, pcchPathBuf
);
3035 msi_free(szwProduct
);
3036 msi_free(szwComponent
);
3037 msi_free(szwQualifier
);
3042 /***********************************************************************
3043 * MsiProvideQualifiedComponentW [MSI.@]
3045 UINT WINAPI
MsiProvideQualifiedComponentW( LPCWSTR szComponent
,
3046 LPCWSTR szQualifier
, DWORD dwInstallMode
, LPWSTR lpPathBuf
,
3047 LPDWORD pcchPathBuf
)
3049 return MsiProvideQualifiedComponentExW(szComponent
, szQualifier
,
3050 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3053 /***********************************************************************
3054 * MsiProvideQualifiedComponentA [MSI.@]
3056 UINT WINAPI
MsiProvideQualifiedComponentA( LPCSTR szComponent
,
3057 LPCSTR szQualifier
, DWORD dwInstallMode
, LPSTR lpPathBuf
,
3058 LPDWORD pcchPathBuf
)
3060 return MsiProvideQualifiedComponentExA(szComponent
, szQualifier
,
3061 dwInstallMode
, NULL
, 0, 0, lpPathBuf
, pcchPathBuf
);
3064 /***********************************************************************
3065 * MSI_GetUserInfo [internal]
3067 static USERINFOSTATE
MSI_GetUserInfo(LPCWSTR szProduct
,
3068 awstring
*lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3069 awstring
*lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3070 awstring
*lpSerialBuf
, LPDWORD pcchSerialBuf
)
3072 WCHAR squished_pc
[SQUISH_GUID_SIZE
];
3073 LPWSTR user
, org
, serial
;
3074 USERINFOSTATE state
;
3079 TRACE("%s %p %p %p %p %p %p\n", debugstr_w(szProduct
), lpUserNameBuf
,
3080 pcchUserNameBuf
, lpOrgNameBuf
, pcchOrgNameBuf
, lpSerialBuf
,
3083 if (!szProduct
|| !squash_guid(szProduct
, squished_pc
))
3084 return USERINFOSTATE_INVALIDARG
;
3086 if (MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
3087 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3088 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3089 &hkey
, FALSE
) != ERROR_SUCCESS
&&
3090 MSIREG_OpenProductKey(szProduct
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3091 &hkey
, FALSE
) != ERROR_SUCCESS
)
3093 return USERINFOSTATE_UNKNOWN
;
3096 if (MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3097 NULL
, &props
, FALSE
) != ERROR_SUCCESS
&&
3098 MSIREG_OpenInstallProps(szProduct
, MSIINSTALLCONTEXT_MACHINE
,
3099 NULL
, &props
, FALSE
) != ERROR_SUCCESS
)
3102 return USERINFOSTATE_ABSENT
;
3105 user
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGOWNERW
);
3106 org
= msi_reg_get_val_str(props
, INSTALLPROPERTY_REGCOMPANYW
);
3107 serial
= msi_reg_get_val_str(props
, INSTALLPROPERTY_PRODUCTIDW
);
3108 state
= USERINFOSTATE_ABSENT
;
3114 state
= USERINFOSTATE_PRESENT
;
3116 if (pcchUserNameBuf
)
3118 if (lpUserNameBuf
&& !user
)
3120 (*pcchUserNameBuf
)--;
3124 r
= msi_strcpy_to_awstring(user
, lpUserNameBuf
, pcchUserNameBuf
);
3125 if (r
== ERROR_MORE_DATA
)
3127 state
= USERINFOSTATE_MOREDATA
;
3135 if (!orgptr
) orgptr
= szEmpty
;
3137 r
= msi_strcpy_to_awstring(orgptr
, lpOrgNameBuf
, pcchOrgNameBuf
);
3138 if (r
== ERROR_MORE_DATA
)
3140 state
= USERINFOSTATE_MOREDATA
;
3153 r
= msi_strcpy_to_awstring(serial
, lpSerialBuf
, pcchSerialBuf
);
3154 if (r
== ERROR_MORE_DATA
)
3155 state
= USERINFOSTATE_MOREDATA
;
3166 /***********************************************************************
3167 * MsiGetUserInfoW [MSI.@]
3169 USERINFOSTATE WINAPI
MsiGetUserInfoW(LPCWSTR szProduct
,
3170 LPWSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3171 LPWSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3172 LPWSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3174 awstring user
, org
, serial
;
3176 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3177 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3178 (lpSerialBuf
&& !pcchSerialBuf
))
3179 return USERINFOSTATE_INVALIDARG
;
3181 user
.unicode
= TRUE
;
3182 user
.str
.w
= lpUserNameBuf
;
3184 org
.str
.w
= lpOrgNameBuf
;
3185 serial
.unicode
= TRUE
;
3186 serial
.str
.w
= lpSerialBuf
;
3188 return MSI_GetUserInfo( szProduct
, &user
, pcchUserNameBuf
,
3189 &org
, pcchOrgNameBuf
,
3190 &serial
, pcchSerialBuf
);
3193 USERINFOSTATE WINAPI
MsiGetUserInfoA(LPCSTR szProduct
,
3194 LPSTR lpUserNameBuf
, LPDWORD pcchUserNameBuf
,
3195 LPSTR lpOrgNameBuf
, LPDWORD pcchOrgNameBuf
,
3196 LPSTR lpSerialBuf
, LPDWORD pcchSerialBuf
)
3198 awstring user
, org
, serial
;
3202 if ((lpUserNameBuf
&& !pcchUserNameBuf
) ||
3203 (lpOrgNameBuf
&& !pcchOrgNameBuf
) ||
3204 (lpSerialBuf
&& !pcchSerialBuf
))
3205 return USERINFOSTATE_INVALIDARG
;
3207 prod
= strdupAtoW( szProduct
);
3208 if (szProduct
&& !prod
)
3209 return ERROR_OUTOFMEMORY
;
3211 user
.unicode
= FALSE
;
3212 user
.str
.a
= lpUserNameBuf
;
3213 org
.unicode
= FALSE
;
3214 org
.str
.a
= lpOrgNameBuf
;
3215 serial
.unicode
= FALSE
;
3216 serial
.str
.a
= lpSerialBuf
;
3218 r
= MSI_GetUserInfo( prod
, &user
, pcchUserNameBuf
,
3219 &org
, pcchOrgNameBuf
,
3220 &serial
, pcchSerialBuf
);
3227 UINT WINAPI
MsiCollectUserInfoW(LPCWSTR szProduct
)
3231 MSIPACKAGE
*package
;
3232 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3234 TRACE("(%s)\n",debugstr_w(szProduct
));
3236 rc
= MsiOpenProductW(szProduct
,&handle
);
3237 if (rc
!= ERROR_SUCCESS
)
3238 return ERROR_INVALID_PARAMETER
;
3240 /* MsiCollectUserInfo cannot be called from a custom action. */
3241 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3243 return ERROR_CALL_NOT_IMPLEMENTED
;
3245 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
3246 msiobj_release( &package
->hdr
);
3248 MsiCloseHandle(handle
);
3253 UINT WINAPI
MsiCollectUserInfoA(LPCSTR szProduct
)
3257 MSIPACKAGE
*package
;
3258 static const WCHAR szFirstRun
[] = {'F','i','r','s','t','R','u','n',0};
3260 TRACE("(%s)\n",debugstr_a(szProduct
));
3262 rc
= MsiOpenProductA(szProduct
,&handle
);
3263 if (rc
!= ERROR_SUCCESS
)
3264 return ERROR_INVALID_PARAMETER
;
3266 /* MsiCollectUserInfo cannot be called from a custom action. */
3267 package
= msihandle2msiinfo(handle
, MSIHANDLETYPE_PACKAGE
);
3269 return ERROR_CALL_NOT_IMPLEMENTED
;
3271 rc
= ACTION_PerformUIAction(package
, szFirstRun
, -1);
3272 msiobj_release( &package
->hdr
);
3274 MsiCloseHandle(handle
);
3279 /***********************************************************************
3280 * MsiConfigureFeatureA [MSI.@]
3282 UINT WINAPI
MsiConfigureFeatureA(LPCSTR szProduct
, LPCSTR szFeature
, INSTALLSTATE eInstallState
)
3284 LPWSTR prod
, feat
= NULL
;
3285 UINT r
= ERROR_OUTOFMEMORY
;
3287 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
), eInstallState
);
3289 prod
= strdupAtoW( szProduct
);
3290 if (szProduct
&& !prod
)
3293 feat
= strdupAtoW( szFeature
);
3294 if (szFeature
&& !feat
)
3297 r
= MsiConfigureFeatureW(prod
, feat
, eInstallState
);
3306 /***********************************************************************
3307 * MsiConfigureFeatureW [MSI.@]
3309 UINT WINAPI
MsiConfigureFeatureW(LPCWSTR szProduct
, LPCWSTR szFeature
, INSTALLSTATE eInstallState
)
3311 static const WCHAR szCostInit
[] = { 'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0 };
3312 MSIPACKAGE
*package
= NULL
;
3314 WCHAR sourcepath
[MAX_PATH
], filename
[MAX_PATH
];
3317 TRACE("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
), eInstallState
);
3319 if (!szProduct
|| !szFeature
)
3320 return ERROR_INVALID_PARAMETER
;
3322 switch (eInstallState
)
3324 case INSTALLSTATE_DEFAULT
:
3325 /* FIXME: how do we figure out the default location? */
3326 eInstallState
= INSTALLSTATE_LOCAL
;
3328 case INSTALLSTATE_LOCAL
:
3329 case INSTALLSTATE_SOURCE
:
3330 case INSTALLSTATE_ABSENT
:
3331 case INSTALLSTATE_ADVERTISED
:
3334 return ERROR_INVALID_PARAMETER
;
3337 r
= MSI_OpenProductW( szProduct
, &package
);
3338 if (r
!= ERROR_SUCCESS
)
3341 sz
= sizeof(sourcepath
);
3342 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3343 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3345 sz
= sizeof(filename
);
3346 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3347 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3349 lstrcatW( sourcepath
, filename
);
3351 MsiSetInternalUI( INSTALLUILEVEL_BASIC
, NULL
);
3353 r
= ACTION_PerformUIAction( package
, szCostInit
, -1 );
3354 if (r
!= ERROR_SUCCESS
)
3357 r
= MSI_SetFeatureStateW( package
, szFeature
, eInstallState
);
3358 if (r
!= ERROR_SUCCESS
)
3361 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3364 msiobj_release( &package
->hdr
);
3369 /***********************************************************************
3370 * MsiCreateAndVerifyInstallerDirectory [MSI.@]
3372 * Notes: undocumented
3374 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory(DWORD dwReserved
)
3376 WCHAR path
[MAX_PATH
];
3378 TRACE("%d\n", dwReserved
);
3382 FIXME("dwReserved=%d\n", dwReserved
);
3383 return ERROR_INVALID_PARAMETER
;
3386 if (!GetWindowsDirectoryW(path
, MAX_PATH
))
3387 return ERROR_FUNCTION_FAILED
;
3389 lstrcatW(path
, installerW
);
3391 if (!CreateDirectoryW(path
, NULL
))
3392 return ERROR_FUNCTION_FAILED
;
3394 return ERROR_SUCCESS
;
3397 /***********************************************************************
3398 * MsiGetShortcutTargetA [MSI.@]
3400 UINT WINAPI
MsiGetShortcutTargetA( LPCSTR szShortcutTarget
,
3401 LPSTR szProductCode
, LPSTR szFeatureId
,
3402 LPSTR szComponentCode
)
3405 const int len
= MAX_FEATURE_CHARS
+1;
3406 WCHAR product
[MAX_FEATURE_CHARS
+1], feature
[MAX_FEATURE_CHARS
+1], component
[MAX_FEATURE_CHARS
+1];
3409 target
= strdupAtoW( szShortcutTarget
);
3410 if (szShortcutTarget
&& !target
)
3411 return ERROR_OUTOFMEMORY
;
3415 r
= MsiGetShortcutTargetW( target
, product
, feature
, component
);
3417 if (r
== ERROR_SUCCESS
)
3419 WideCharToMultiByte( CP_ACP
, 0, product
, -1, szProductCode
, len
, NULL
, NULL
);
3420 WideCharToMultiByte( CP_ACP
, 0, feature
, -1, szFeatureId
, len
, NULL
, NULL
);
3421 WideCharToMultiByte( CP_ACP
, 0, component
, -1, szComponentCode
, len
, NULL
, NULL
);
3426 /***********************************************************************
3427 * MsiGetShortcutTargetW [MSI.@]
3429 UINT WINAPI
MsiGetShortcutTargetW( LPCWSTR szShortcutTarget
,
3430 LPWSTR szProductCode
, LPWSTR szFeatureId
,
3431 LPWSTR szComponentCode
)
3433 IShellLinkDataList
*dl
= NULL
;
3434 IPersistFile
*pf
= NULL
;
3435 LPEXP_DARWIN_LINK darwin
= NULL
;
3438 TRACE("%s %p %p %p\n", debugstr_w(szShortcutTarget
),
3439 szProductCode
, szFeatureId
, szComponentCode
);
3441 init
= CoInitialize(NULL
);
3443 r
= CoCreateInstance( &CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
3444 &IID_IPersistFile
, (LPVOID
*) &pf
);
3445 if( SUCCEEDED( r
) )
3447 r
= IPersistFile_Load( pf
, szShortcutTarget
,
3448 STGM_READ
| STGM_SHARE_DENY_WRITE
);
3449 if( SUCCEEDED( r
) )
3451 r
= IPersistFile_QueryInterface( pf
, &IID_IShellLinkDataList
,
3453 if( SUCCEEDED( r
) )
3455 IShellLinkDataList_CopyDataBlock( dl
, EXP_DARWIN_ID_SIG
,
3457 IShellLinkDataList_Release( dl
);
3460 IPersistFile_Release( pf
);
3463 if (SUCCEEDED(init
))
3466 TRACE("darwin = %p\n", darwin
);
3473 ret
= MsiDecomposeDescriptorW( darwin
->szwDarwinID
,
3474 szProductCode
, szFeatureId
, szComponentCode
, &sz
);
3475 LocalFree( darwin
);
3479 return ERROR_FUNCTION_FAILED
;
3482 UINT WINAPI
MsiReinstallFeatureW( LPCWSTR szProduct
, LPCWSTR szFeature
,
3483 DWORD dwReinstallMode
)
3485 MSIPACKAGE
* package
= NULL
;
3487 WCHAR sourcepath
[MAX_PATH
];
3488 WCHAR filename
[MAX_PATH
];
3489 static const WCHAR szLogVerbose
[] = {
3490 ' ','L','O','G','V','E','R','B','O','S','E',0 };
3491 WCHAR reinstallmode
[11];
3495 FIXME("%s %s %i\n", debugstr_w(szProduct
), debugstr_w(szFeature
),
3498 ptr
= reinstallmode
;
3500 if (dwReinstallMode
& REINSTALLMODE_FILEMISSING
)
3502 if (dwReinstallMode
& REINSTALLMODE_FILEOLDERVERSION
)
3504 if (dwReinstallMode
& REINSTALLMODE_FILEEQUALVERSION
)
3506 if (dwReinstallMode
& REINSTALLMODE_FILEEXACT
)
3508 if (dwReinstallMode
& REINSTALLMODE_FILEVERIFY
)
3510 if (dwReinstallMode
& REINSTALLMODE_FILEREPLACE
)
3512 if (dwReinstallMode
& REINSTALLMODE_USERDATA
)
3514 if (dwReinstallMode
& REINSTALLMODE_MACHINEDATA
)
3516 if (dwReinstallMode
& REINSTALLMODE_SHORTCUT
)
3518 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3522 sz
= sizeof(sourcepath
);
3523 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3524 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEW
, sourcepath
, &sz
);
3526 sz
= sizeof(filename
);
3527 MsiSourceListGetInfoW(szProduct
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
3528 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAMEW
, filename
, &sz
);
3530 lstrcatW( sourcepath
, filename
);
3532 if (dwReinstallMode
& REINSTALLMODE_PACKAGE
)
3533 r
= MSI_OpenPackageW( sourcepath
, &package
);
3535 r
= MSI_OpenProductW( szProduct
, &package
);
3537 if (r
!= ERROR_SUCCESS
)
3540 msi_set_property( package
->db
, szReinstallMode
, reinstallmode
);
3541 msi_set_property( package
->db
, szInstalled
, szOne
);
3542 msi_set_property( package
->db
, szLogVerbose
, szOne
);
3543 msi_set_property( package
->db
, szReinstall
, szFeature
);
3545 r
= MSI_InstallPackage( package
, sourcepath
, NULL
);
3547 msiobj_release( &package
->hdr
);
3552 UINT WINAPI
MsiReinstallFeatureA( LPCSTR szProduct
, LPCSTR szFeature
,
3553 DWORD dwReinstallMode
)
3559 TRACE("%s %s %i\n", debugstr_a(szProduct
), debugstr_a(szFeature
),
3562 wszProduct
= strdupAtoW(szProduct
);
3563 wszFeature
= strdupAtoW(szFeature
);
3565 rc
= MsiReinstallFeatureW(wszProduct
, wszFeature
, dwReinstallMode
);
3567 msi_free(wszProduct
);
3568 msi_free(wszFeature
);
3575 unsigned int buf
[4];
3576 unsigned char in
[64];
3577 unsigned char digest
[16];
3580 extern VOID WINAPI
MD5Init( MD5_CTX
*);
3581 extern VOID WINAPI
MD5Update( MD5_CTX
*, const unsigned char *, unsigned int );
3582 extern VOID WINAPI
MD5Final( MD5_CTX
*);
3584 /***********************************************************************
3585 * MsiGetFileHashW [MSI.@]
3587 UINT WINAPI
MsiGetFileHashW( LPCWSTR szFilePath
, DWORD dwOptions
,
3588 PMSIFILEHASHINFO pHash
)
3590 HANDLE handle
, mapping
;
3593 UINT r
= ERROR_FUNCTION_FAILED
;
3595 TRACE("%s %08x %p\n", debugstr_w(szFilePath
), dwOptions
, pHash
);
3598 return ERROR_INVALID_PARAMETER
;
3601 return ERROR_PATH_NOT_FOUND
;
3604 return ERROR_INVALID_PARAMETER
;
3606 return ERROR_INVALID_PARAMETER
;
3607 if (pHash
->dwFileHashInfoSize
< sizeof *pHash
)
3608 return ERROR_INVALID_PARAMETER
;
3610 handle
= CreateFileW( szFilePath
, GENERIC_READ
,
3611 FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
, OPEN_EXISTING
, 0, NULL
);
3612 if (handle
== INVALID_HANDLE_VALUE
)
3613 return ERROR_FILE_NOT_FOUND
;
3615 length
= GetFileSize( handle
, NULL
);
3617 mapping
= CreateFileMappingW( handle
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
3620 p
= MapViewOfFile( mapping
, FILE_MAP_READ
, 0, 0, length
);
3626 MD5Update( &ctx
, p
, length
);
3628 UnmapViewOfFile( p
);
3630 memcpy( pHash
->dwData
, ctx
.digest
, sizeof pHash
->dwData
);
3633 CloseHandle( mapping
);
3635 CloseHandle( handle
);
3640 /***********************************************************************
3641 * MsiGetFileHashA [MSI.@]
3643 UINT WINAPI
MsiGetFileHashA( LPCSTR szFilePath
, DWORD dwOptions
,
3644 PMSIFILEHASHINFO pHash
)
3649 TRACE("%s %08x %p\n", debugstr_a(szFilePath
), dwOptions
, pHash
);
3651 file
= strdupAtoW( szFilePath
);
3652 if (szFilePath
&& !file
)
3653 return ERROR_OUTOFMEMORY
;
3655 r
= MsiGetFileHashW( file
, dwOptions
, pHash
);
3660 /***********************************************************************
3661 * MsiAdvertiseScriptW [MSI.@]
3663 UINT WINAPI
MsiAdvertiseScriptW( LPCWSTR szScriptFile
, DWORD dwFlags
,
3664 PHKEY phRegData
, BOOL fRemoveItems
)
3666 FIXME("%s %08x %p %d\n",
3667 debugstr_w( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
3668 return ERROR_CALL_NOT_IMPLEMENTED
;
3671 /***********************************************************************
3672 * MsiAdvertiseScriptA [MSI.@]
3674 UINT WINAPI
MsiAdvertiseScriptA( LPCSTR szScriptFile
, DWORD dwFlags
,
3675 PHKEY phRegData
, BOOL fRemoveItems
)
3677 FIXME("%s %08x %p %d\n",
3678 debugstr_a( szScriptFile
), dwFlags
, phRegData
, fRemoveItems
);
3679 return ERROR_CALL_NOT_IMPLEMENTED
;
3682 /***********************************************************************
3683 * MsiIsProductElevatedW [MSI.@]
3685 UINT WINAPI
MsiIsProductElevatedW( LPCWSTR szProduct
, BOOL
*pfElevated
)
3687 FIXME("%s %p - stub\n",
3688 debugstr_w( szProduct
), pfElevated
);
3690 return ERROR_SUCCESS
;
3693 /***********************************************************************
3694 * MsiIsProductElevatedA [MSI.@]
3696 UINT WINAPI
MsiIsProductElevatedA( LPCSTR szProduct
, BOOL
*pfElevated
)
3698 FIXME("%s %p - stub\n",
3699 debugstr_a( szProduct
), pfElevated
);
3701 return ERROR_SUCCESS
;
3704 /***********************************************************************
3705 * MsiSetExternalUIRecord [MSI.@]
3707 UINT WINAPI
MsiSetExternalUIRecord( INSTALLUI_HANDLER_RECORD handler
,
3708 DWORD filter
, LPVOID context
,
3709 PINSTALLUI_HANDLER_RECORD prev
)
3711 TRACE("%p %08x %p %p\n", handler
, filter
, context
, prev
);
3714 *prev
= gUIHandlerRecord
;
3716 gUIHandlerRecord
= handler
;
3718 gUIContext
= context
;
3720 return ERROR_SUCCESS
;
3723 /***********************************************************************
3724 * MsiInstallMissingComponentW [MSI.@]
3726 UINT WINAPI
MsiInstallMissingComponentW(LPCWSTR szProduct
, LPCWSTR szComponent
, INSTALLSTATE eInstallState
)
3728 FIXME("(%s %s %d\n", debugstr_w(szProduct
), debugstr_w(szComponent
), eInstallState
);
3729 return ERROR_SUCCESS
;