Jump to content

DllCall - problems


Recommended Posts

Hi,

i got a USB-IO Device, delivered with an DLL for the communication between the device and computer. I'm trying to use it, but nothing happens. This ist my code so far:

$hDLL = DllOpen("USBDII.dll")
$hDID = DllCall($hDLL, "int", "_hid_OpenDevice", "DWORD", 0x01, "DWORD", 0)
$return = DllCall($hDLL, "int", "_hid_SetDigitalByte", "HANDLE", $hDID, "DWORD", 0, "BYTE", 0xFF)

in the Description i found the following informations

hid_OpenDevice

HANDLE hid_OpenDevice ( DWORD device_type, DWORD device_id );

device_type: The type of the device to open.

device_id : Device's id on the Board.

hid_SetDigitalByte

BOOL hid_SetDigitalByte ( HANDLE hDevice, DWORD dwPort, BYTE byPortState);

hDevice: A valid device handle, previously obtained from hid_OpenDeviceDevice

dwPort: The index of the port on the card to manipulate. The first port has index 0.

byPortState: The new state of the port

I used the Dependcy Walker to get the function nams inside the DLL

_com_CloseDevice@4

_com_GetDigitalBit@12

_com_GetDigitalByte@12

_com_OpenDevice@12

_com_ResetHW@4

_com_SetDigitalBit@12

_com_SetDigitalByte@12

_com_close@4

_com_open@12

_com_read@12

_com_write@12

_hid_CloseDevice@4

_hid_GetAnalogChannel@12

_hid_GetDigitalBit@12

_hid_GetDigitalByte@12

_hid_OpenDevice@8

_hid_ResetHW@4

_hid_SetDigitalBit@12

_hid_SetDigitalByte@12

_hid_SetInit@28

_hid_close@4

_hid_open@8

_hid_read@12

_hid_write@12

anyone has a hint for me?
Link to comment
Share on other sites

Thanks,

$hDLL = DllOpen("USBDII.dll")
$hDID = DllCall($hDLL, "HANDLE", "_hid_OpenDevice", "DWORD", 0x01, "DWORD", 0)
$return = DllCall($hDLL, "HANDLE", "_hid_SetDigitalByte", "HANDLE", $hDID, "DWORD", 0, "BYTE", 0xFF)

$hDLL = DllOpen("USBDII.dll")
$hDID = DllCall($hDLL, "HWND", "_hid_OpenDevice", "DWORD", 0x01, "DWORD", 0)
$return = DllCall($hDLL, "HWND", "_hid_SetDigitalByte", "HANDLE", $hDID, "DWORD", 0, "BYTE", 0xFF)

i tried both of it, but both didn't work.

I got an testprogram for the device and the device is working well, only controlling it with autoit fails :/

Edited by yetrael
Link to comment
Share on other sites

My mistake, the call to _hid_SetDigitalByte should have BOOL as return type

If not try BOOLEAN (they seem to have different sizes in autoit)

No problem, i compared the expected datetypes for the dll with the datatypes inside autoit - everything is used the right way

$hDLL = DllOpen("USBDII.dll")
$hDID = DllCall($hDLL, "HANDLE", "_hid_OpenDevice", "DWORD", 0x03, "DWORD", 0x01)
DllCall($hDLL, "BOOL", "_hid_SetDigitalByte", "HANDLE", $hDID, "DWORD", 0x01, "BYTE", 0xFF)

but it really should work with autoit, or are there any limitations?

edit: dumbass :mellow:

tried $hDID[0] as handle and it works.

Edited by yetrael
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...