在VC6.0中的CString 到.NET平台中因为CString 对应设置为Unicode为wchar,所以需要做转化,才能将6.0平台中的CString移植过来。
CW2A
pszA((PCWSTR)strFilename);
const
char
*
pfilename = pszA;
1、
对于
CString strFilename
利用
(PCWSTR)
strFilename
提取
CString
对象的
CONST
WCHAR *
指针,其中
typedef CONST WCHAR *PCWSTR;
2、
利用
CW2A pszA(…)
宏将
LPCWSTR
转化成
LPCSTR,
并将转化成的
ansi
字符指针放到
pszA
中
3、
A CString
object also can act like a literal C-style string (an PCXSTR
, which is the same as const char*
if not under Unicode
,在
Unicode
下是
const wchar *
).
The
CSimpleStringT::operator
PCXSTR
conversion operator allows CString
objects to be freely substituted for character pointers in function calls.
.NET平台中VC6.0中CString到const char *转化问题
最新推荐文章于 2020-04-02 17:45:22 发布