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();
}



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, August 20, 2020

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250