c++wixcustom-action

WIX Toolset MSI. How to pass CustomActionData to a CustomAction using WiX if there are several CustomAction and several Properties in the code?


I trying using this: How to pass CustomActionData to a CustomAction using WiX?

I have 2 CA and several Properties. CustomActionData using in second CA.

Product.wxs:

<Binary Id="CustomAction1" SourceFile="..\CustomAction1\bin\Debug\CustomAction1.dll"/>
<Binary Id="BinaryId1" SourceFile="..\CustomAction2\bin\Debug\CustomAction2.dll"/>    
<CustomAction Id="CustomAction1" BinaryKey="CustomAction1" Execute="immediate" DllEntry="CustomAction1" />
<CustomAction Id="PrepCustomAction" Property="CustomAction2" Value="PROPERTY1=[NAME];PROPERTY2=[TRUST];PROPERTY3=[LOGIN];PROPERTY4=[PASSWORD];"/>
<CustomAction Id="CustomAction2" BinaryKey="BinaryId1" Execute="deferred" DllEntry="CustomAction2" Return="check" HideTarget="no"/>

<InstallUISequence>     
   <Custom Action="CustomAction1" After="AppSearch">1</Custom>     
   <Custom Action="PrepCustomAction" Before="CustomAction2" />
   <Custom Action="CustomAction2" Before="InstallFinalize" />
</InstallUISequence>

CustomAction.cpp:

MsiGetProperty(hInstall, TEXT("PROPERTY1;PROPERTY2;PROPERTY3;PROPERTY4;"), buf, &buflen);

I'm expecting the buf to contain properties, but it's empty. What am I doing wrong?


Solution

  • Get the value of "CustomActionData" property using MsiGetProperty method. In your case, this method should be called in CustomAction2.

    MsiGetProperty(hInstall, TEXT("CustomActionData"), buf, &buflen);
    

    After this, you need to convert returned string into dictionary to get the value of each property.