代码之家  ›  专栏  ›  技术社区  ›  Adrian Fâciu

WIX C++自定义动作

  •  5
  • Adrian Fâciu  · 技术社区  · 16 年前

    我有一个基本的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>
    

    任何帮助都将不胜感激。谢谢

    2 回复  |  直到 14 年前
        1
  •  8
  •   Charles Gargent    16 年前

    您需要导出被调用的函数,以便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;
        }
    
        2
  •  3
  •   Community Mohan Dere    8 年前

    如上所述 here ,这是克服 __stdcall

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

    这将在DLL导出表中创建第二个条目。

    推荐文章