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.

TypeCategoryUnderlying C typeBitsprintf (ANSI)wprintf (Unicode)Notes
BYTEUnsigned intunsigned char8%u or %hhu%u or %hhuOften used for raw byte buffers.
CHARIntegerchar8%c%cANSI character. Use %s for strings.
SHORTIntegershort16%hd%hdSigned 16-bit integer.
WORDUnsigned intunsigned short16%hu%huUnsigned 16-bit. Common in struct fields.
INTIntegerint32%d or %i%d or %iStandard signed 32-bit integer.
UINTUnsigned intunsigned int32%u%uUnsigned 32-bit. Same width as DWORD.
LONGIntegerlong32%ld%ldAlways 32-bit on Windows, unlike Linux.
ULONGUnsigned intunsigned long32%lu%luUnsigned 32-bit. Very common in WinAPI.
DWORDUnsigned intunsigned long32%lu or %08lX%lu or %08lXWorkhorse unsigned 32-bit. Hex with %lX.
DWORD32Unsigned intunsigned int32%u%uExplicit 32-bit, always UINT underneath.
DWORD64Unsigned intunsigned __int6464%I64u%I64uUse %llu on non-MSVC or with _USE_32BIT_TIME_T unset.
LONGLONGInteger__int6464%I64d%I64dAlso valid: PRId64 with <inttypes.h>.
ULONGLONGUnsigned intunsigned __int6464%I64u%I64uAlso valid: PRIu64. Used by FILETIME math.
INT_PTRPointer / handle__int64 / intarch%Id%IdSigned, pointer-sized. 64-bit on x64, 32-bit on x86.
UINT_PTRPointer / handleunsigned __int64 / unsigned intarch%Iu%IuUnsigned pointer-sized integer.
LONG_PTRPointer / handle__int64 / longarch%Id%IdPointer-sized signed long.
ULONG_PTRPointer / handleunsigned __int64 / unsigned longarch%Iu%IuPointer-sized unsigned long. Param for WndProc.
SIZE_TUnsigned intULONG_PTRarch%Iu or %zu%Iu or %zuResult of sizeof(). %zu works in C99+ MSVC.
SSIZE_TIntegerLONG_PTRarch%Id%IdSigned SIZE_T.
PVOID / LPVOIDPointer / handlevoid *arch%p%pGeneric pointer. %p prints address.
HANDLEPointer / handlevoid *arch%p%pOpaque handle. Print address, not value.
HWNDPointer / handleHANDLEarch%p%pWindow handle.
HMODULE / HINSTANCEPointer / handleHANDLEarch%p%pModule handle. Treat as pointer.
FARPROCPointer / handlefunction pointerarch%p%pCast to (void *) before printing.
CHAR / LPSTR / LPCSTRStringchar * / const char *8%s%hs or %S (deprecated)ANSI string. In wprintf, %hs is safe; %S is legacy.
WCHAR / LPWSTR / LPCWSTRStringwchar_t * / const wchar_t *16%ls or %S (MSVC)%s or %lsWide string. In wprintf: %s. In printf: %ls. L"..." literals.
TCHAR / LPTSTR / LPCTSTRStringWCHAR or CHAR (UNICODE macro)arch%s or %ls%s or %lsUse _T() / TEXT() macros. Expands to WCHAR if UNICODE defined.
BSTRStringWCHAR * (length-prefixed)16%ls%sCOM string. Use SysAllocString / SysFreeString.
BOOLBool / statusint32%d%dTRUE=1, FALSE=0. NOT a C99 bool. Check != FALSE.
BOOLEANBool / statusBYTE (unsigned char)8%u%uUsed in NT native API. 0=false, non-0=true.
HRESULTBool / statusLONG (signed)320x%08lX0x%08lXAlways print as hex. SUCCEEDED() / FAILED() macros.
NTSTATUSBool / statusLONG (signed)320x%08lX0x%08lXNT status code. NT_SUCCESS() macro.
FLOATFloat / miscfloat32%f or %g%f or %gSingle-precision. Same as standard C float.
DOUBLEFloat / miscdouble64%lf or %g%lf or %gDouble-precision. %g trims trailing zeros.
FILETIMEFloat / miscstruct { 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 / UUIDFloat / miscstruct (16 bytes)128StringFromGUID2 or manual sprintfStringFromGUID2 or swprintfPrint each field individually or use RPC helpers.
COLORREFFloat / miscDWORD32RGB(%u,%u,%u) or 0x%06lX0x%06lXPacked RGB: low byte = red. Use GetRValue / GetGValue / GetBValue.

This site uses Just the Docs, a documentation theme for Jekyll.