|
Hi,
I try to get the device descriptor with the following code :
procedure GetDeviceDescriptor(handle:THandle; var devDescr:DEVICE_DESCRIPTOR);
var
dwBytes : DWORD;
ds : DEVICE_DESCRIPTOR;
begin
if not DeviceIoControl(handle, IOCTL_GET_DEVICE_DESCRIPTOR,
@ds, sizeof(DEVICE_DESCRIPTOR),
@ds, sizeof(DEVICE_DESCRIPTOR),
dwBytes, nil) then
raise ECyUSBException.Create('Error #14 : ' + inttostr(GetLastError()));
devDescr := ds;
end;
IOCTL_GET_DEVICE_DESCRIPTOR is defined as followed (from usbscan.h):
IOCTL_GET_DEVICE_DESCRIPTOR := CTL_CODE(FILE_DEVICE_USB_SCAN, IOCTL_INDEX + 6, METHOD_BUFFERED,FILE_ANY_ACCESS);
FILE_DEVICE_USB_SCAN =$8000;
IOCTL_INDEX = $0800;
declariation of the type DEVICE_DESCRIPTOR (from usbscan.h)
type
_DEVICE_DESCRIPTOR = packed record
usVendorId: USHORT;
usProductId: USHORT;
usBcdDevice: USHORT;
usLanguageId: USHORT;
end {_DEVICE_DESCRIPTOR};
DEVICE_DESCRIPTOR = _DEVICE_DESCRIPTOR;
PDEVICE_DESCRIPTOR = ^_DEVICE_DESCRIPTOR;
|