Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reading from a USB port with Win32 API

Posted on 2003-12-02
3
Medium Priority
?
5,011 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

722 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