windows各种恼人的变量定义

MSDN地址(https://msdn.microsoft.com/en-us/library/cc230347.aspx),原文含所有变量的说明,这里只是将最近经常遇到的,让人混乱的部分粘贴过来,便于实时翻阅


 

LPCSTR

An LPCSTR is a 32-bit pointer to a constant null-terminated string of 8-bit Windows (ANSI)
characters.
This type is declared as follows:

typedef const char* LPCSTR;

 

LPCVOID

An LPCVOID is a 32-bit pointer to a constant of any type.
This type is declared as follows:

typedef const void* LPCVOID;

 

LPCWSTR

An LPCWSTR is a 32-bit pointer to a constant string of 16-bit Unicode characters, which MAY be
null-terminated.
This type is declared as follows:

typedef const wchar_t* LPCWSTR;

 

LPSTR

The LPSTR type and its alias PSTR specify a pointer to an array of 8-bit characters, which MAY
be terminated by a null character.
In some protocols, it may be acceptable to not terminate with a null character, and this option
will be indicated in the specification. In this case, the LPSTR or PSTR type MUST either be
tagged with the IDL modifier [string], that indicates string semantics, or be accompanied by an
explicit length specifier, for example [size_is()].
The format of the characters MUST be specified by the protocol that uses them. Two common
8-bit formats are ANSI and UTF-8.
A 32-bit pointer to a string of 8-bit characters, which MAY be null-terminated.
This type is declared as follows:

typedef char* PSTR, *LPSTR;

 

LPWSTR

The LPWSTR type is a 32-bit pointer to a string of 16-bit Unicode characters, which MAY be
null-terminated. The LPWSTR type specifies a pointer to a sequence of Unicode characters,
which MAY be terminated by a null character (usually referred to as "null-terminated Unicode").
In some protocols, an acceptable option may be to not terminate a sequence of Unicode
characters with a null character. Where this option applies, it is indicated in the protocol
specification. In this situation, the LPWSTR or PWSTR type MUST either be tagged with the IDL
modifier [string], which indicates string semantics, or MUST be accompanied by an explicit
length specifier, as specified in the RPC_UNICODE_STRING (section 2.3.10) structure.
This type is declared as follows:

typedef wchar_t* LPWSTR, *PWSTR;

 

LMCSTR

A LMCSTR is a 32-bit pointer to a constant null-terminated string of 16-bit Unicode characters.
This type is declared as follows:

typedef const wchar_t* LMCSTR;
LMSTR

A LMSTR is a 32-bit pointer to a null-terminated string of 16-bit Unicode characters.
This type is declared as follows:

typedef WCHAR* LMSTR;

 

WCHAR

A WCHAR is a 16-bit Unicode character.
This type is declared as follows:

typedef wchar_t WCHAR, *PWCHAR;

 

WORD

A WORD is a 16-bit unsigned integer (range: 0 through 65535 decimal). Because a WORD is
unsigned, its first bit (Most Significant Bit (MSB)) is not reserved for signing.
This type is declared as follows:

typedef unsigned short WORD, *PWORD, *LPWORD;

 

DWORD

A DWORD is a 32-bit unsigned integer (range: 0 through 4294967295 decimal). Because a
DWORD is unsigned, its first bit (Most Significant Bit (MSB)) is not reserved for signing.
This type is declared as follows:

typedef unsigned long DWORD, *PDWORD, *LPDWORD;

 

QWORD

A QWORD is a 64-bit unsigned integer.
This type is declared as follows:

typedef unsigned __int64 QWORD;

 

STRING

Unless otherwise noted, a STRING is a UCHAR buffer that represents a null-terminated string of
8-bit characters.
This type is declared as follows:

typedef UCHAR* STRING;

 

UCHAR

A UCHAR is an 8-bit integer with the range: 0 through 255 decimal. Because a UCHAR is
unsigned, its first bit (Most Significant Bit (MSB)) is not reserved for signing.
This type is declared as follows:

typedef unsigned char UCHAR, *PUCHAR;

 

最易让人混淆的就是各种LP**STR,网上有比较简单的记法:

L -- 代表Long型(32bit)

P -- 代表pointer指针

C -- 代表Constant常量

W -- 代表宽字符wchat_t

STR -- 代表字符串(应该就是指*这个东西)

 

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据