Articles → CSHARP → Hide Console Application Window In C#
Hide Console Application Window In C#
Code
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void Main(string[] args) {
IntPtr hWnd = FindWindow(null, Console.Title); //put your console window caption here
if (hWnd != IntPtr.Zero) {
//Hide the window
ShowWindow(hWnd, 0); // 0 = SW_HIDE
}
Console.ReadLine();
}