0

I try to get data from the CustomActionData property in a c++ dll, but it's always empty during the deferred sequence. If I use the exact same code in a CA executed during the UI sequence it all works great.

        UINT iCASize = 0;
        UINT uiStat = MsiGetProperty(hInstall, TEXT("CustomActionData"), TEXT(""), &iCASize);
        if (uiStat == ERROR_MORE_DATA)
        {
            // this means there are data to read. Allocate array for all data and read it (+1 for null termination)
            pCustData = new WCHAR[iCASize + 1];
            uiStat = MsiGetProperty(hInstall, TEXT("CustomActionData"), pCustData, &iCASize);
        }

Any of you out there have an idea what could be wrong?

  • The procedure is shown for C# here: https://github.com/glytzhkof/WiXDeferredModeSample - essentially the same in MSI terms for C# and C++ - just more that can go wrong in C++ of course. [Here is an answer on C++ custom actions](https://stackoverflow.com/questions/54925087/interrupt-installation-when-custom-action-returns-error/54929785#54929785) and [another answer on C# custom actions](https://stackoverflow.com/questions/60383913/how-do-i-add-c-sharp-methods-to-an-existing-large-wix-script/60384739#60384739). – Stein Åsmul Feb 23 '21 at 03:08

1 Answers1

1

Either there is something wrong with this C++ code (I haven't done c++ in twenty years) or more likely you not setting the CustomActionData correctly.

You need to a custom action scheduled in the immediate context before your deferred custom action. The property it sets is the name of the deferred CA.

Customaction Name: SetSomething Property: Something = Value: FOO ( Not CustomActionData = FOO )

Customaction Name: Something MsiGetProperty( ... "CustomactionData" ... );

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100