Click here to Skip to main content
15,921,467 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: HWND that *sent* a MSG? Pin
Mark Salsbery24-Mar-07 8:25
Mark Salsbery24-Mar-07 8:25 
QuestionReAcquire my Source code Pin
stixoffire23-Mar-07 14:16
stixoffire23-Mar-07 14:16 
AnswerRe: ReAcquire my Source code Pin
Mark Salsbery24-Mar-07 6:17
Mark Salsbery24-Mar-07 6:17 
GeneralRe: ReAcquire my Source code Pin
stixoffire25-Mar-07 21:50
stixoffire25-Mar-07 21:50 
GeneralRe: ReAcquire my Source code Pin
Mark Salsbery26-Mar-07 8:13
Mark Salsbery26-Mar-07 8:13 
QuestionStoring files in a dll, or somewhere like that... Pin
Anthony Mushrow23-Mar-07 14:05
professionalAnthony Mushrow23-Mar-07 14:05 
AnswerRe: Storing files in a dll, or somewhere like that... Pin
DLChambers23-Mar-07 15:04
DLChambers23-Mar-07 15:04 
Questionserial.Open(_T("COM1")); in CSerial class Pin
m-hwang23-Mar-07 14:01
m-hwang23-Mar-07 14:01 
Hello all,
I'm pretty new at C++, and I'm trying to write a console program to communicate with a microcontroller via RS232. I'm trying to use the CSerial class (http://www.codeproject.com/system/serial.asp) to control one of the COM serial ports on my computer.
To open the serial port, I can call:
serial.Open(_T("COM1"));, which works.
However, I would like to prompt the user to select a port, so I tried:

<br />
string port;<br />
...<br />
//use cin get get the port<br />
...<br />
serial.Open(_T(port));<br />


This does not work; I get an error:
main.cpp(24) : error C2065: 'Lport' : undeclared identifier

The prototype for serial.Open looks like this:
<br />
LONG CSerial::Open (LPCTSTR lpszDevice, DWORD dwInQueue, DWORD dwOutQueue, bool fOverlapped)<br />


It turns out that _T("some string") will append an L to the string, so "some string" becomes L"somestring". But if I put in the variable port, it becomes Lport, which doesn't exist. How can I get around this?

I am using Visual C++ express with Platform SDK R2.
Thanks,
Mike
AnswerRe: serial.Open(_T("COM1")); in CSerial class Pin
Cedric Moonen23-Mar-07 22:41
Cedric Moonen23-Mar-07 22:41 
GeneralRe: serial.Open(_T("COM1")); in CSerial class Pin
m-hwang24-Mar-07 5:50
m-hwang24-Mar-07 5:50 
AnswerRe: serial.Open(_T("COM1")); in CSerial class Pin
Gary R. Wheeler24-Mar-07 2:47
Gary R. Wheeler24-Mar-07 2:47 
QuestionEject one USB device on multiple USB devices Pin
fuxiangwu23-Mar-07 12:37
fuxiangwu23-Mar-07 12:37 
QuestionNewbie learning MFC, confused about Document/View Pin
maxmaven23-Mar-07 10:26
maxmaven23-Mar-07 10:26 
AnswerRe: Newbie learning MFC, confused about Document/View Pin
Gary R. Wheeler24-Mar-07 3:37
Gary R. Wheeler24-Mar-07 3:37 
GeneralRe: Newbie learning MFC, confused about Document/View Pin
maxmaven24-Mar-07 9:37
maxmaven24-Mar-07 9:37 
Questionalways load windows default color scheme in a dialog??? Pin
tiflo23-Mar-07 9:28
tiflo23-Mar-07 9:28 
QuestionContext Menu and displaying menu on screen Pin
flippydeflippydebop23-Mar-07 8:17
flippydeflippydebop23-Mar-07 8:17 
AnswerRe: Context Menu and displaying menu on screen Pin
flippydeflippydebop23-Mar-07 8:39
flippydeflippydebop23-Mar-07 8:39 
Questionany fn to know the memoru allocated by SafeArrayCreate() Pin
GANsJob23-Mar-07 7:24
GANsJob23-Mar-07 7:24 
AnswerRe: any fn to know the memoru allocated by SafeArrayCreate() Pin
prasad_som23-Mar-07 20:44
prasad_som23-Mar-07 20:44 
Questioncan't retrieve the string from string table using loadstring() Pin
GANsJob23-Mar-07 7:16
GANsJob23-Mar-07 7:16 
AnswerRe: can't retrieve the string from string table using loadstring() Pin
perle123-Mar-07 14:22
perle123-Mar-07 14:22 
Questionconfusing problem Pin
swatgodjr23-Mar-07 6:58
swatgodjr23-Mar-07 6:58 
AnswerRe: confusing problem Pin
Christian Graus23-Mar-07 7:10
protectorChristian Graus23-Mar-07 7:10 
GeneralRe: confusing problem Pin
swatgodjr23-Mar-07 7:42
swatgodjr23-Mar-07 7:42 

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.