Just go to the project properties and change the output type from Console Application (console will be displayed here) to Windows Application (console will not be displayed with this setting)
The solution published by the colleague is optimal to hide the console, there is another way that works to hide and show the console, it is done through a pointer that is handled by the Intpr Structure, then the code:
using System.Runtime.InteropServices;
Class Program
{
[DllImport("user32.dll")]
public static extern IntPtr EncontraVentana(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool MostrarVentana(IntPtr hWnd, int nCmdShow);
static void Main(string[] args)
{
Console.Title = "MyConsoleApp";
ManejoConsola(false, Console.Title);
}
public static void ManejoConsola(bool visible, string titulo)
{
IntPtr resultado = EncontraVentana(null, titulo); //Nombre de la consola
if (resultado != IntPtr.Zero)
{
if(!visible)
{
//Esconder Ventana
MostrarVentana(resultado, 0); // 0 = Esconder
}
else
{
//Mostrar Vnetana
MostrarVentana(resultado, 1); //1 = Mostrar
}
}
}
}
Just go to the project properties and change the output type from Console Application (console will be displayed here) to Windows Application (console will not be displayed with this setting)
Good day,
The solution published by the colleague is optimal to hide the console, there is another way that works to hide and show the console, it is done through a pointer that is handled by the Intpr Structure, then the code: