Solved

Reading from a USB port with Win32 API

Posted on 2003-12-02
3
4,642 Views
Last Modified: 2013-11-15
I have a HID device (magnetic cardreader) that uses a usb port to connect to a computer running any version of windows.  I want to be able to figure out what port the device is on and read information from it.  I know I need to use the Win32 API, but I haven't been able to find any useful information on how to do this.  Can any one help?

Thanks in advance.
0
Comment
Question by:sixefftee
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 9861034
The 'usual' way to communicate with an USB device is to call 'CreateFile()' to obtain a handle to the USB driver and send commands using 'DeviceIoControl()' (see e.g. http://www.delcom-eng.com/downloads/USBPRGMNL.pdf) - the rest is specific to the device that you want to communicate with.
0
 
LVL 4

Expert Comment

by:havman56
ID: 9866792
yes what JKR states is corrrect
treat the port as file
do create file() readfile() write file() it will work....

i used the simmilar for printer port and serial port as files. so USB also work.



0
 
LVL 5

Expert Comment

by:migoEX
ID: 10332375
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept jkr's comment as answer.

Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

migoEX
EE Cleanup Volunteer
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I previously wrote an article addressing the use of UBCD4WIN and SARDU. All are great, but I have always been an advocate of SARDU. Recently it was suggested that I go back and take a look at Easy2Boot in comparison.
Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now