c# 隐藏控制台窗口

 

[DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

 

Console.Title = "WAHAHA"; //为控制台窗体指定一个标题
IntPtr intptr = FindWindow("ConsoleWindowClass", "WAHAHA");
 if (intptr != IntPtr.Zero)
{
ShowWindow(intptr, 0);//隐藏这个窗口
}

 

你可能感兴趣的:(String,user,C#)