| ... | @@ -734,24 +734,21 @@ pub fn call_wWinMain() std.os.windows.INT { | ... | @@ -734,24 +734,21 @@ pub fn call_wWinMain() std.os.windows.INT { |
| 734 | // - u32 in PEB.ProcessParameters.dwShowWindow | 734 | // - u32 in PEB.ProcessParameters.dwShowWindow |
| 735 | // Since STARTUPINFO is the bottleneck for the allowed values, we use `u16` as the | 735 | // Since STARTUPINFO is the bottleneck for the allowed values, we use `u16` as the |
| 736 | // type which can coerce into i32/c_int/u32 depending on how the user defines their wWinMain | 736 | // type which can coerce into i32/c_int/u32 depending on how the user defines their wWinMain |
| 737 | // (the Win32 docs show wWinMain with `int` as the type for nCmdShow). | 737 | // (the Win32 docs show wWinMain with `int` as the type for nShowCmd). |
| 738 | const nCmdShow: u16 = nCmdShow: { | 738 | const nShowCmd: u16 = nShowCmd: { |
| 739 | // This makes Zig match the nCmdShow behavior of a C program with a WinMain symbol: | 739 | // This makes Zig match the nShowCmd behavior of a C program with a WinMain symbol: |
| 740 | // - With STARTF_USESHOWWINDOW set in STARTUPINFO.dwFlags of the CreateProcess call: | 740 | // - With STARTF_USESHOWWINDOW set in STARTUPINFO.dwFlags of the CreateProcess call: |
| 741 | // - Compiled with subsystem:console -> nCmdShow is always SW_SHOWDEFAULT | 741 | // - nShowCmd is STARTUPINFO.wShowWindow from the parent CreateProcess call |
| 742 | // - Compiled with subsystem:windows -> nCmdShow is STARTUPINFO.wShowWindow from | | |
| 743 | // the parent CreateProcess call | | |
| 744 | // - With STARTF_USESHOWWINDOW unset: | 742 | // - With STARTF_USESHOWWINDOW unset: |
| 745 | // - nCmdShow is always SW_SHOWDEFAULT | 743 | // - nShowCmd is always SW_SHOWDEFAULT |
| 746 | const SW_SHOWDEFAULT = 10; | 744 | const SW_SHOWDEFAULT = 10; |
| 747 | const STARTF_USESHOWWINDOW = 1; | 745 | const STARTF_USESHOWWINDOW = 1; |
| 748 | // root having a wWinMain means that std.builtin.subsystem will always have a non-null value. | 746 | if (peb.ProcessParameters.dwFlags & STARTF_USESHOWWINDOW != 0) { |
| 749 | if (std.builtin.subsystem.? == .Windows and peb.ProcessParameters.dwFlags & STARTF_USESHOWWINDOW != 0) { | 747 | break :nShowCmd @truncate(peb.ProcessParameters.dwShowWindow); |
| 750 | break :nCmdShow @truncate(peb.ProcessParameters.dwShowWindow); | | |
| 751 | } | 748 | } |
| 752 | break :nCmdShow SW_SHOWDEFAULT; | 749 | break :nShowCmd SW_SHOWDEFAULT; |
| 753 | }; | 750 | }; |
| 754 | | 751 | |
| 755 | // second parameter hPrevInstance, MSDN: "This parameter is always NULL" | 752 | // second parameter hPrevInstance, MSDN: "This parameter is always NULL" |
| 756 | return root.wWinMain(hInstance, null, lpCmdLine, nCmdShow); | 753 | return root.wWinMain(hInstance, null, lpCmdLine, nShowCmd); |
| 757 | } | 754 | } |