Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using TCHAR and char array Pin
dipuks8-Oct-09 6:43
dipuks8-Oct-09 6:43 
GeneralRe: Using TCHAR and char array Pin
CPallini8-Oct-09 7:50
mveCPallini8-Oct-09 7:50 
GeneralRe: Using TCHAR and char array Pin
Richard MacCutchan8-Oct-09 8:29
mveRichard MacCutchan8-Oct-09 8:29 
GeneralRe: Using TCHAR and char array Pin
dipuks8-Oct-09 6:26
dipuks8-Oct-09 6:26 
GeneralRe: Using TCHAR and char array Pin
Richard MacCutchan8-Oct-09 6:55
mveRichard MacCutchan8-Oct-09 6:55 
GeneralRe: Using TCHAR and char array Pin
Rajesh R Subramanian8-Oct-09 7:02
professionalRajesh R Subramanian8-Oct-09 7:02 
GeneralRe: Using TCHAR and char array Pin
Richard MacCutchan8-Oct-09 7:12
mveRichard MacCutchan8-Oct-09 7:12 
AnswerRe: Using TCHAR and char array Pin
Rajesh R Subramanian8-Oct-09 7:00
professionalRajesh R Subramanian8-Oct-09 7:00 
Hi,

You are doing an Unicode build (have defined _UNICODE instead of _MBCS) and therefore TCHAR behaves like wchar_t (double byte character). The API is obviously returning an Unicode string to you, and you have accepted it into an ANSI style string. The Unicode version of the API was called, because you are doing an Unicode build. To solve this, you could do an MBCS build.

However, I strongly recommend the usage of TCHAR instead of char and use neutral string manipulation functions and APIs - for example, _tcscpy instead of strcpy. _tcscpy will behave like strcpy when you do an MBCS build and will behave like wcscpy when you do an Unicode build. This way, you could do an Unicode build and an MBCS build without making changes in the source code.

Take a look at the "Windows Data types" section of this article[^].

I would also recommend this two part article to you:

The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^]
The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^]


It is a crappy thing, but it's life -^ Carlo Pallini

GeneralRe: Using TCHAR and char array Pin
dipuks8-Oct-09 7:56
dipuks8-Oct-09 7:56 
QuestionExecute a GUI dll (SDI MFC) from exe Pin
MrKBA8-Oct-09 4:27
MrKBA8-Oct-09 4:27 
AnswerRe: Execute a GUI dll (SDI MFC) from exe Pin
Code-o-mat8-Oct-09 5:06
Code-o-mat8-Oct-09 5:06 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
MrKBA8-Oct-09 5:14
MrKBA8-Oct-09 5:14 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
Code-o-mat8-Oct-09 5:22
Code-o-mat8-Oct-09 5:22 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
MrKBA8-Oct-09 6:16
MrKBA8-Oct-09 6:16 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
Code-o-mat8-Oct-09 9:14
Code-o-mat8-Oct-09 9:14 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
MrKBA8-Oct-09 11:41
MrKBA8-Oct-09 11:41 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
Code-o-mat8-Oct-09 21:39
Code-o-mat8-Oct-09 21:39 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
Richard MacCutchan8-Oct-09 22:36
mveRichard MacCutchan8-Oct-09 22:36 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
Code-o-mat8-Oct-09 23:30
Code-o-mat8-Oct-09 23:30 
GeneralRe:@ Code-o-mat Execute a GUI dll (SDI MFC) from exe Pin
Richard MacCutchan8-Oct-09 23:56
mveRichard MacCutchan8-Oct-09 23:56 
AnswerRe: Execute a GUI dll (SDI MFC) from exe Pin
Richard MacCutchan8-Oct-09 5:06
mveRichard MacCutchan8-Oct-09 5:06 
GeneralRe: Execute a GUI dll (SDI MFC) from exe Pin
MrKBA8-Oct-09 5:13
MrKBA8-Oct-09 5:13 
GeneralRe: Execute a GUI dll (SDI MFC) from exe Pin
Richard MacCutchan8-Oct-09 6:02
mveRichard MacCutchan8-Oct-09 6:02 
GeneralRe:@ Richard MacCutchan Execute a GUI dll (SDI MFC) from exe Pin
MrKBA8-Oct-09 6:18
MrKBA8-Oct-09 6:18 
GeneralRe:@ Richard MacCutchan Execute a GUI dll (SDI MFC) from exe Pin
Richard MacCutchan8-Oct-09 6:28
mveRichard MacCutchan8-Oct-09 6:28 

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.