How to hide the Console Application in C#
By FoxLearn 7/15/2017 5:51:06 PM 7.97K
How to hide the console application in C#
Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Console Application. Name your project "HideConsole" and then click OK
Step 2: Add code to Program class as below
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; namespace HideConsole { class Program { [DllImport("Kernel32.dll")] private static extern IntPtr GetConsoleWindow(); [DllImport("User32.dll")] private static extern bool ShowWindow(IntPtr hWnd, int cmdShow); static void Main(string[] args) { Console.WriteLine("Press any key to hide me."); Console.ReadKey(); IntPtr hWnd = GetConsoleWindow(); if (hWnd != IntPtr.Zero) { ShowWindow(hWnd, 0);//hide Thread.Sleep(5000);//5s ShowWindow(hWnd, 1);//show } Console.ReadKey(); } } }
VIDEO TUTORIALS
Categories
Popular Posts
Visual Studio: Auto increment version
03/22/2024
What is ARM architecture?
03/11/2024