Difference between WinMain,main and DllMain in C++

Ahmed Said picture Ahmed Said · Jan 6, 2009 · Viewed 15k times · Source

What is the difference between the three functions and when to use them??

Answer

Frederick The Fool picture Frederick The Fool · Jan 6, 2009

main() means your program is a console application.

WinMain() means the program is a GUI application -- that is, it displays windows and dialog boxes instead of showing console.

DllMain() means the program is a DLL. A DLL cannot be run directly but is used by the above two kinds of applications.

Therefore:

  • Use WinMain when you are writing a program that is going to display windows etc.
  • Use DLLMain when you write a DLL.
  • Use main in all other cases.