Index Types & Handles Window & Input GDI System & Files File I/O Multimedia

Types & Handles

Fundamental Win32 scalar types, opaque handle types, calling-convention macros, and pointer-width integers. These are the building blocks used by every other part of the API.

Scalar types

Win32 defines its own set of type aliases so that the same code compiles unchanged on 16-bit, 32-bit, and 64-bit targets. Free API mirrors them exactly.

TypeUnderlying typeStatusNotes
BOOLintHEADER_ONLYWin32 boolean. Use TRUE / FALSE macros (1 / 0). Functions may return any non-zero value for TRUE.
BYTEunsigned charHEADER_ONLY8-bit unsigned.
WORDunsigned shortHEADER_ONLY16-bit unsigned.
DWORDunsigned longHEADER_ONLY32-bit unsigned. Used extensively for flags, lengths, and IDs.
UINTunsigned intHEADER_ONLYPlatform-width unsigned integer.
INTintHEADER_ONLYPlatform-width signed integer.
LONGlongHEADER_ONLYAlways 32-bit on Windows; may be 64-bit on LP64 Linux — use LONG only for Win32 struct compatibility.
FLOATfloatHEADER_ONLYSingle-precision float alias.
TRUE / FALSEmacro (1 / 0)HEADER_ONLYStandard BOOL values.
MAX_PATHmacro (260)HEADER_ONLYMaximum path length in characters. POSIX PATH_MAX may differ but 260 is safe for file names passed to Free API.

String / buffer pointer types

TypeUnderlying typeNotes
LPSTRchar*Pointer to mutable ANSI string.
LPCSTRconst char*Pointer to constant ANSI string. Most Free API functions accept LPCSTR for path/name arguments.
LPWSTRwchar_t*Wide string — declared but not used by Free API (no Unicode implementation).
LPCWSTRconst wchar_t*Wide constant string — declared for compilation only.
LPVOIDvoid*Generic pointer.
LPCVOIDconst void*Pointer to read-only memory.
LPBYTEBYTE*Byte buffer pointer.

Geometry types

TypeFieldsNotes
RECT / LPRECTLONG left, top, right, bottomAxis-aligned rectangle. Used by GetClientRect, IntersectRect, etc.
POINT / LPPOINTLONG x, yScreen or client coordinates. Used by GetCursorPos, ClientToScreen, etc.
SIZELONG cx, cyWidth/height pair.
C++ — typical usage of scalar types
#include <windows.h>

// DWORD for counts, flags, and IDs
DWORD flags = MCI_OPEN_TYPE | MCI_OPEN_ELEMENT;
DWORD tick  = GetTickCount();

// BOOL return values — test with != FALSE, not == TRUE
BOOL ok = CreateDirectoryA("saves", NULL);
if (ok != FALSE) { /* directory created */ }

// RECT filled by the API
RECT rc;
GetClientRect(hwnd, &rc);
int width  = rc.right  - rc.left;
int height = rc.bottom - rc.top;

// POINT for cursor position
POINT pt;
GetCursorPos(&pt);          // screen coords
ScreenToClient(hwnd, &pt);  // convert to window-client coords
      

Opaque handle types

Win32 uses opaque handles to refer to kernel objects. Free API maps each handle type to an internal registry entry backed by SDL3 objects.

