class Program { [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); static void Main(string[] args) { Console.Title = "WAHAHA"; IntPtr intptr = FindWindow("ConsoleWindowClass", "WAHAHA"); if (intptr != IntPtr.Zero) { ShowWindow(intptr, 0);//隐藏这个窗口 } string x; x = Console.ReadLine(); } }通过以上代码只能是让其闪的时间变得纪委短暂。有时候还是看到有框出现。
代码摘自网络
本文详细介绍了如何在C#控制台应用程序中隐藏黑窗口,通过修改项目属性和代码实现,使得程序在运行时仅显示应用程序界面,不出现控制台窗口。
691

被折叠的 条评论
为什么被折叠?



