473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Opening USB HID Device in VB6

I'm attempting to open an USB HID device using createfile from kernel32.
The open attempt always fails. This is the call I'm using:

CreateFile(HidName$, &HC0000000, 3, 0, 3, 0 ,0)

HidName$ gets assigned the device:
\\?\hid
#vid_7766&pid_1629
#6&1b9813bf&0&0000
#{4d1e55b2-f16f-11cf-88cb-00111100030}

(its actually 1 string, I entered linebreaks here at the # marks for
readability)

Createfile is defined as:

Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
_(ByVal lpFileName$, ByVal dwDesiredAccess&,
_ ByVal dwShareMode&,lpSecurityAttributes&,
_ ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&,
_ ByVal hTemplateFile&) As Long

No matter what, the CreateFile call always returns -1. I've tried it with
multiple HID devices to ensure I'm finding the correct device name.

This is VB 6.0 on Win2k.

Any ideas?

-James

Jul 17 '05 #1
1 17687

"CMiYC" <cm***@nowhere.com> wrote in message
news:pa****************************@nowhere.com...
I'm attempting to open an USB HID device using createfile from kernel32.
The open attempt always fails. This is the call I'm using:

CreateFile(HidName$, &HC0000000, 3, 0, 3, 0 ,0)

HidName$ gets assigned the device:
\\?\hid
#vid_7766&pid_1629
#6&1b9813bf&0&0000
#{4d1e55b2-f16f-11cf-88cb-00111100030}

(its actually 1 string, I entered linebreaks here at the # marks for
readability)

Createfile is defined as:

Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
_(ByVal lpFileName$, ByVal dwDesiredAccess&,
_ ByVal dwShareMode&,lpSecurityAttributes&,
_ ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&,
_ ByVal hTemplateFile&) As Long

No matter what, the CreateFile call always returns -1. I've tried it with
multiple HID devices to ensure I'm finding the correct device name.

This is VB 6.0 on Win2k.

Any ideas?

-James

Hi James..

If I recall correctly from my Win98 usb days, I think createfile is async so
it goes back immediately. Did you try putting in a delay for polling?, e.g.:

'Find the device
DeviceDetected = FindTheHid
If DeviceDetected = True Then
'Learn the capabilities of the device
Call GetDeviceCapabilities
' report to the device
Call WriteReport

'The firmware adds 1 to each received byte and sends the bytes back
'to the host. Add a delay to allow the host time to poll for the
returned data.

Timeout = False
tmrDelay.Interval = 100
tmrDelay.Enabled = True
Do
DoEvents
Loop Until Timeout = True
'Read a report from the device.
Call ReadReport
Else
End If

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Karl Koscher | last post by:
I'm trying to communicate with a USB device using C#. I'm able to determine the device path using P/Invoke and SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces, and SetupDiGetDeviceInterfaceDetail,...
4
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is...
4
by: Jeff Baynton | last post by:
Does anyone know how to get a cash drawer to open using VB? I'm doing a Point of Sale program and figured this was the easiest way to figure it out. If you know just email me. Thanks!
1
by: sush | last post by:
Details of the Opening : Position : Technical Lead Openings : 2 positions Job Location Bangalore * Should! have extensive experience and strong hold in Device drivers, Win 32,
1
by: Joe B. | last post by:
I have been wading through using SetupDi... API to get a device path to use in CreateFile so that I could open a USB HID device. I can now get a device path, but when I try to open for...
3
by: rxhofman | last post by:
Hello all, I want to create my own filesystem on a flash memory card. How can I open the card as a raw character device? On a unix-like system I can just open /dev/hdx as a file and do...
13
by: sayansayan | last post by:
two threads are running in a prog i need the output of one thread in a new terminal which the prog will create and the output of other thread in the old terminal
1
by: gallois | last post by:
hello everyone, i've been trying to write something that checks the inputs from the possible devices where a mouse can be connected (debian/linux) in order to make it configure the system...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.