Search code examples
cmdwindows-console

What is the difference between win32 console and command prompt?


I am reading about console applications and I don't know how command prompt and win32 console are connected. Are they the same thing?


Solution

  • Your computer has many console mode programs. It has only one Cmd.exe. Which is the command interpreter, it displays a prompt and let you type commands to start other programs.

    You ought to play with Dumpbin.exe, included with Visual Studio. Use its /headers option to look at the header of an executable file. Such a file indicates what sub-system it wants to run on. There are three common ones you can encounter:

    • 1, displayed as "Native". Targets the native Windows operating system, used by device drivers for example, the ones you find in c:\windows\system32\drivers. The native OS resembles VMS, the operating system that Dave Cutler and his team created when they worked for DEC. It is only partially documented, just the parts that you need to write a driver.
    • 2, displayed as "Windows GUI". A Win32 process that creates its own windows with CreateWindow(). Like Notepad.exe
    • 3, displayed as "Windows CUI". A Win32 process that needs a console window, the OS automatically creates it before starting the program. Like Cmd.exe

    Windows used to have more sub-systems, like OS/2 and Posix, but they fell out of use. Win32 won by a land-slide. The distinction between the native OS and the api layer is also the core way Microsoft innovates on the OS, the Win32 api is frozen in stone and can never be changed, only added to. They can change the native OS as they see fit. Vista was the last one with very drastic changes, major version 6. Windows 2000 was the previous one, major version 5.