They are documented on MSDN. Here's a few:
TCHAR
: A WCHAR
if UNICODE
is defined, a CHAR
otherwise.
WCHAR
: A 16-bit Unicode character.
CHAR
: An 8-bit Windows (ANSI) character.
LPTSTR
: An LPWSTR
if UNICODE
is defined, an LPSTR
otherwise.
LPSTR
: A pointer to a null-terminated string of 8-bit Windows (ANSI) characters.
LPWSTR
: A pointer to a null-terminated string of 16-bit Unicode characters.
LPCTSTR
: An LPCWSTR
if UNICODE
is defined, an LPCSTR
otherwise.
LPCWSTR
: A pointer to a constant null-terminated string of 16-bit Unicode characters.
LPCSTR
: A pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.
Note that some of these types map to something different depending on whether UNICODE
has been #define
'd. By default, they resolve to the ANSI versions:
#include <windows.h>
// LPCTSTR resolves to LPCSTR
When you #define UNICODE
before #include <windows.h>
, they resolve to the Unicode versions.
#define UNICODE
#include <windows.h>
// LPCTSTR resolves to LPCWSTR
They are in reality typedef
s to some fundamental types in the C and C++ language. For example:
typedef char CHAR;
typedef wchar_t WCHAR;
On compilers like Visual C++, there's really no difference between an LPCSTR
and a const char*
or a LPCWSTR
and a const wchar_t*
. This might differ between compilers however, which is why these data types exist in the first place!
It's sort of like the Windows API equivalent of <cstdint>
or <stdint.h>
. The Windows API has bindings in other languages, and having data types with a known size is useful, if not required.