我有以下 WiX 标记,指示 MSI 安装程序从包含的 DLL 调用自定义操作:
<CustomAction Id="CA_SetProperties_Finalize"
Property="CA_OnInstallFinalize"
Value="[Installed],[REINSTALL],[UPGRADINGPRODUCTCODE],[REMOVE]" />
<CustomAction Id='CA_OnInstallFinalize'
BinaryKey='CADll'
DllEntry='msiOnInstallFinalize'
Execute='deferred' Impersonate='no' />
<InstallExecuteSequence>
<Custom Action='CA_SetProperties_Finalize'
Before='InstallFinalize'></Custom>
<Custom Action='CA_OnInstallFinalize'
After='CA_SetProperties_Finalize'></Custom>
</InstallExecuteSequence>
<Binary Id='CADll' SourceFile='Sources\ca-installer.dll' />
并且 DLL 本身具有以下用于自定义操作的 C++ 代码:
#pragma comment(linker, "/EXPORT:msiOnInstallFinalize=_msiOnInstallFinalize@4")
extern "C" UINT __stdcall msiOnInstallFinalize(MSIHANDLE hInstall)
{
//Do the work
if(doWork(hInstall) == FALSE)
{
//Error, cannot continue, display end-user message...
PMSIHANDLE hRecord = MsiCreateRecord(0);
MsiRecordSetString(hRecord, 0, TEXT("Error cannot continue!"));
MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_ERROR + MB_OK), hRecord);
return ERROR_INSTALL_FAILURE;
}
return ERROR_SUCCESS;
}
如您所见,最终用户消息是硬编码的。在我实际的 WiX 标记中,我将本地化 .wxl 文件用于字符串,如下所示:
<Property Id="ARPCONTACT" Value="!(loc.ContactInfo)" Secure="yes" />
然后,例如,lang_en-us.wxl
文件将是:
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="ContactInfo">To get hold of me yell out of the window...</String>
</WixLocalization>
所以我很好奇,有没有办法从我的 C++ 自定义操作代码中的 .wxl 文件中访问这些本地化字符串?