Loading
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 :)

  • Community Manager (Flexera Software)

    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;
    Expand Post
  • 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 :)
    Expand Post
  • Community Manager (Flexera Software)

    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 (&, |, ^, ~, >)".
  • 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 :)
    Expand Post
  • Community Manager (Flexera Software)

    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.)

Loading
Calling a dll function