start.zig: call wWinMain with root's type

I have an alternative set of windows bindings I'm working on: https://github.com/marler8997/zig-os-windows.  So I'm declaring my wWinMain function with my own HINSTANCE type rather than the one from std.os.windows.  This change allows start to call wWinMain using any pointer type.
This commit is contained in:
Jonathan Marler
2020-11-07 10:44:05 -07:00
committed by Andrew Kelley
parent 48d60834fd
commit 4df75645ce

View File

@@ -354,13 +354,14 @@ pub fn callMain() u8 {
}
pub fn call_wWinMain() std.os.windows.INT {
const hInstance = @ptrCast(std.os.windows.HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?);
const hPrevInstance: ?std.os.windows.HINSTANCE = null; // MSDN: "This parameter is always NULL"
const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.args[0].arg_type.?;
const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?);
const lpCmdLine = std.os.windows.kernel32.GetCommandLineW();
// There's no (documented) way to get the nCmdShow parameter, so we're
// using this fairly standard default.
const nCmdShow = std.os.windows.user32.SW_SHOW;
return root.wWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
// second parameter hPrevInstance, MSDN: "This parameter is always NULL"
return root.wWinMain(hInstance, null, lpCmdLine, nCmdShow);
}