TypeFree API backingStatusNotes
HWND Internal window registry (SDL windowID) PARTIAL Returned by CreateWindowExA. Maps to exactly one SDL window. Valid until DestroyWindow is called. HWND_DESKTOP is defined as ((HWND)0).
HDC Internal DC record (pointer to SDL surface) PARTIAL Either a memory DC (CreateCompatibleDC) or a surface DC. Only SRCCOPY blitting between these two types is implemented.
HBITMAP SDL3 surface (RGBA32) PARTIAL Returned by LoadImageA and CreateBitmap. Must be freed with DeleteObject.
HGDIOBJ Generic GDI handle (HBITMAP or other) PARTIAL Used as parameter/return type of SelectObject and DeleteObject. Cast freely between HBITMAP and HGDIOBJ.
HINSTANCE / HMODULE NULL STUB Always NULL. Target games pass it to CreateWindowExA / RegisterClassA where it is ignored by Free API.
HMENU NULL STUB Menus are not implemented. Pass NULL wherever HMENU is needed.
HICON / HCURSOR NULL STUB LoadIconA and LoadCursorA return NULL. Games that test the result before use will not crash.
HBRUSH NULL STUB Background brush in WNDCLASSA.hbrBackground is stored but not used during window painting.
HANDLE Generic opaque handle PARTIAL Base handle type. Alias for void*. Used by LoadImageA return type.
HRSRC / HGLOBAL NULL STUB Win32 resource handles. All resource functions (FindResourceA, LoadResource…) are stubs.
ATOM typedef WORD HEADER_ONLY Returned by RegisterClassA. Free API always returns 1 (non-zero = success).
C++ — handle lifecycle example
// Window handle — create → use → destroy
HWND hwnd = CreateWindowA("MyClass", "Title",
    WS_OVERLAPPEDWINDOW, 100, 100, 800, 600,
    NULL, NULL, NULL, NULL);

// Bitmap handle — load → select into DC → use → cleanup
HBITMAP hBmp = (HBITMAP)LoadImageA(
    NULL, "assets/sprites.bmp",
    IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

HDC hdcMem  = CreateCompatibleDC(NULL);
HGDIOBJ old = SelectObject(hdcMem, hBmp);

// ... use hdcMem for blitting ...

// Always restore and clean up
SelectObject(hdcMem, old);
DeleteDC(hdcMem);
DeleteObject(hBmp);
      

Calling conventions & pointer-width integers

Macro / TypeOn non-MSVCPurpose
WINAPIexpands to nothingStandard Win32 calling convention. Applied to all API function declarations.
WINAPIVexpands to nothingVariadic variant (e.g. wsprintfA).
CALLBACKexpands to nothingMarks user-supplied callbacks (WNDPROC, LPTIMECALLBACK).
WPARAMuintptr_tUnsigned pointer-width; first message parameter.
LPARAMintptr_tSigned pointer-width; second message parameter. Mouse coordinates packed as (y<<16)|x.
LRESULTintptr_tReturn value of WNDPROC and DispatchMessageA.
DWORD_PTRuintptr_tDWORD stretched to pointer width. Used by MCI callback parameters.
UINT_PTRuintptr_tUINT stretched to pointer width. Used by timer IDs.
LONG_PTRintptr_tLONG stretched to pointer width.
ULONG_PTRuintptr_tULONG stretched to pointer width.
lParam mouse coordinate packing Mouse messages encode cursor position as lParam = (y << 16) | (x & 0xFFFF). Extract with the standard macros: int x = LOWORD(lParam); and int y = HIWORD(lParam); (both defined in minwindef.h).

String types, HRESULT & COM basics

SymbolUnderlying typeStatusNotes
CHARcharHEADER_ONLYANSI character.
WCHARwchar_tHEADER_ONLYWide character. Unicode APIs not implemented.
TCHARchar (ANSI build)HEADER_ONLYResolves to CHAR when UNICODE is not defined (default for Free API).
HRESULTlongHEADER_ONLYCOM result code. Negative = error, zero or positive = success.
S_OK0x00000000HEADER_ONLYCOM success.
S_FALSE0x00000001HEADER_ONLYCOM success with alternate result.
E_FAIL0x80004005HEADER_ONLYGeneric COM failure.
GUIDstruct {Data1,Data2,Data3,Data4}HEADER_ONLY128-bit globally unique identifier. Declared for compilation compatibility.
C++ — HRESULT pattern
// HRESULT success test — use SUCCEEDED/FAILED macros
HRESULT hr = SomeComFunction();
if (SUCCEEDED(hr)) {
    // ok — hr is S_OK (0) or S_FALSE (1)
} else {
    // error — hr has a negative value like E_FAIL
}

// Equivalent manual test
if (hr >= 0) { /* success */ }