Windows Data Types
A quick reference sheet of Windows data types and their format specifiers.
For BOOL, don’t compare == TRUE, as its an int — compare != FALSE or just use the value directly since any non-zero value is truthy.
| Type | Category | Underlying C type | Bits | printf (ANSI) | wprintf (Unicode) | Notes |
|---|---|---|---|---|---|---|
BYTE | Unsigned int | unsigned char | 8 | %u or %hhu | %u or %hhu | Often used for raw byte buffers. |
CHAR | Integer | char | 8 | %c | %c | ANSI character. Use %s for strings. |
SHORT | Integer | short | 16 | %hd | %hd | Signed 16-bit integer. |
WORD | Unsigned int | unsigned short | 16 | %hu | %hu | Unsigned 16-bit. Common in struct fields. |
INT | Integer | int | 32 | %d or %i | %d or %i | Standard signed 32-bit integer. |
UINT | Unsigned int | unsigned int | 32 | %u | %u | Unsigned 32-bit. Same width as DWORD. |
LONG | Integer | long | 32 | %ld | %ld | Always 32-bit on Windows, unlike Linux. |
ULONG | Unsigned int | unsigned long | 32 | %lu | %lu | Unsigned 32-bit. Very common in WinAPI. |
DWORD | Unsigned int | unsigned long | 32 | %lu or %08lX | %lu or %08lX | Workhorse unsigned 32-bit. Hex with %lX. |
DWORD32 | Unsigned int | unsigned int | 32 | %u | %u | Explicit 32-bit, always UINT underneath. |
DWORD64 | Unsigned int | unsigned __int64 | 64 | %I64u | %I64u | Use %llu on non-MSVC or with _USE_32BIT_TIME_T unset. |
LONGLONG | Integer | __int64 | 64 | %I64d | %I64d | Also valid: PRId64 with <inttypes.h>. |
ULONGLONG | Unsigned int | unsigned __int64 | 64 | %I64u | %I64u | Also valid: PRIu64. Used by FILETIME math. |
INT_PTR | Pointer / handle | __int64 / int | arch | %Id | %Id | Signed, pointer-sized. 64-bit on x64, 32-bit on x86. |
UINT_PTR | Pointer / handle | unsigned __int64 / unsigned int | arch | %Iu | %Iu | Unsigned pointer-sized integer. |
LONG_PTR | Pointer / handle | __int64 / long | arch | %Id | %Id | Pointer-sized signed long. |
ULONG_PTR | Pointer / handle | unsigned __int64 / unsigned long | arch | %Iu | %Iu | Pointer-sized unsigned long. Param for WndProc. |
SIZE_T | Unsigned int | ULONG_PTR | arch | %Iu or %zu | %Iu or %zu | Result of sizeof(). %zu works in C99+ MSVC. |
SSIZE_T | Integer | LONG_PTR | arch | %Id | %Id | Signed SIZE_T. |
PVOID / LPVOID | Pointer / handle | void * | arch | %p | %p | Generic pointer. %p prints address. |
HANDLE | Pointer / handle | void * | arch | %p | %p | Opaque handle. Print address, not value. |
HWND | Pointer / handle | HANDLE | arch | %p | %p | Window handle. |
HMODULE / HINSTANCE | Pointer / handle | HANDLE | arch | %p | %p | Module handle. Treat as pointer. |
FARPROC | Pointer / handle | function pointer | arch | %p | %p | Cast to (void *) before printing. |
CHAR / LPSTR / LPCSTR | String | char * / const char * | 8 | %s | %hs or %S (deprecated) | ANSI string. In wprintf, %hs is safe; %S is legacy. |
WCHAR / LPWSTR / LPCWSTR | String | wchar_t * / const wchar_t * | 16 | %ls or %S (MSVC) | %s or %ls | Wide string. In wprintf: %s. In printf: %ls. L"..." literals. |
TCHAR / LPTSTR / LPCTSTR | String | WCHAR or CHAR (UNICODE macro) | arch | %s or %ls | %s or %ls | Use _T() / TEXT() macros. Expands to WCHAR if UNICODE defined. |
BSTR | String | WCHAR * (length-prefixed) | 16 | %ls | %s | COM string. Use SysAllocString / SysFreeString. |
BOOL | Bool / status | int | 32 | %d | %d | TRUE=1, FALSE=0. NOT a C99 bool. Check != FALSE. |
BOOLEAN | Bool / status | BYTE (unsigned char) | 8 | %u | %u | Used in NT native API. 0=false, non-0=true. |
HRESULT | Bool / status | LONG (signed) | 32 | 0x%08lX | 0x%08lX | Always print as hex. SUCCEEDED() / FAILED() macros. |
NTSTATUS | Bool / status | LONG (signed) | 32 | 0x%08lX | 0x%08lX | NT status code. NT_SUCCESS() macro. |
FLOAT | Float / misc | float | 32 | %f or %g | %f or %g | Single-precision. Same as standard C float. |
DOUBLE | Float / misc | double | 64 | %lf or %g | %lf or %g | Double-precision. %g trims trailing zeros. |
FILETIME | Float / misc | struct { DWORD dwLowDateTime; DWORD dwHighDateTime; } | 64 | %I64u (combine first) | %I64u (combine first) | 100ns intervals since Jan 1 1601. Cast: (ULONGLONG)ft.dwHighDateTime<<32 | ft.dwLowDateTime. |
GUID / UUID | Float / misc | struct (16 bytes) | 128 | StringFromGUID2 or manual sprintf | StringFromGUID2 or swprintf | Print each field individually or use RPC helpers. |
COLORREF | Float / misc | DWORD | 32 | RGB(%u,%u,%u) or 0x%06lX | 0x%06lX | Packed RGB: low byte = red. Use GetRValue / GetGValue / GetBValue. |