In previous blog posts, we decoded some Windows SDK string typedefs like PWSTR and PCWSTR. As we already saw, they are basically typedefs for C-style null-terminated wchar_t Unicode UTF-16 string pointers. In particular, the “C” in PCWSTR means that the string is read-only (const).
To recap these typedefs in table form, we have:
| Windows SDK Typedef | C/C++ Underlying Type |
| PWSTR | wchar_t* |
| PCWSTR | const wchar_t* |
Now, as you can imagine, there are also char-based variants of these wchar_t string typedefs. You can easily recognize their names as the char versions do not have the “W” (which stands for WCHAR or equivalently wchar_t): They are PSTR and PCSTR.
As you can see, there is the “STR” part in their names, specifying that these are C-style null-terminated strings. The “P” stands for pointer. So, in table form, they correspond to the following C/C++ underlying types:
| Windows SDK Typedef | C/C++ Underlying Type |
| PSTR | char* |
| PCSTR | const char* |
As expected, the const version, which represents read-only strings, has the letter “C” before “STR”.
These char-based string pointers can be used to represent ASCII strings, strings in some kind of multi-byte encoding, and even UTF-8-encoded strings.
Moreover, as we already saw for the wchar_t versions, another common prefix you can find for them is “LP” instead of just “P” for “pointer”, as in LPSTR and LPCSTR. LPSTR is the same as PSTR; similarly, LPCSTR is the same as PCSTR.
In table form:
| Windows SDK Typedef | C/C++ Underlying Type |
| PSTR | char* |
| LPSTR | char* |
| PCSTR | const char* |
| LPCSTR | const char* |