Solved

Reading from a USB port with Win32 API

Posted on 2003-12-02
3
4,932 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 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

If your app took Google’s lash recently, here are the 5 most likely reasons.
All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

623 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