cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tech_is
Level 5

Calling a dll function

URGENT

Hi,
Please suggest with example to call the dll function, in InstallScript, which shall look in C++ as:
prototype:
short myDll.myFunction (short &,integer &,short &,short &);
function call:
short param1=-1,param2=0,param3=0;
int param4 = 0;
nReturn = myFunction(param1, param2, param3, param4); //all parameters are output paramters.
param2 &= 0x00FFFFFF; //after the function call, need to remove the most significant byte.

So how to implement this functionality in Installscript.:confused:
Please help.

Thanks in advance 🙂
Labels (1)
0 Kudos
(6) Replies
RobertDickau
Flexera Alumni

In a quick test, with a C++ DLL whose code is this:

#include

void __stdcall myFunction(short& p1, int& p2, short& p3, short& p4)
{
p1 = 1;
p2 = 2;
p3 = 3;
p4 = 4;
}
and assuming you've set up a .def file for exports and such, this InstallScript seems to work:
prototype void InstallScriptCppDll.myFunction(
BYREF SHORT, BYREF INT, BYREF SHORT, BYREF SHORT);

function OnBegin( )
SHORT s1, s3, s4;
INT s2;
begin

UseDLL(SUPPORTDIR ^ "InstallScriptCppDll.dll");

myFunction(s1, s2, s3, s4);

UnUseDLL("InstallScriptCppDll.dll");

SprintfBox(INFORMATION, "DLL Results",
"s1 = %d, s2 = %d, s3 = %d, s4 = %d",
s1, s2, s3, s4);

end;
0 Kudos
tech_is
Level 5

Hi,
Thanks Robert. But how to remove the most significant byte? as specified in:
param2 &= 0x00FFFFFF; // the value of param2 is ANDed with 0x00FFFFFF.

How to implement this in installscript? Is there any internal function which can be called to convert to Hex, then do the AND & then revert the value back to NUMBER/INT:confused: ?
Please help.

Thanks in advance 🙂
0 Kudos
RobertDickau
Flexera Alumni

It shouldn't be necessary to convert between decimal and hex; you can use arithmetic and bit operations (11 + 0xABC is valid, and so on). I don't think there's the &= operator, but please see the help topic "Bit Operators (&, |, ^, ~, <<, >>)".
0 Kudos
tech_is
Level 5

Hi Robert,
You mean that I can directly call the:
param2 &= 0x00FFFFFF; // the value of param2 is ANDed with 0x00FFFFFF.
in installscript as:

p2 = p2 && FFFFFF;?
I suppose this won't work as expected. Well I looked for the Bit operator as well but I think the operands on both sides of the Bit operator should be of the same type i.e. either decimal or hexa:confused: . Please tell me if i'm wrong.

Thanks a lot 🙂
0 Kudos
RobertDickau
Flexera Alumni

There's no hex data type; would p2 = p2 & 0xFFFF; work? (The double ampersand && is the logical-or operator, where single & is the bitwise operator.)
0 Kudos
tech_is
Level 5

Thanks a lot Robert. It worked. Thanks a lot again. 🙂
0 Kudos