stefan_riediger
Posts: 33
Joined: Fri Feb 18, 2022 4:07 pm

How to detect whether a custom action is called as immediate or as deferred CA.

Dear Advanced Installer team,

When I write a C++ Custom Action dll, how can or should I detect whether the custom action is called as immediate custom action or as deferred custom action.

The reason is that if it is called as immediate custom action in the UI Sequence, I can access the MSI properties by calling MsiGetPropertyW with the specific property name as it is used on the dialog.

On the other hand, when the custom action is called as deferred custom action, then I have to read the "CustomActionData" property and parse the value and extract my data.

Or do you recommend to use two separate Custom Actions, like
DoSomething_Immediate and DoSomething_Deferred

best regards,
Stefan
Catalin
Posts: 7038
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect whether a custom action is called as immediate or as deferred CA.

Hello Stefan,

To be fully honest with you, I did not even know it's possible to do that.

However, I stumbled across the following StackOverflow thread which might help:

How to check if custom action is running in deferred or immediate execution using WIX C#?

Is there a reason why you'd need to do that, though?

You being the developer of the custom action, you know how the custom action is gonna be scheduled and which method to retrieve the property should be used.

Beste regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stefan_riediger
Posts: 33
Joined: Fri Feb 18, 2022 4:07 pm

Re: How to detect whether a custom action is called as immediate or as deferred CA.

Hi Catalin,

thank you very much. Perfect, that pointed me into the right direction. With MsiGetMode i can check if the custom action is called as deferred CA. It works.

A little bit of the background :
The reason why wanted to achieve it is that in our company we have lots of products which are going to get an MSI installer. Because we have our own database for configurations, we have a custom action dll which read/write properties from/to our database. To avoid code duplication I wanted to move the code which fetches the values of the properties to one function. Depending when the function is called (immediate in UI stage or deferred in the execution stage) I can access directly the properties or have to pass and extract it by using CustomActionData.

Thank you for your great support.

best regards,
Stefan
Catalin
Posts: 7038
Joined: Wed Jun 13, 2018 7:49 am

Re: How to detect whether a custom action is called as immediate or as deferred CA.

You are always welcome, Stefan!

And thank you for the details and for your kind words.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”