문제

I have a basic WIX custom action:

        UINT __stdcall MyCustomAction(MSIHANDLE hInstaller)
        {   
            DWORD dwSize=0;
            MsiGetProperty(hInstaller, TEXT("MyProperty"), TEXT(""), &dwSize);
            return ERROR_SUCCESS;
        }

Added to the installer:

   <CustomAction Id="CustomActionId" FileKey="CustomDll" DllEntry="MyCustomAction"/>
   <InstallExecuteSequence>
       <Custom Action="CustomActionId" Before="InstallFinalize" />
   </InstallExecuteSequence>

The problem is that, no matter what i do, the handle hInstaller is not valid. I've set the action to commit, deferred, changed the place in InstallExecute sequence, hInstaller is always not valid.

Any help would be appreciated. Thanks.

도움이 되었습니까?

해결책

You need to export the called function so MSI can call it using undecorated C style name

Replace your code with this

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

다른 팁

As mentioned here, the only way to overcome the mangling of a __stdcall is to use:

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

This creates a second entry in the DLL export table.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top