Jump to content

calling c++ function


madhutm
 Share

Recommended Posts

hi

ths for reply.ya i am calling that function using calldll.But that not working fine. The function return type is bool every it will give different integer number($dll[0]) but it will not connected to the device.is there any prerequires to calling this type of functions.

Link to comment
Share on other sites

$ctl = 0
 
$tStruct = DllStructCreate("byte[256]") ;set your byte size here
DllStructSetData($tStruct, 1, ...
 
$inLen = 0
 
$tStruct2 = DllStructCreate("byte[256]") ;set your byte size here
 
$outLen = 0
 
DllCall("yourlib.dll", "bool", "Control", "int", $ctl, "struct*", $tStruct, "int", $inLen, "struct*", $tStruct2, "int*", $outLen)
 
;Control(int ctl, byte[] inData, int inLen, byte[] outData, ref int outLen)
Not sure if it's a struct*, or if it's a ptr (in this case you will use DllStructGetPtr with the 1st element).

Edit: And you will maybe need a struct for the int pointer (I'm pretty sure about it though).

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

ths for reply.

i don't know about inside code in c++.same function i am calling from c# it works fine in c#.for testing purpose i need to call this function from autoit.

can you please tell me how to convert hex string to bytearray in Autoit. the above function second parameter i need to send this byte array only.

Link to comment
Share on other sites

this is how i am sending the function

  DllCall($dll,"bool:cdecl","BCRBT_Control","int", $ctl, "struct*", $tStruct, "int", $inLen, "struct*", $tStruct2, "int*", $outLen)

my paramer values are

        Local $input = GUICtrlRead($hInput)
        Local $dd =  StringFormat("%X",$input)
        Local $outLen = 0;
        Local $ctl =0xf901;
        $tStruct2 = DllStructCreate("byte[0xff]")
        $inLen =0;

        $b = StringToBinary($dd)
        $tStruct = DllStructCreate("byte[" & BinaryLen($B) & "]")
        DllStructSetData($tStruct, 1, $B)
 

Link to comment
Share on other sites

i am trying to connect blutooth device via com port.

Have you tried to communicate directly with the COM port?

An example >here.

If your struct2 is a simple byte (not a byte array), call the parameter with BYTE and directly 0xFF.

Br, FireFox.

Link to comment
Share on other sites

hi,

that stringtobinary function not working properly.my port number is 30 after converting this to hexstring the value become 1E.while converting this value to binary that $b value gives  (0x313445)

but this is not binary format.

and struct2 is byte array.in c# i am declaring like this

byte[] = new byte[0xff];

how can i declare same like this in autoit.

and how can i find the tstruct lengh because i need to send this as third parameter to function.

ths

Link to comment
Share on other sites

that stringtobinary function not working properly.my port number is 30 after converting this to hexstring the value become 1E.while converting this value to binary that $b value gives  (0x313445)

but this is not binary format.

Binary is not 010101... it's hexadecimal in Binary variable type.

StringToBinary("0xABCDE") ;will be converted to binary type

and struct2 is byte array.in c# i am declaring like this

 

byte[] = new byte[0xff];

 

how can i declare same like this in autoit.

$tStruct2 = DllStructCreate("byte[" & 0xFF & "]") ;or 255

and how can i find the tstruct lengh because i need to send this as third parameter to function.

You haven't searched at all, take a look at the help file and you will find related function DllStructGetSize.

Br, FireFox.

Link to comment
Share on other sites

forgot above one for while this is my Bio_diconnect function it will not take any parameter.this one also not calling.

i am calling liki this

Local $ t1 = calldll($dll,"bool:cdecl","Bio_Disconnect")

msgbox(0,"txt",$t1[0])

this value give different integer numbers every time(not 0 or 1)

my question is there anything i need to setup working with bluetooth device or not.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...