C# Console in WinForms
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[DllImport("kernel32.dll")] static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool AllocConsole(); const int SW_HIDE = 0; const int SW_SHOW = 5; void test(){ AllocConsole(); // create console ShowWindow(GetConsoleWindow(), SW_HIDE); // hide console } |
