1

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?

Alexandr
  • 243
  • 2
  • 3
  • 15
  • 1
    These old samples could help? [WiXDeferredModeSample](https://github.com/glytzhkof/WiXDeferredModeSample) and [WiXDeferredModeSampleDTF](https://github.com/glytzhkof/WiXDeferredModeSampleDTF). The DTF sample uses an approach that I have never used in a live package. Just a disclaimer. – Stein Åsmul Aug 10 '22 at 13:52
  • Thanks, I think this will help me! If there are more examples with C ++, it will be great. – Alexandr Aug 10 '22 at 14:01
  • I don't think I have that ready as a sample - I will have to search for a suitable sample locally. In the mean time, [here is an answer on common C++ native custom action errors](https://stackoverflow.com/a/54929785/129130). – Stein Åsmul Aug 10 '22 at 14:24

1 Answers1

1

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.

Vivek Jaiswal
  • 861
  • 1
  • 7
  • 20