3

Possible Duplicates:
“APIENTRY _tWinMain” and “WINAPI WinMain” difference
What functions does _WinMainCRTStartup perform?

I just started to dive into windows programming. And when I tried to understand the win 32 program I noticed that the program has two entry points which are _tmainCRTStartup and _WinMainCRTStartup. Besides, I found the _tmainCRTStartup function also called _WinMain function. I just wonder what are they used for? And why there are two different entry points.

Thanks!

Community
  • 1
  • 1
xiao 啸
  • 6,350
  • 9
  • 40
  • 51
  • possible duplicate of ["APIENTRY _tWinMain" and "WINAPI WinMain" difference](http://stackoverflow.com/questions/4681443/apientry-twinmain-and-winapi-winmain-difference), [What functions does _WinMainCRTStartup perform?](http://stackoverflow.com/questions/1583193/what-functions-does-winmaincrtstartup-perform), [How can I write a Windows application without using WinMain?](http://stackoverflow.com/questions/564576/how-can-i-write-a-windows-application-without-using-winmain) – Cody Gray - on strike Jul 26 '11 at 09:04
  • There's an entry point for the CRT, which does some initialization tasks, and then hands off control to the entry point for your app (`WinMain`, `_tWinMain`, etc.). You can change the default entry point, but usually you want the convenience of the initialization the CRT entry point does for you automatically. – Cody Gray - on strike Jul 26 '11 at 09:06
  • Off-topic, but why bother learning C++ Win32 in 2011?? – Joris Mans Jul 26 '11 at 09:07
  • 4
    @JorisMans: Because it's still *the only way to write native Windows applications*. The Win32 API is the foundation for Windows itself, and it's written entirely in C (not C++). Programmers nowadays, however, find it convenient to work in C++ rather than C. But they still target the C-based Win32 API because there really is no alternative. That strikes me as kind of an ignorant comment. Java and Ruby are not suitable for every application. – Cody Gray - on strike Jul 26 '11 at 09:08
  • 1
    @Joris Mans, because we need to maintain legacy software :) – xiao 啸 Jul 26 '11 at 09:13
  • 2
    The Win32 API is **not** legacy. Please don't promote that misconception, even in jest... – Cody Gray - on strike Jul 26 '11 at 10:00
  • It is cleraly NOT a duplicate. Neither of the links has `tmainCRTStartup` _anywhere_. Only `WinMain` variants are asked and answered about, but `__tmainCRTStartup` (and `_mainCRTStartup`) are not covered. – Eugene Ryabtsev Apr 16 '14 at 08:57

0 Answers0