By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,046 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,046 IT Pros & Developers. It's quick & easy.

USB HID IO in VB .NET

P: n/a
I am having some trouble getting this working in VB.NET.
I have found numerous examples for VB 6, but nothing
on .NET so I am having to try to convert. I am making
baby steps in progress, but have not been able to get past
a certain point. I have not been able to convert by byte
array to a string. Also, if anyone knows a good reference
for VB .NET usb hardware i/o, let me know. I have not
been able to find anything on the internet or www.usb.org.

Dim DetailDataBuffer() as Byte
devInfo = SetupDiGetClassDevs(HidGuid, vbNullString, _
Me.Handle.ToInt32, _
DIGCF_PRESENT Or _
DIGCF_DEVICEINTERFACE)

' Size should be 28 bytes
DeviceInterfaceData.cbSize = 28

DeviceInfoData.cbSize = Len(DeviceInfoData.ToString)
result = SetupDiGetDeviceInterfaceDetail(devInfo, _
DeviceInterfaceData, _
0, _
0, _
Needed, _
0)
DetailDataSize = Needed
DeviceInterfaceDetailData.cbSize = 5
ReDim DetailDataBuffer(DetailDataSize)
' Store cbSize in the first byte of the buffer
RtlMoveMemory(DetailDataBuffer(0), _
DeviceInterfaceDetailData, 4)

' Call again, but pass first byte of detaildatabuffer
result = SetupDiGetDeviceInterfaceDetail(devInfo, _
DeviceInterfaceData, _
DetailDataBuffer, _
DetailDataSize, _
Needed, _
0)

' This should return my device path into DetailDataBuffer
' The convert to string
DevicePathName =
System.Text.UnicodeEncoding.Unicode.GetString
(DetailDataBuffer)
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.