what is the difference between win32 application, windows form application and console application?

sara picture sara · Dec 15, 2013 · Viewed 14.6k times · Source

I want to know what is the difference between windows form application, win32application ana console, i know that both the windows form application and win32 application is gui tool, but i want to know when to use one over the other one, and could I convert console application to windows form application ?

Answer

Cheers and hth. - Alf picture Cheers and hth. - Alf · Dec 15, 2013

Windows Form refers to a .NET application. It's not based directly on the native Windows API, but instead on the .NET infrastructure. Which includes a virtual machine.

Win32 generally refers to the 32-bit Windows API. However, the _WIN32 macro is defined for both 32-bit and 64-bit programming. As a Visual Studio project type it includes both GUI and console subsystem API-level programs.

A Windows subsystem is a small integer value in the executable's header that tells Windows what kind of services this program needs. This value can be inspected via e.g. Microsoft's dumpbin program, e.g. dumpbin c:\windows\notepad.exe /headers | find "ubs". In Windows 9x the dumpbin output was available via the file preview functionality, but that feature was discontinued.

Each process in Windows can be associated with one, and at most one, console window.

GUI subsystem means that Windows will NOT attempt to outfit each instance with an associated console window. The process can however create a console window itself. Usually this subsystem is used for ordinary programs with a graphical user interface (hence, "GUI"), and with most linkers it's specified as "windows".

Console subsystem means that Windows will attempt to outfit each instance with an associated console window, creating a new one if necessary.

Note that

  • The same source code can be built as console or GUI subsystem. And that's extremely easy to do. Just change the subsystem specification.

  • A GUI subsystem executable has standard streams, just as a console subsystem executable has.

  • A console subsystem executable can present a graphical user interface, just as a GUI one can.

Also note that

  • Microsoft's tools will by default not accept a standard C++ main for a GUI subsystem build. However, this non-conforming behavior is easy to fix. Just specify /entry:mainCRTStartup in the linker options.

There is no such problem with the GNU tools, that is, g++.