views:

207

answers:

1

Hi,

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.

+1  A: 

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