What is my C # application running?

When developing a C # project in Visual Studio, I have three options for the output type. Console Application, Windows Application, and Class Library. AFAIK, the only difference between a DLL and an EXE is that the EXE must have a specific entry point and be called when the file is double-clicked. However, when you run an EXE created from a console application, a console window is created. So it is obvious that something is happening besides starting the CLR and then calling my Main method. What launches the console window? When I run an EXE created from a Windows application, is there some other code run also running, or is this just my main method?

+3


source to share


3 answers


Your portable executable (exe) will contain information about which application it has.

Subsystem

the IMAGE_OPTIONAL_HEADER flag determines which user interface the application is built with.



IMAGE_SUBSYSTEM_WINDOWS_CUI

defines a console application, IMAGE_SUBSYSTEM_WINDOWS_GUI

defines a Windows application, etc.

For more information Peering Inside PE: An Overview of the Portable Win32 Executable

+4


source


Output Type is a configuration setting for your project that tells Visual Studio what to do when compiling. If the Console Application is installed, it will generate an exe file with the code to launch the console window.



The difference between dll and exe is more than the main method. Visual Studio has generated additional codes in the exe file that creates the console and calls the main method. For more on how this exe file works, see http://en.wikipedia.org/wiki/Portable_Executable .

+2


source


In this link, the inquisitor added a few notes that mentioned a blog post (2nd link). Is it possible to create a console app that doesn't display the console window when double clicked?

http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx

The same content as Siram is answered by fooobar.com/questions/2221886 / ... , but to help you with future searches, these were the keywords Google used to find said resources. "double click the EXE launches the console"

+2


source







All Articles