unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
DLLNAME = 'SLABHIDDevice.dll';
// Return Codes
HID_DEVICE_SUCCESS = $00;
HID_DEVICE_NOT_FOUND = $01;
HID_DEVICE_NOT_OPENED = $02;
HID_DEVICE_ALREADY_OPENED = $03;
HID_DEVICE_TRANSFER_TIMEOUT = $04;
HID_DEVICE_TRANSFER_FAILED = $05;
HID_DEVICE_CANNOT_GET_HID_INFO = $06;
HID_DEVICE_HANDLE_ERROR = $07;
HID_DEVICE_INVALID_BUFFER_SIZE = $08;
HID_DEVICE_SYSTEM_CODE = $09;
HID_DEVICE_UNSUPPORTED_FUNCTION = $0A;
HID_DEVICE_UNKNOWN_ERROR = $FF;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
HID_DEVICE = Pointer;
var
Form1: TForm1;
function HidDevice_GetNumHidDevices(VID: Word; PID: Word): integer; stdcall; external DLLNAME ;
function HidDevice_Open(device: HID_DEVICE; DevNum: Integer; VID: Word; PID: Word): BYTE; stdcall; external DLLNAME ;
function HidDevice_GetInputReport_Interrupt(device: HID_DEVICE; repbuffer: pointer; len: Integer; RepNums: Integer; var BytesReturned: Integer): BYTE; stdcall; external DLLNAME ;
function HidDevice_GetInputReportBufferLength: Integer; stdcall; external DLLNAME ;
implementation
{$R *.dfm}
const
VID = $152A;
PID = $8261;
var
devNum: integer;
m_hid: HID_DEVICE; // array[0..3000] of char;
InputEnableBuffer: array[0..255] of char;
procedure TForm1.Button1Click(Sender: TObject);
var
status: Byte;
BytesRead: Integer;
begin
devNum := HidDevice_GetNumHidDevices(VID, PID);
ShowMessage('DeviceID = '+IntToStr(devNum));
if devNum <> 0 then
begin
status := HidDevice_Open(@m_hid, devNum-1,VID, PID);
if (status = HID_DEVICE_SUCCESS) then
ShowMessage('OK!');
HidDevice_GetInputReport_Interrupt(m_hid,@InputEnableBuffer,HidDevice_GetInputReportBufferLength,1,BytesRead);
end;
end;
end.