473,672 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(HidN ame$, &HC0000000, 3, 0, 3, 0 ,0)

HidName$ gets assigned the device:
\\?\hid
#vid_7766&pid_1 629
#6&1b9813bf&0&0 000
#{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 "CreateFile A"
_(ByVal lpFileName$, ByVal dwDesiredAccess &,
_ ByVal dwShareMode&,lp SecurityAttribu tes&,
_ ByVal dwCreationDispo sition&, ByVal dwFlagsAndAttri butes&,
_ 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 17746

"CMiYC" <cm***@nowhere. com> wrote in message
news:pa******** *************** *****@nowhere.c om...
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(HidN ame$, &HC0000000, 3, 0, 3, 0 ,0)

HidName$ gets assigned the device:
\\?\hid
#vid_7766&pid_1 629
#6&1b9813bf&0&0 000
#{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 "CreateFile A"
_(ByVal lpFileName$, ByVal dwDesiredAccess &,
_ ByVal dwShareMode&,lp SecurityAttribu tes&,
_ ByVal dwCreationDispo sition&, ByVal dwFlagsAndAttri butes&,
_ 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 GetDeviceCapabi lities
' 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.Interv al = 100
tmrDelay.Enable d = 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
10827
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, but I can't open the device using File.Open. I get the following error: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Illegal characters in path.
4
7395
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 there are multiple pages per invoice. How can I grab the data, make the TIF, place it on the client and then Open with the clients default program for veiwing TIF's (usually Microsoft Picture and Fax Viewer). Please help.
4
2190
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
1381
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
4384
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 GENERIC_READ|GENERIC_WRITE, I get an error that only tells me "Access Denied". If I use zero in dwDesiredAccess, I get a valid handle that I can use for device query access and use HidD_GetAttributes to read the Vendor ID and Product ID so on that level I...
3
1931
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 whatever I want. How can I achieve the same thing under MS DOS or Windows 98? Thanks!
13
4605
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
1624
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 according to the right path i'm proceeding as follow: i call a function that will invoke multiple threads, each one trying to get some input stream from a device that is declared on a configuration file. i can get the first one (/dev/psaux as it is...
0
8418
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8640
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6254
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4239
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2836
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2091
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1835
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.