|
|
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."
|
|
|
|
|
hum, i would have gone into C++ cast operators, like static_cast<LPCTSTR>(str) :p
but, was it really necessary to explicitely cast here ? i'm not 100%, but i have no compiler with me, so...
|
|
|
|
|
Well I've been doing it for years but have only recently upgraded from VC6 to VS2005. You've made me do some experiments and it has been improved (fixed?) in VS2005. The following code segment
<br />
{<br />
std::ofstream out("test.txt");<br />
CString str;<br />
str = "This is a test line";<br />
out << str;<br />
}<br />
on VC6 produces one line in the file:
<br />
00423FDC<br />
which I assume is the address of the CString. In VS2005 it works as you would expect. I guess MS finally included a suitable operator<< overload. I can now stop typing all those (LPCSTR) casts! Thanks tox
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."
|
|
|
|
|
Hi,
I have a dialog which contains different controls,and I want to send
a WM_KEYDOWN message to the parent dialog when a control receives a WM_KEYDOWN
message.
In the dialog,I overrided the OnKeyDown() method as follow:
void Frm_WKFailureMatrix::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
and in the control,I also overrided the OnKeyDown() method , and inside
that handler I call the ::SendMessage(...) method,as follow:
void WkMfcButton::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
int x = 0;
::SendMessage(GetOwner()->GetSafeHwnd() , WM_KEYDOWN , 0 , 0);
}
My problem is that ::SendMessage() accept the third and fourth parameters
as WPARAM and LPARAM(UINT_PTR and LONG_PTR).
How can I convert nChar,nRepCnt and nFlags to WPARAM and LPARAM so the
parent dialog will receive the correct parameters???
With best regards,
Eli
|
|
|
|
|
|
toxcct wrote: static_cast<>()...
Actually, that won't work correctly. The OP actually needs to pack the three parameters back into the wParam and lParam. The MAKELPARAM and MAKEWPARAM macros will do this. Refer to the WM_KEYDOWN doc to determine where each item goes.
Judy
|
|
|
|
|