我有一个基本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可以使用未修饰的空调风格的名字称呼它

与此替换代码

    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;
    }

其他提示

如所提到的 href="https://stackoverflow.com/questions/2804893/c-dll-export-decorated-mangled-names">,以克服的是混淆的唯一方式__stdcall是使用:

#pragma comment(linker, "/EXPORT:SomeFunction=_SomeFunction@@@23mangledstuff#@@@@")

这会在DLL导出表的第二项。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top