Click here to Skip to main content
15,891,621 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPrinter settings Pin
AnayKulkarni28-May-09 23:15
AnayKulkarni28-May-09 23:15 
AnswerRe: Printer settings Pin
«_Superman_»28-May-09 23:23
professional«_Superman_»28-May-09 23:23 
GeneralRe: Printer settings Pin
AnayKulkarni28-May-09 23:55
AnayKulkarni28-May-09 23:55 
QuestionRe: Printer settings Pin
«_Superman_»29-May-09 0:41
professional«_Superman_»29-May-09 0:41 
QuestionGetLocalDiskNames Pin
p_196028-May-09 20:48
p_196028-May-09 20:48 
AnswerRe: GetLocalDiskNames Pin
Hamid_RT28-May-09 21:15
Hamid_RT28-May-09 21:15 
QuestionSend data bits through USB Pin
mythlace28-May-09 20:24
mythlace28-May-09 20:24 
AnswerRe: Send data bits through USB Pin
Cedric Moonen28-May-09 20:36
Cedric Moonen28-May-09 20:36 
Accessing a USB port is not the same as accessing the serial port: you can't simply "open" it and send data on it. This is because multiple devices could be connected to the same port (see for instance an USB hub). So, what you have to do instead is retrieve the handle to the device driver associated with the device you want to communicate with (of course, the device should be installed on your computer before being able to do so). To retrieve the handle to the driver, it is similar as opening the serial port: you call CreateFile with the driver symbolic name for the file name argument. Once this is done, you can start sending and receiving data using the WriteFile and ReadFile functions (like for a serial port). Not that the driver will implement a specific behavior for these functions, so it really depends on your driver. Finally, you can also send driver specific control code by using the DeviceIOControl function.

All these things are very specific to the device you want to access (so, to the driver you are accessing). Which kind of USB device are you trying to access ? There should be some documentation with the driver that explains you how to retrieve the handle to the driver and list the device control codes.
If you are trying to access a USB-to-serial converter, things are different because in that case, the driver will emulate a virtual COM port and you can simply use this virtual COM port as a standard COM port.

Cédric Moonen
Software developer

Charting control [v2.0]
OpenGL game tutorial in C++

GeneralRe: Send data bits through USB Pin
«_Superman_»28-May-09 20:41
professional«_Superman_»28-May-09 20:41 
GeneralRe: Send data bits through USB Pin
mythlace28-May-09 20:43
mythlace28-May-09 20:43 
GeneralRe: Send data bits through USB Pin
Cedric Moonen28-May-09 20:51
Cedric Moonen28-May-09 20:51 
GeneralRe: Send data bits through USB Pin
mythlace28-May-09 21:01
mythlace28-May-09 21:01 
GeneralRe: Send data bits through USB Pin
Cedric Moonen28-May-09 21:10
Cedric Moonen28-May-09 21:10 
AnswerRe: Send data bits through USB Pin
bolivar12329-May-09 9:00
bolivar12329-May-09 9:00 
QuestionHow to measure wstring memory size? Pin
cozyu28-May-09 20:16
cozyu28-May-09 20:16 
AnswerRe: How to measure wstring memory size? Pin
Cedric Moonen28-May-09 20:18
Cedric Moonen28-May-09 20:18 
AnswerRe: How to measure wstring memory size? Pin
«_Superman_»28-May-09 20:43
professional«_Superman_»28-May-09 20:43 
GeneralRe: How to measure wstring memory size? Pin
Cedric Moonen28-May-09 20:58
Cedric Moonen28-May-09 20:58 
GeneralRe: How to measure wstring memory size? Pin
«_Superman_»28-May-09 21:07
professional«_Superman_»28-May-09 21:07 
GeneralRe: How to measure wstring memory size? Pin
Cedric Moonen28-May-09 21:11
Cedric Moonen28-May-09 21:11 
GeneralRe: How to measure wstring memory size? Pin
«_Superman_»28-May-09 21:13
professional«_Superman_»28-May-09 21:13 
GeneralRe: How to measure wstring memory size? Pin
Cedric Moonen28-May-09 21:20
Cedric Moonen28-May-09 21:20 
GeneralRe: How to measure wstring memory size? Pin
norish28-May-09 20:48
norish28-May-09 20:48 
AnswerRe: How to measure wstring memory size? Pin
Stuart Dootson28-May-09 22:22
professionalStuart Dootson28-May-09 22:22 
QuestionError Pin
Ryuk199028-May-09 16:55
Ryuk199028-May-09 16:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.