[英]WIX C++ Custom Action
我有一个基本的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都无效。 我已将动作设置为commit,deferred,在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;
}
如前所述这里 ,要克服的是混淆的唯一途径__stdcall
是使用:
#pragma comment(linker, "/EXPORT:SomeFunction=_SomeFunction@@@23mangledstuff#@@@@")
这将在DLL导出表中创建第二个条目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.