When using WinMain, you are bypassing the DRuntime entry point,
meaning the runtime is never initialized. You need to do it
manually. However, since you're passing /SUBSYSTEM:windows on the
command line, you *don't need* WinMain. That flag is for when you
want to use main, but don't want the console to popup. If you use
WinMain, you do not need that flag. To keep things simple, I
recommend you use the /SUBSYSTEM:windows flag together with a
regular main and drop WinMain completely. You can drop the
/EXETYPE flag as well.

Actually, I need to amend that. It isn't needed with WinMain when
using the Microsoft linker, but it is when using OPTLINK. The MS
linker recognizes WinMain and treats it as /SUBSYSTEM:WINDOWS by
default.

Actually, I need to amend that. It isn't needed with WinMain
when using the Microsoft linker, but it is when using OPTLINK.
The MS linker recognizes WinMain and treats it as
/SUBSYSTEM:WINDOWS by default.