Call DLL Function

Post specialized setup scripts you have created here.
SITL
Posts: 114
Joined: Tue Sep 27, 2016 12:31 am

Call DLL Function

Postby SITL » Tue Sep 27, 2016 2:02 am

Hi Francesco Toscano,

Your answers to other questions helped me to get started, Appreciate.
I'm calling two Dll functions (VC++), one works and other one fails. see if you can help me.

CASE I : This one works.
Function prototype :
extern "C" __declspec(dllexport) WORD UpdateLicenseKey1()
{
return 22;
}

And this is how I'm calling from InstallAware -

~InstallAware Clipboard Data~
~Call DLL Function~
~{784B4EB7-116D-4EA4-99BA-B80D1BB4A619}~
~F:\VC2010\InstallerTest\Debug\InstallerTest.dll,UpdateLicenseKey1,word,DWORDVALUE,$~
~mIDEFunc.dll\mEXEFunc.dll~

Result : No issue, works as expected
===========================================End of CASE I ==================
CASE II : This one doesn't work - Getting EXTERNALEXCEPTION

Function prototype :
extern "C" __declspec(dllexport) BOOL UpdateLicenseKey(char* key)
{
return TRUE;
}
And this is how I'm calling from InstallAware -

~InstallAware Clipboard Data~
~Call DLL Function~
~{DC68A8D9-1EA2-4C49-9501-151909EB3DBF}~
~F:\VC2010\InstallerTest\Debug\InstallerTest.dll,UpdateLicenseKey,bool,LicenseKeyStatus,"pointer to string",$NewKeyValue$,$~
~mIDEFunc.dll\mEXEFunc.dll~

Result - EXTERNALEXCEPTION

========== End of CASE II =====================

FrancescoT
Site Admin
Posts: 4852
Joined: Sun Aug 22, 2010 4:28 am

Re: Call DLL Function

Postby FrancescoT » Tue Sep 27, 2016 11:48 am

Dear SITL,

your second DLL call looks correct ... supposing you declared your "NewKeyValue" variable before to use "Call DLL Function" and that such variable has been initialized to some value.

Hope this helps you.

Regards
Francesco Toscano
InstallAware Software Support

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

SITL
Posts: 114
Joined: Tue Sep 27, 2016 12:31 am

Re: Call DLL Function

Postby SITL » Wed Sep 28, 2016 12:15 am

Dear Francesco Toscano,

Appreciate your reply,
I have decalared and properly initialised the variable NewKeyValue.
In fact I'm displaying the value in the debugger. and tried all the different ways and methods of calling and exporting function.
I tried DWORD and LONG as well (because some times string may cause problems due to some other reasons).
Only passing parameters is not Working.

Can you give me some function prototypes ? I'll use the same and see how it goes.
I feel the problem with function prototype and the way you export.

Regards
SITL

SITL
Posts: 114
Joined: Tue Sep 27, 2016 12:31 am

Re: Call DLL Function

Postby SITL » Mon Oct 03, 2016 4:52 am

Dear Francesco Toscano,

No success, Tried different methods :o :?
Guide me, I'm almost stuck.

Regards
SITL

FrancescoT
Site Admin
Posts: 4852
Joined: Sun Aug 22, 2010 4:28 am

Re: Call DLL Function

Postby FrancescoT » Mon Oct 03, 2016 11:58 am

Dear STL,

Your Function prototype "extern "C" __declspec(dllexport) BOOL UpdateLicenseKey(char* key)" looks correct, but probably there is something else wrong with your DLL.

Did you try to call your DLL from a test C++ application? ... you can even debug it.

Personally I don't use "__declspec" with my DLLs and I prefer to Export from a DLL Using DEF Files.
https://msdn.microsoft.com/en-us/library/d91k01sh.aspx

If you want I can send you a "dummy dll" sample via DEF file... just send me an email to; support@installaware.com.

Regards
Francesco Toscano
InstallAware Software Support

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Sample Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest