Click here to Skip to main content
15,908,618 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I had a MFC Application, I want to integrated a code to This App. But It not true worked. When I writing the code on the Other MFC Application (A App I'm create to Testing this code). It worked !!!!! I think when start up Solution, The my 1st App is defind some header, or lib or something. Maybe It makes the program does not work properly.!
Thank and best Regards !

In Other C/C++ Project, The Function to start alway is void main(), or int main();
But in MFC, there don't having the main Function !!!!

I think the "virtual BOOL InitInstance();" in the MySolustionName.cpp
This Function's calling the Start form ?
Posted
Updated 21-Nov-13 15:52pm
v3

1 solution

This is called "entry point": http://en.wikipedia.org/wiki/Entry_point[^].

In Windows, the conventional entry point is WinMain: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633559%28v=vs.85%29.aspx[^].

In an MFC application, the entry point is hidden in the library, reportedly, in the file "Appmodule.cpp". Actually, the entry point name is defined as _tWinMain, which is a generic name for Unicode ("wide" wWinMain) and non-Unicode (WinMain) entry-point names, a way to abstract out from Unicode option.

This CodeProject article explains how it works with MFC: MFC under the hood[^].

See the section "So, what happened to good old WinMain?"… :-)

[EDIT]

Now, some advanced background information:

We can see that different platforms based on PE files (http://en.wikipedia.org/wiki/Portable_Executable[^]) use different names for entry-point functions, and also, for different Windows-based platforms and/or frameworks, one entry point function calls another "secondary" entry function which is the only one exposed to the framework user. We can investigate it all, but does it make much sense? Ultimately, even the very top function on the call stack, "real" entry point, does not have to have a certain standard name. This is so because that "real" entry point is found not by the name, but by the address in the header structure used for this purpose. Please see:
http://en.wikibooks.org/wiki/X86_Disassembly/Windows_Executable_Files#PE_Optional_Header[^].

—SA
 
Share this answer
 
v5
Comments
Mạnh Lê 21-Nov-13 22:24pm    
Thank. !
I have to view this !
Sergey Alexandrovich Kryukov 21-Nov-13 22:25pm    
I added more background information, after [EDIT].
Will you accept my answer formally now (green "Accept" button)?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900