Getting CustomActionData in deferred custom action

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?

Upvotes: 0

Views: 884

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55571

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" ... );

Upvotes: 1

Related Questions