Solved

Reading from a USB port with Win32 API

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

790 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