How to determine if a console window exists for the current process

October 2, 2009

tags: ,
no comments

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;

        }

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*