If you need to determine whether there's a console window for the current process, you can do it as follows:
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr GetConsoleWindow();
internal static bool HasConsoleWindow()
{
return GetConsoleWindow() != IntPtr.Zero;
}