Tuesday, January 27, 2026

Zig basic Windows application using win32 API

Zig basic Windows application using win32 API

Info:
OS: Windows 10 IoT LTSC 2021
Zig: 0.15.2

Sample application using zigwin32, Windows API to create basic window that does nothing. It calls the following win32 API functions:
- LoadCursorW
- RegisterClassW
- GetLastError
- CreateWindowExW
- ShowWindow
- GetMessageW
- TranslateMessage
- DispatchMessageW
- DefWindowProcw
And windows WindoProc function for pumping messages.

Create a Zig application, like:
PS C:\prj\> mkdir hellowindow
PS C:\prj\> cd hellowindow
PS C:\prj\hellowindow> zig init
Modify build.zig to add zigwin32. See lines 86-91 in gist below. Update src/main.zig to look like below. Checkout zigwin32 into the root of the project
PS C:\prj\hellowindow> git clone https://github.com/marlersoft/zigwin32 libs/zigwin32
Now do a build:
PS C:\prj\hellowindow> zig build
Or do a release build that produces the smallest binary:
PS C:\prj\hellowindow> zig build -Doptimize=ReleaseSmall

No comments:

Zig basic Windows application using win32 API

Zig basic Windows application using win32 API Info : OS: Windows 10 IoT LTSC 2021 Zig: 0.15.2 Sample application using zigwin32, Window...