Click here to Skip to main content
16,016,537 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to convert PWSTR to char * ? Pin
adara4-May-02 6:25
adara4-May-02 6:25 
AnswerRe: How to convert PWSTR to char * ? Pin
Tom Archer4-May-02 6:42
Tom Archer4-May-02 6:42 
GeneralRe: How to convert PWSTR to char * ? Pin
l a u r e n4-May-02 6:51
l a u r e n4-May-02 6:51 
GeneralRe: How to convert PWSTR to char * ? Pin
Nish Nishant4-May-02 6:55
sitebuilderNish Nishant4-May-02 6:55 
GeneralRe: How to convert PWSTR to char * ? Pin
l a u r e n4-May-02 6:56
l a u r e n4-May-02 6:56 
GeneralThanx ! Pin
adara4-May-02 6:58
adara4-May-02 6:58 
GeneralRe: How to convert PWSTR to char * ? Pin
Nish Nishant4-May-02 7:01
sitebuilderNish Nishant4-May-02 7:01 
GeneralRe: How to convert PWSTR to char * ? Pin
Tom Archer4-May-02 7:00
Tom Archer4-May-02 7:00 
Yep. Does the same thing and definitely much less typing and remembering of parameter values. Great catch!

By the way, check out what these macros expand to OMG | :OMG:

Original C++ code


void SayHello2(PWSTR wstrName)
{
  USES_CONVERSION;
  AfxMessageBox(W2A(wstrName));
}


Expanded macros


void SayHello2(PWSTR wstrName)
{
  int _convert = 0; 
  _convert; 
  UINT _acp = ATL::_AtlGetConversionACP() ; 
  _acp; 
  LPCWSTR _lpw = 0; 
  _lpw; 
  LPCSTR _lpa = 0; 
  _lpa;
  
 AfxMessageBox((((_lpw = wstrName) == 0) ? 0 
   : (_convert = (lstrlenW(_lpw)+1)*2, 
   AtlW2AHelper((LPSTR) _alloca(_convert), 
   _lpw, 
   _convert, 
   _acp))));
}



Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible

A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
GeneralRe: How to convert PWSTR to char * ? Pin
Nish Nishant4-May-02 7:04
sitebuilderNish Nishant4-May-02 7:04 
GeneralRe: How to convert PWSTR to char * ? Pin
Nish Nishant4-May-02 6:51
sitebuilderNish Nishant4-May-02 6:51 
GeneralRe: How to convert PWSTR to char * ? Pin
Tom Archer4-May-02 7:02
Tom Archer4-May-02 7:02 
GeneralRe: How to convert PWSTR to char * ? Pin
Nish Nishant4-May-02 7:06
sitebuilderNish Nishant4-May-02 7:06 
GeneralRe: How to convert PWSTR to char * ? Pin
Tom Archer4-May-02 7:08
Tom Archer4-May-02 7:08 
GeneralRe: How to convert PWSTR to char * ? Pin
Tim Smith4-May-02 16:38
Tim Smith4-May-02 16:38 
GeneralRe: How to convert PWSTR to char * ? Pin
Nish Nishant4-May-02 16:42
sitebuilderNish Nishant4-May-02 16:42 
GeneralAdding a column to DataGrid ... Pin
Hadi Rezaee4-May-02 6:20
Hadi Rezaee4-May-02 6:20 
GeneralPossible Networking Program Design :: Winsock Pin
valikac4-May-02 6:02
valikac4-May-02 6:02 
GeneralRe: Possible Networking Program Design :: Winsock Pin
l a u r e n4-May-02 6:47
l a u r e n4-May-02 6:47 
GeneralRe: Possible Networking Program Design :: Winsock Pin
Felix Gartsman4-May-02 7:29
Felix Gartsman4-May-02 7:29 
GeneralRe: Possible Networking Program Design :: Winsock Pin
valikac4-May-02 8:30
valikac4-May-02 8:30 
GeneralRe: Possible Networking Program Design :: Winsock Pin
Felix Gartsman5-May-02 5:25
Felix Gartsman5-May-02 5:25 
GeneralRe: Possible Networking Program Design :: Winsock Pin
valikac5-May-02 5:40
valikac5-May-02 5:40 
GeneralConfused about FindResource Pin
albean4-May-02 5:48
albean4-May-02 5:48 
GeneralRe: Confused about FindResource Pin
l a u r e n4-May-02 6:55
l a u r e n4-May-02 6:55 
GeneralRe: Confused about FindResource Pin
albean4-May-02 9:12
albean4-May-02 9:12 

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.