运行c#程序时禁用shell窗口

运行c#程序时禁用shell窗口,c#,C#,我编写了一些基本程序(来自空项目),它用一些按钮显示窗口,但每当我运行它时,VisualStudio都会向我显示shell黑色窗口,如何禁用此行为?提前感谢请执行以下操作: [DllImport("kernel32.dll")] static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); const in

我编写了一些基本程序(来自空项目),它用一些按钮显示窗口,但每当我运行它时,VisualStudio都会向我显示shell黑色窗口,如何禁用此行为?提前感谢

请执行以下操作:

[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

const int SW_HIDE = 0;
const int SW_SHOW = 5;

var handle = GetConsoleWindow();

// Hide
ShowWindow(handle, SW_HIDE);

// Show
ShowWindow(handle, SW_SHOW);

来源:

只需使用“新建项目向导”创建一个windows应用程序项目或控制台应用程序项目,而不是一个空项目。请检查此处:@Davide Piras:您可以发布它!