Passing paramters to dll function - 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!

splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Passing paramters to dll function

Hey Guys,

I am calling a function from a dll in a custom action.

I am having a bit of difficulty and just wondering if I am doing it right.

I have chosen the function in the dropdown and I have put the parameters in the "Action Data" field example:

'parameter_1', true, 'parameter_3', false, true


I did see mention on the forums of command line stuff but cant see where i could do that.

Any help is truly appreciated.

This is a great product.

Thanks

Tony
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

You cannot pass parameters to functions in dll's, VBScript, JavaScript etc. for use in custom actions. As an alternative you can create properties in AI which contain the parameters you need to send, and in your script you can use:

Code: Select all

value = Session.Property("PROPERTY_NAME")
Regards,
cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Parameters

Hi,


Thats great, thanks for your reply.

But then how would I call the function and use the parameters from the Custom Actions screen.

Or would I call it in VB Script? If so would you have an example?

Cheers

Tony
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

You can use properties to pass parameters in two ways:
- if your custom action is immediate then you can name the property any way you want and use it
- if your custom action is deferred then you can specify in the "Action Data" field the parameters you need and retrieve them in your custom action by using the value of the CustomActionData property.

To get/set a property in a DLL custom action you use the MsiGetProperty/MsiSetProperty function.

How to create a DLL which will be used as a custom action is explained here:
http://www.advancedinstaller.com/forums ... etproperty

Regards,
cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Third party

Hi,

Thanks for that reply.

My real problem is, this is a third party dll.

I am not writing the dll so dont have the luxury of using the AI session properties within it.

This is a third party one that has a function that I want to use but that function requires parameters passed.

Sorry to be a pain :(

Thanks

Tony
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Here is how you can accomplish what you need:

- in the "Files and Folders" page you add the 3rd party DLL as a temporary file (right-click -> "Add Temporary Files..."); I recommend you add it in the "Windows Volume\Temporary" folder

- you create a custom action DLL that retrieves the values of the properties from the installer (see the example Serial-Validation DLL: http://www.advancedinstaller.com/user-g ... n-dll.html ) or you can hardcode the parameters in your DLL custom action

- in your DLL you load the 3rd party DLL using the LoadLibrary function
http://msdn2.microsoft.com/en-us/library/ms684175.aspx

- in your DLL you retrieve the address of the function you need from the 3rd party DLL using the GetProcAddress function http://msdn2.microsoft.com/en-us/library/ms683212.aspx

Now you can invoke the function using the pointer obtained from the GetProcAddress call !
Hope this helps!


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

Return to “Common Problems”