How does MFC wWinMain work in an executable?

The MFC wWinMainis defined in appmodul.cpp. This file is embedded in mfc90ud.dll from what I see. However, when I launch my application, the call stack shows MyApplication.exe!wWinMain. How did it take a function wWinMainthat was exported to appmodul.objand put into my application?

+5
source share
3 answers

Right-click your project in the solution explorer window, properties, linker, command line. Type / verbose in the Advanced Options field. Rebuild your project. The Output window now displays the trace in which the linker found the symbol. Search for winmain to find this:

1>    Searching c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\lib\mfcs90ud.lib:
1>      Found _wWinMain@16
1>        Referenced in msvcrtd.lib(wcrtexew.obj)
1>        Loaded mfcs90ud.lib(appmodul.obj)

Note the name of the library, mfcs90ud.lib is a static link library. If you are looking for "mfcs90ud.lib", you can also see how this library got the link:

1>Starting pass 1
1>Processed /DEFAULTLIB:mfc90ud.lib
1>Processed /DEFAULTLIB:mfcs90ud.lib
1>Processed /DEFAULTLIB:msvcrtd.lib
etc..

If you are looking for the MFC source code for "mfcs", you will see how this / defaultlib option was entered. From afx.h:

            #ifdef _DEBUG
                    #pragma comment(lib, "mfc" _MFC_FILENAME_VER "ud.lib")
                    #pragma comment(lib, "mfcs" _MFC_FILENAME_VER "ud.lib")
            #else
                    #pragma comment(lib, "mfc" _MFC_FILENAME_VER "u.lib")
                    #pragma comment(lib, "mfcs" _MFC_FILENAME_VER "u.lib")
            #endif

, MFC . Mfc90u.lib - DLL- MFC. Mfcs90u.lib - , , . WinMain().

+10

. , . ..

+1

CWinApp:

  • ( ).
  • CWinApp:: CWinApp ( ).
  • , AfxGetApp() - !
  • wWinMain, CWinApp.

Try debugging from wWinMainor from your custom CWinApp-derived constructor .

+1
source

All Articles