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

 

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 (可转换的)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值