<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx</link><description>This is another common asked question. But it is a Win32 question. In Windows GUI applications and Console applications are very different. GUI applications have at least one window, and a message loop, but no standard in/out/error. Console applications</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#68562</link><pubDate>Sat, 07 Feb 2004 05:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:68562</guid><dc:creator>consoled</dc:creator><description>So is that the same for cmd.exe? Or does the OS do something special? If I launch it from Win+R it creates a new window, but if I then call cmd again from within that console itself, it creates a new cmd instance and redirects its stdio to the same window.</description></item><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#68676</link><pubDate>Sat, 07 Feb 2004 09:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:68676</guid><dc:creator>Eric J. Smith</dc:creator><description>Are there any issues with simply renaming a .NET console .exe to .com?</description></item><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#68828</link><pubDate>Sat, 07 Feb 2004 13:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:68828</guid><dc:creator>Junfeng Zhang</dc:creator><description>Eric,&lt;br&gt;See my another post &amp;quot;Name of your-app.exe&amp;quot;. Basically we won't be able to find itself in non-default domain because we only probe .dll/.exe&lt;br&gt;&lt;br&gt;Consoled,&lt;br&gt;It is nothing special for cmd.exe. Console apps by default re-use parent's console, unless you specify a flag in CreateProcess. If launched from explorer, because explorer is a GUI app, a new console is created for cmd.exe (because cmd.exe is a console app). If launched from cmd.exe itself, it re-uses the existing console.</description></item><item><title>Make an application a GUI and Console application</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#70418</link><pubDate>Tue, 10 Feb 2004 08:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70418</guid><dc:creator>Mark Olson's blog</dc:creator><description /></item><item><title>Make an application a GUI and Console application</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#70433</link><pubDate>Tue, 10 Feb 2004 08:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:70433</guid><dc:creator>Mark Olson's blog</dc:creator><description /></item><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#72719</link><pubDate>Sat, 14 Feb 2004 18:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:72719</guid><dc:creator>Nate W</dc:creator><description>Note that when launching ildasm from explorer.exe, it's not unusual to see a console window flicker briefly. &lt;br&gt;&lt;br&gt;The problem is that the OS decides whether or not your app needs a console before your app begins to execute, based on information in the .exe header.  The gui-vs-console decision is made at build time, not execution time.  If you attempt to have one executable fulfill both roles, you will have to put up with quirks.&lt;br&gt;&lt;br&gt;If you build as a console app, and get run from a GUI tool (e.g. explorer), a console window will be created before your application begins to execute.  If you build as a GUI app, the OS will detach your application from the console before your own code begins to execute.  The former is only slightly inelegant - you can close that console window easily.  The latter is a more substantial problem because you cannot re-attach to the console from which the application was spawned.  By the time your code starts executing, the console may already have issued a C:&amp;gt; prompt and the user could be typing their next command - or worse, your application may have been run from a batch file and the next command in the batch is already piping information into a log file before your application begins executing.&lt;br&gt;&lt;br&gt;Far as I can tell, the devenv.com / devnenv.exe solution seems to be the most elegant.</description></item><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#75159</link><pubDate>Wed, 18 Feb 2004 18:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:75159</guid><dc:creator>Ian Griffiths</dc:creator><description>I'm not clear on why editbin is needed.&lt;br&gt;&lt;br&gt;You mention fundamental features of a GUI app: &amp;quot;GUI applications have at least one window, and a message loop,&amp;quot; but there's absolutely nothing stopping a console application having these.  The fact that you have a stdin and stdout doesn't stop you from also opening windows.&lt;br&gt;&lt;br&gt;There's no real need to use editbin.  I just used VS.NET 2003 to build a standard Win32 console application.  I then put enough of the code from the good old 'Generic' sample in the PSDK to get a window up and running.  Works fine.  I have a window that behaves normally, and also a console window that behaves normally.&lt;br&gt;&lt;br&gt;This has always worked.  The console vs windows app is mainly a matter of a linker switch and supplying the right kind of entry point.</description></item><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#75218</link><pubDate>Wed, 18 Feb 2004 20:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:75218</guid><dc:creator>Junfeng Zhang</dc:creator><description>Everything has a story. &lt;br&gt;&lt;br&gt;Here is what the author of ildasm says:&lt;br&gt;&lt;br&gt;-------------------------------------------&lt;br&gt;From: &lt;br&gt;To: Junfeng Zhang&lt;br&gt;Subject: RE: Mixed console/windows app&lt;br&gt;&lt;br&gt;It's actually quite a story.&lt;br&gt;&lt;br&gt;Initially, ILDASM was a console app that by default dumped the disassembly text to the console window, or launched GUI when prompted by the command line option. People started complaining that when they launch ILDASM in GUI mode from a console window, it doesn't release the console window (of course it doesn't -- it's a console app). &lt;br&gt;&lt;br&gt;OK, so I've made ILDASM a GUI app and GUI was made the default mode. Launched from a console window in GUI mode, ILDASM immediately released the console. People started complaining that they want to dump the disassembly text to a console window. &lt;br&gt;&lt;br&gt;OK, so I added console window popping up whenever console dump was ordered. ILDASM released the original console, popped up new console when ordered, and dumped the disassembly text there. People started complaining that they can't redirect console dump to a file. Why it's preferable to do &amp;quot;ildasm MyApp.dll /text &amp;gt; MyApp.il&amp;quot; instead of &amp;quot;ildasm MyApp.dll /out=MyApp.il&amp;quot;, still remains mystery to me.&lt;br&gt;&lt;br&gt;OK, so I've made ILDASM a GUI-disguised-as-console app. It releases the console window in GUI mode, it dumps the disassembly text to the console window when ordered, and you can redirect this console dump to a file. People started complaining that when ILDASM is launched from Windows Explorer, it momentarily flashes a console window before going into GUI mode (Nate is not actually the first one to notice this effect). Sorry, folks, I'm afraid I can't fix that without breaking some of the above.&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Unable to launch notepad from 'Run' or view HTML source</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#151910</link><pubDate>Wed, 09 Jun 2004 22:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:151910</guid><dc:creator>David Cumps</dc:creator><description /></item><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#186190</link><pubDate>Sun, 18 Jul 2004 15:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:186190</guid><dc:creator>Uriel Mondrowicz</dc:creator><description>Hi All,&lt;br&gt;&lt;br&gt;I have seen this thread on Junfeng Zhang's blog which is related to an ongoing issue I have.&lt;br&gt;Zhang, thank you very much for your post.&lt;br&gt;&lt;br&gt;I'm trying to build in C# a simple tool that should be used in dual mode:&lt;br&gt;1. Windows Application when called without any arguments (or simply&lt;br&gt;double-clicked)&lt;br&gt;2. Console Application when called from a command line with some arguments&lt;br&gt;&lt;br&gt;I could create a parent console application that runs from a command line&lt;br&gt;(and sends its output to the stdout console) when it is called with some&lt;br&gt;arguments.&lt;br&gt;If it detects that no arguments were entered (args.Length == 0) it opens a&lt;br&gt;windows form using the frmGUI.ShowDialog() method.&lt;br&gt;&lt;br&gt;My main problem is that when clicking on the tool executable to run it as a&lt;br&gt;win GUI, it will open a black console window for a second, dissapear, and&lt;br&gt;then show the GUI form.&lt;br&gt;This is very annoying, and I'm sure there is a way to resolve this black&lt;br&gt;screen issue. Although it has the same bahavior as the ILDASM as described by it's author.&lt;br&gt;I tried using FreeConsole() method in my entry point just before checking&lt;br&gt;the args but it still shows the black console for a second.&lt;br&gt;&lt;br&gt;I cannot use the MSDEV approach as I have to keep it in only one executable standalone file.&lt;br&gt;&lt;br&gt;I know that this thread is quite old, hoever I was wondering if anyone here could find a solution to this problem or can point me to some other sources.&lt;br&gt;You can contact me directly using the email below.&lt;br&gt;&lt;br&gt;Thanks in advance,&lt;br&gt;Uriel Mondrowicz.&lt;br&gt;urielmon@hotmail.com</description></item><item><title>re: How to make an application as both GUI and Console application?</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#187876</link><pubDate>Tue, 20 Jul 2004 17:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:187876</guid><dc:creator>Junfeng Zhang</dc:creator><description>This is an OS issue and there is probably nothing you can do about it.</description></item><item><title> Junfeng Zhang s Windows Programming Notes How to make an application | Cast Iron Cookware</title><link>http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx#9728820</link><pubDate>Fri, 12 Jun 2009 05:28:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9728820</guid><dc:creator> Junfeng Zhang s Windows Programming Notes How to make an application | Cast Iron Cookware</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://castironbakeware.info/story.php?title=junfeng-zhang-s-windows-programming-notes-how-to-make-an-application"&gt;http://castironbakeware.info/story.php?title=junfeng-zhang-s-windows-programming-notes-how-to-make-an-application&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>