Essential Difference between CONSOLE and GUI Applications | CodeGuru

Essential Difference between CONSOLE and GUI Applications

Click here for larger image Environment: VC6 Win2K/NT/98 This sample describes the difference between CONSOLE and GUI applications with 20 lines of code. There are 2 small projects in this sample. The first project shows how to create a console in WinMain(). First of all, we need to allocate a console with AllocConsole(); secondly, we […]

Written By
CodeGuru Staff
CodeGuru Staff
Sep 17, 2001
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More





Click here for larger image

Environment: VC6 Win2K/NT/98

This sample describes the difference between CONSOLE and GUI applications with 20 lines of code.

There are 2 small projects in this sample. The first project shows how to create a console in WinMain(). First of all, we need to allocate a console with AllocConsole(); secondly, we in turn retrieve the operating system handle (GetStdHandle), run-time handle (_open_osfhandle), stream (_fdopen) and standard stream (stdout); finally, we can call functions like printf() and scanf().

The second project demonstrates how to create a window in main(). I created an edit box in a separate thread, so that you can control this window from the console. I retrieved the module handle through GetModuleHandle(), and then I called CreateWindow with the predefined class name EDIT.

As you can see, there is not much essential difference between console and GUI applications, even though VC requires us to indicate the type of the application when you create a project.

Downloads

Download demo project – 27 Kb

Download source – 4 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.