G
Guest
Hi,
Any one knows how to convert CString to LPCWSTR?
Please advice, thanks!
-P
Any one knows how to convert CString to LPCWSTR?
Please advice, thanks!
-P
Antti Keskinen said:Hello !
LPCWSTR is a pointer to a constant wchar_t string.
Using Visual Studio .NET 2003 this is an easy task. In the ATL-MFC version
7, a set of conversion macros are provided to simplify the process. So, in
order to convert it, the following command would do it
CT2CW( (LPCTSTR) MyStringObj );
This would return a constant pointer to a wchar_t string (LPCWSTR). Note
that if you wish to save this, reserve memory for a wchar_t string and then
use string copying to copy from the return value of this macro into the new
string. For further information, see MSDN with topic "ATL and MFC String
Conversion Macros". Or use keyword search with the macro name.
If you don't have .NET 2003, you can still do the conversion, but must use
the old-style macros, which are somewhat less sophisticated (read: might
contain bugs). The calling convention of this would be:
T2W( (LPCTSTR) MyStringObj );
Hope this helps !
-Antti Keskinen