我有一个基本的 WIX 自定义操作:
UINT __stdcall MyCustomAction(MSIHANDLE hInstaller)
{
DWORD dwSize=0;
MsiGetProperty(hInstaller, TEXT("MyProperty"), TEXT(""), &dwSize);
return ERROR_SUCCESS;
}
添加到安装程序:
<CustomAction Id="CustomActionId" FileKey="CustomDll" DllEntry="MyCustomAction"/>
<InstallExecuteSequence>
<Custom Action="CustomActionId" Before="InstallFinalize" />
</InstallExecuteSequence>
问题是,无论我做什么,句柄 hInstaller 都无效。我已将操作设置为提交、推迟、更改 InstallExecute 序列中的位置,hInstaller 始终无效。
如有任何帮助,我们将不胜感激。谢谢。
最佳答案
您需要导出被调用的函数,以便 MSI 可以使用未修饰的 C 样式名称调用它
用这个替换你的代码
extern "C" _declspec(dllexport) UINT __stdcall MyCustomAction(MSIHANDLE hInstall);
extern "C" UINT __stdcall MyCustomAction(MSIHANDLE hInstall)
{
DWORD dwSize=0;
MsiGetProperty(hInstaller, TEXT("MyProperty"), TEXT(""), &dwSize);
return ERROR_SUCCESS;
}
关于c++ - WIX C++ 自定义操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2133583/