Standard DLL call using user-defined structures - Advanced Installer Community
ntqsqa
Posts: 2
Joined: Wed Nov 05, 2014 7:42 pm

Standard DLL call using user-defined structures

Hi all! I am having trouble calling a standard DLL with a user-defined structure. From browsing this forum and the Advanced Installer tutorial base, I cannot find an adequate solution for this issue.

Problem : I was provided a Standard DLL using a standard calling convention. I do not have access to the source code corresponding to the DLL. This DLL has a function that has the following prototype (in C) :

Code: Select all

int WINAPI My_DLL_Function(MYSTRUCT *struct, BYTE *data);
The user-defined structure is (in C) :

Code: Select all

typedef struct MYSTRUCT {

char mychar1;
int myint1;
unsigned int myuint1;

} MYSTRUCT;
I have tried using the UI based CustomAction CallFunctionFromDll, but it only accepts standard variable types as function arguments.

Is it possible to store a user-defined variable type as and Advanced Installer property? I must be able to create the MYSTRUCT variable, edit its members, use it as an argument by ref to the DLL function and retrieve the modified variable.

Thank you for your help!

ntqsqa
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Standard DLL call using user-defined structures

Hello and welcome to Advanced Installer forums,

I'm afraid you cannot pass a structure as a parameter to your dll function. You should change your function's signature to accept each individual parameter.
e.g.

Code: Select all

int WINAPI My_DLL_Function (char mychar, int myint, unsigned int myuint, BYTE *data);
If there is anything else I can help you with, please let me know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ntqsqa
Posts: 2
Joined: Wed Nov 05, 2014 7:42 pm

Re: Standard DLL call using user-defined structures

Hi Dan,

First of all, I would like to thank you for your prompt response. I fully understand your solution, but as I am not the author of the DLL I cannot modify the source code nor change the function's signature. The DLL I am using is from a 3rd party and I cannot get a hold of the source code for IP reasons. I might resort to using a DLL wrapper that would create the appropriate structure from individual parameters.

Thank you,

ntqsqa

Return to “Common Problems”