|
You have to open (using CreateFile) the driver that is associated with the device. Then you can use ReadFile and WriteFile to read or write data to the driver.
But it depends also of the kind of device you are using. Can you provide more information ?
|
|
|
|
|
I am very new to this USB communication.
can u please send sample code for this or any links????????
Thanks In Advance
Ashok.
|
|
|
|
|
ashokbngr wrote: can u please send sample code for this or any links????????
No, because I don't have any information to give a piece of code. What device are you trying to communicate with ?
|
|
|
|
|
Cedric Moonen wrote: What device are you trying to communicate with ?
Come on, Cedric, it's a universal serial device!
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Cedric Moonen wrote: What device are you trying to communicate with ?
This[^] device!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
|
|
Still not enough info!
Or yellow...
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Well, that depends on the driver for your specific device.
If your device's USB driver acts like a serial-port then you need the ReadFile() and WriteFile() (just like in a serial port)
Otherwise, you'll have to refer to the documentation/spec of your device ...
|
|
|
|
|
can u please send sample code for this.
Thanks In Advance
Ashok.
|
|
|
|
|
|
hi all,
i am doing a project..and i need to display the informations of a user accounts of the system and the informations about the local groups of the system.i found that the APIs NetUserEnum() and NetLocalGroupEnum() can be used ..but i couldnt display the result..there were a lot of errors..
please..anybody help me.. i want to display it on a button click to a textbox.
|
|
|
|
|
habeesh wrote: there were a lot of errors..
Such as ???
There are a limited amount of mind-readers here at CP, please be more specific.
Exactly what's your problem(s)?
BTW, welcome to CP.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
kakan wrote: There are a limited amount of mind-readers here at CP...
Are they all busy? The half-pipe in the break room is gonna have to go then.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Looks like David is in a pretty good mood today.
|
|
|
|
|
Hi every body!
I've got one CString variable with value "Hello world" and now I want to write its value into one text file. what I have to do now? I'm using Visual C++ 2005 and my project type is MFC project. Thank you every much!
Not good at VC++
|
|
|
|
|
what about using std::ofstream ?
|
|
|
|
|
Probably you need WriteString method of CStdioFile , see here
[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
thankx you so much..
Not good at C++
|
|
|
|
|
In additional you can use of CFile class
|
|
|
|
|
CStdioFile already inherits CFile
|
|
|
|
|
Yeah
|
|
|
|
|
If you use std::fstream you need to manually cast the CString e.g.
#include <fstream>
#using namespace std;
...
ofstream out("filename.txt");
CString str("this is a test");
out << (LPCSTR) str << endl;
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
what about adding a out.close() at last ?
also, your example works, but i wanted the OP to search a little by himself too... such easy code is not too hard to write when you're pointed in the right direction, what i did in my first reply
|
|
|
|
|
I had to leave something for the OP to find out - he only asked how to write the string to the file after all . I often don't call the .close() function as it happens automatically when the stream goes out of scope.
Actually I was hoping that someone was going to embarass me and tell me what I've been missing all these years writing explicit casts from CStrings to LPCSTR to use std::stream and also printf, TRACE macros etc.
I only posted as finding the need to explicitly cast can be a bit of a trick that is hard to find.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|