Jump to content

Convert from Delphi to Autoit DLLCALL


Recommended Posts

The delphi code looks like this :

        private IntPtr _device = new IntPtr(-1);
        private readonly byte[] _readVersionCommand = new byte[] { 0, 1, 134, 255, 1, 0, 0, 0, 0 };
        byte[] bVersion = new byte[9];
 

_device = RDing.OpenUSBDevice(UsbVendorId, UsbDeviceId);

RDing.WriteUSB(_device, _readVersionCommand, (uint)_deviceOutputLength, ref numberOfBytesWritten);
RDing.ReadUSB(_device, bVersion, (uint)_deviceInputLength, ref _numberOfBytesRead);
 

I translated it to :

$b = DllStructCreate("byte[9]")
$c = DllStructCreate("word")
$cTemp = DllStructGetPtr($c)
$e= DllStructCreate("byte[9]")
Dim $TemperReadVersionCommand[11] = [0,1,134,255,1,0,0,0,0,0,0]
For $I = 0 To 8 
    DllStructSetData($b,1,$TemperReadVersionCommand[$I],$I+1)
Next

Global $ghHidFTDll = DLLOpen("RDingUSB.dll")

$TemperDevice = DllCall($ghHidFTDll,"bool","OpenUSBDevice","int",3141,"int", 29697)$TemperRequestTemperature = DllCall($ghHidFTDll,"int","WriteUSB","int",$TemperDevice[0],"str",DllStructGetData($b,1),"uint",9,"ptr",$cTemp)
$temperReadTemperature = DllCall($ghHidFTDll,"int","ReadUSB","int",$TemperDevice[0],"str*",$e,"uint",9,"ptr",$cTemp)

The first and second DLLCall gives a good result (return code 0).

The second DLL call return an error on the second parameter.  (return code 1)

The result should be a 9 byte array in the second parameter ($e).

What do I wrong.  How can I pass a variable to write the array to ?

Tanks in advance for your help.

 

 

 

 

 

 

 

 

 

Elke vogel zingt zoals hij gebekt is !Als alleen die vogels zongen die het mooiste zingen zou het stil zijn in het bos.

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