您的位置:首页 > 编程语言

Win32编程常见字符类型(摘自MSDN)

2011-10-11 13:32 246 查看
LPCSTR
Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
This type is declared in WinNT.h as follows:
typedef __nullterminated CONST CHAR *LPCSTR;
指向以NULL结尾的const ansi字符串(每个字符为8位)

LPCWSTR
Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
This type is declared in WinNT.h as follows:
typedef CONST WCHAR *LPCWSTR;
指向以NULL结尾的const unicode字符串(每个字符为16位)

LPCTSTR
An LPCWSTR if UNICODE is defined, an LPCSTR otherwise.
This type is declared in WinNT.h as follows:
#ifdef UNICODE
typedef LPCWSTR LPCTSTR;
#else
typedef LPCSTR LPCTSTR;
#endif
可在LPCSTR和LPCWSTR两种数据类型间转换,取决于与预处理宏UNICODE的定义与否

LPSTR
Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
This type is declared in WinNT.h as follows:
typedef CHAR *LPSTR;
指向以NULL结尾的ansi字符串 (每个字符为8位)

LPWSTR

Pointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts.
This type is declared in WinNT.h as follows:
typedef WCHAR *LPWSTR;
指向以NULL结尾的unicode字符串(每个字符为16位)

LPTSTR

An LPWSTR if UNICODE is defined, an LPSTR otherwise.
This type is declared in WinNT.h as follows:
#ifdef UNICODE
typedef LPWSTR LPTSTR;
#else
typedef LPSTR LPTSTR;
#endif
可在LPSTR和LPWSTR两种数据类型间转换,取决于与预处理宏UNICODE的定义与否

TCHAR
A WCHAR if UNICODE is defined, a CHAR otherwise.
This type is declared in WinNT.h as follows:
#ifdef UNICODE
typedef WCHAR TCHAR;
#else
typedef char TCHAR;
#endif
可在char和wchar之间转换,取决于与预处理宏UNICODE的定义与否

助记字母:

LP – long pointer (32位指针,win32编程指针都为LP)

C – constant

W – wide(UNICODE宽字符)

T – transferable (可转换的)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: