Question

I created a deferred/system context custom action in installShield 2012 which calls a managed method. This assembly is stored in the binary table, although I can change to installed with the product if need be. I would like to pass a parameter to my managed method in order to:

1) get the values of public properties

2) maybe write to the windows installer log file

I have been using this article as guidance, however I think it is too ambiguous to be very useful (or I just don't understand it). I have tried both their default method signature and my own. Its not clear what really happens if I use the default..for example it says it will call my method with the msihandle parameter, but how am I supposed to get that msihandle in my managed code and do something useful with it??

Are there any good examples of this out there that my searches are missing? I see little use in using managed custom actions if I cannot get something as simple as a property value.

Was it helpful?

Solution

Simply put, Flexera made a good effort at managed custom actions at a time when others were refusing to try. But their infrastructure has been outclassed by Windows Installer XML (WiX) Deployment Tools Foundation (DTF). This is the gold standard for managed code custom actions. And bets of all, you can use it with InstallShield because it outputs DLL's that just appear as native Type1 MSI DLL custom actions.

OTHER TIPS

The document Managed Custom Action Sample covers most uses of InstallShield's managed code custom action support. You can find it and the associated sample code in the Samples\WindowsInstaller\Managed Custom Actions subfolder of your InstallShield installation.

If you want to use the MSIHANDLE directly, use the non-custom signature, declare a UInt32 parameter for your function, and P/Invokes for calls like MsiGetProperty, MsiProcessMessage, and so forth, passing your UInt32 handle to these P/Invokes. If you want to use the available InstallShield.Interop.Msi to provide the P/Invokes, the Managed Custom Action Sample covers this too; including sample usage of a helper class CustomActionHandle shown in MsiWrapper.cs.

If you'd rather use the custom signature support, you can just create a string parameter for each property you want to pass to your function, and specify the properties to pass in each position. Unless you also pass the MsiHandle, it will not be possible to write to the log file in this case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top