Created
March 2, 2019 18:22
-
-
Save etigui/2cb7a81000b1307b8eb0266660fb7ba8 to your computer and use it in GitHub Desktop.
Hide and show console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using ...; | |
| namespace test { | |
| class Program { | |
| [DllImport("kernel32.dll")] | |
| static extern IntPtr GetConsoleWindow(); | |
| [DllImport("user32.dll")] | |
| static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); | |
| const int SW_HIDE = 0; | |
| const int SW_SHOW = 5; | |
| private static void Main(string[] args) { | |
| var handle = GetConsoleWindow(); | |
| // Hide | |
| ShowWindow(handle, SW_HIDE); | |
| // Show | |
| //ShowWindow(handle, SW_SHOW); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment