Calling a DLL for a custom action - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

ElectronShepherd
Posts: 29
Joined: Thu Jun 30, 2011 11:51 am

Calling a DLL for a custom action

I'm trying to call a custom DLL to verify that ASP is enabled on IIS. I've looked at http://www.advancedinstaller.com/user-g ... ialog.html, but I can't seet how to get to that dialog from within AI.

How do I specify the function signature for the function in the DLL?
How do I control the values of the parameters passed in?
What should the return code be to indicate success or failure?

I can't find any documentation about this in the help file, and seaching the forum for "custom action dll" simply tells me that all three words are very common, and have been excluded from the search.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Calling a DLL for a custom action

Hello and welcome to the Advanced Installer Forums,

Here is the user guide reference to "Call a function from a standard DLL" custom action.
How do I specify the function signature for the function in the DLL?
If you use the above custom action it can have any signature.
How do I control the values of the parameters passed in?
This can be done from the Arguments group of the Edit Function dialog.
What should the return code be to indicate success or failure?
Here is a MSDN link to help you with this.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ElectronShepherd
Posts: 29
Joined: Thu Jun 30, 2011 11:51 am

Re: Calling a DLL for a custom action

mihai.petcu wrote:If you use the above custom action it can have any signature.
I realise that, but how do I tell AI what the signature is?
mihai.petcu wrote:This can be done from the Arguments group of the Edit Function dialogn it can have any signature.
Where is this dialog? If I click the Edit... button next to the Function Name box, the Edit Custom Action Parameters dialog makes no mention of an Arguments group.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Calling a DLL for a custom action

Hello,
I realise that, but how do I tell AI what the signature is?
You don't need to do this, simply follow the user guide reference from my last post to call the function from the .DLL.
Where is this dialog? If I click the Edit... button next to the Function Name box, the Edit Custom Action Parameters dialog makes no mention of an Arguments group.
This dialog appears the first time you add the "Call Function from Standard DLL" custom action and it is again available for edit if you press the [...] button on the right of the Action Data field. It is the same dialog you mentioned in your first post referenced in our user guide under this link.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ElectronShepherd
Posts: 29
Joined: Thu Jun 30, 2011 11:51 am

Re: Calling a DLL for a custom action

I'm not seeing that dialog at all

From here:
SS1.jpg
SS1.jpg (203.64 KiB) Viewed 8442 times
If I click either circled button, I get:
SS2.jpg
SS2.jpg (26.91 KiB) Viewed 8442 times
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Calling a DLL for a custom action

Hello,

These settings are specific to this custom action and should remain like this:
Correct Settings.jpg
Correct Settings.jpg (25.9 KiB) Viewed 8432 times
If they are left like this by pressing the [...] button on the right of the Action Data field the dialog will appear. If you completely remove the custom action and add it again the dialog will be shown first and the settings will be reset.

You can add the custom action by right clicking on a standard action -> Add predefined custom actions -> Call function from Standard DLL.

You can then set everything from the Edit Function dialog.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ElectronShepherd
Posts: 29
Joined: Thu Jun 30, 2011 11:51 am

Re: Calling a DLL for a custom action

OK, got that working, sort of.

At the moment, my custom function just displays a message box, so I know it's being called. I currently have it under InstallUISequence / Welcome Dlg, and it's marked as "Synchronous execution, check return code" and "immediate execution". The function is returning an int, set to ERROR_SUCCESS. However, there are two problems:

The function is being called at the end of the UI sequence, not after the welcome dialog.
The installation is terminating on return from the function.

When AI checks the return code, what is it looking for? It looks like the return code has to be a property, so what property should be selected, and what are the values for success / failure (ie continue the installation or not)? How dO i get it to be called when "Next" is clicked on the Welcome dialog?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Calling a DLL for a custom action

Hi,
The function is being called at the end of the UI sequence, not after the welcome dialog.
A custom action scheduled after InstallUISequence -> WelcomeDlg will be executed when the dialog chain used by WelcomeDlg dialog is ended. In a normal project this happens right before ProgressDlg is shown. If you want to run a custom action when pressing Next button on WelcomeDlg, you need an UI custom action and a DoAction control event. Our user guide contains the Execute custom action on button push how-to which may help you.
The installation is terminating on return from the function.
This usually happens when the function signature and calling convention are not defined correctly for call function from standard DLL custom action. It may also happen if the called DLL crashes because of an exception.

Our custom action stores your return code in a property and always returns 0 if your DLL was called successfully. A non-zero value is returned only when the DLL is not called successfully. So you should check your custom action configuration and debug your DLL to make sure that there are no errors.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”