Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX - Passing parameters to a CustomAction (DLL)

I've got a DLL from an old WiSE installer that i'm trying to get working in WiX, so i'm pretty sure the DLL works with MSI-based installers.

Here is my definition:

<Binary Id="SetupDLL" SourceFile="../Tools/Setup.dll" />
<CustomAction Id="ReadConfigFiles" BinaryKey="SetupDLL" DllEntry="readConfigFiles" />

and usage:

<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="ReadConfigFiles" Order="3">1</Publish>

My C++ function looks like this:

extern "C" UINT __stdcall ReadConfigFiles(MSIHANDLE hInstall, CHAR * szDirectory)

Where exactly can I pass in parameters?

like image 266
glenneroo Avatar asked Apr 28 '10 18:04

glenneroo


1 Answers

You can't pass parameters directly because in order for this to work, your function has to be exported with exactly the right footprint. When you call readConfigFiles in your custom action dll, it should have a footprint like this:

extern "C" UINT __stdcall readConfigFiles(MSIHANDLE hInstaller);

You can use the hInstaller parameter to read properties from the MSI. Use MsiGetProperty():

HRESULT GetProperty(MSIHANDLE hInstaller, LPCWSTR property, LPWSTR value, DWORD cch_value) {
    UINT err = MsiGetProperty(hInstaller, property, value, &cch_value);
    return (err == ERROR_SUCCESS ? S_OK : E_FAIL);
}

Then just make sure you set the property in your .wxs file:

<Property Id="YOUR-PROPERTY-NAME">your-property-value</Property>
like image 88
i_am_jorf Avatar answered Nov 15 '22 07:11

i_am_jorf