不要告诉我从什么winmain之类的主函数开始这类话。DOS下输入程序名运行C程序时,好像是先运行一段编译器加的汇编代码(启动代码?),为我们的main之类的函数的运行做好准备工作,然后才跳到main运行。那么我们双击Windows程序图标之后发生了什么呢?
解决方案 »
- C++自定义namespace库
- MFC]怎么把一个对话框的Edit控件参数传递到另一个对话框中
- 怎么删除掉正在运行的程序?
- 我为树形控件加了检查框风格,我单击这个检查框的时候,会引发哪个消息?
- 在directshow中如何做一个可以提供一个有序流的render fitler,一有新数据来就让外面取走
- 今天我们院子里一个MM家的电脑坏了,不能上网了.我给她修好了.她妈妈夸我....
- 如何在OnDraw函数中调用自定义函数void showplate(CDC *pDC) ?
- 谁能告诉我昨天那个关于MPEG4压缩传输的帖子说的下载网址!!100分!
- 各种程序中的向导功能是怎么做出来的?
- 怎样判断一个对话框窗口是否已经创建好了?? ^*(- -)*^
- 请详解调试信息
- 谁能给我点XML读写的代码让我参考一下。
ZwCreateSection //创建文件的内存映象,生成一个内核对象
ZwCreateProcess //创建一个进程
ZwCreateThread //创建进程的主线程你的程序在main或者WinMain之前做的事这样查看:
在你的App类的构造函数或者main函数中设置断点,然后看call stack,找到WinMainCRTStartup函数,设置断点,重新运行程序,跟踪查看。
Carapee(山豆根) 说的是对的,看看<<MFC深入浅出>>或许你会更加清楚!
值得收藏。
int mainret;
OSVERSIONINFOA *posvi;
int managedapp;
#ifdef _WINMAIN_
_TUCHAR *lpszCommandLine;
STARTUPINFO StartupInfo;
#endif /* _WINMAIN_ */
/*
* Dynamically allocate the OSVERSIONINFOA buffer, so we avoid
* triggering the /GS buffer overrun detection. That can't be
* used here, since the guard cookie isn't available until we
* initialize it from here!
*/
posvi = (OSVERSIONINFOA *)_alloca(sizeof(OSVERSIONINFOA)); /*
* Get the full Win32 version
*/
posvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
(void)GetVersionExA(posvi); _osplatform = posvi->dwPlatformId;
_winmajor = posvi->dwMajorVersion;
_winminor = posvi->dwMinorVersion; /*
* The somewhat bizarre calculations of _osver and _winver are
* required for backward compatibility (used to use GetVersion)
*/
_osver = (posvi->dwBuildNumber) & 0x07fff;
if ( _osplatform != VER_PLATFORM_WIN32_NT )
_osver |= 0x08000;
_winver = (_winmajor << 8) + _winminor; /*
* Determine if this is a managed application
*/
managedapp = check_managed_app();#ifdef _MT
if ( !_heap_init(1) ) /* initialize heap */
#else /* _MT */
if ( !_heap_init(0) ) /* initialize heap */
#endif /* _MT */
fast_error_exit(_RT_HEAPINIT); /* write message and die */#ifdef _MT
if( !_mtinit() ) /* initialize multi-thread */
fast_error_exit(_RT_THREAD); /* write message and die */
#endif /* _MT */ /*
* Initialize the Runtime Checks stuff
*/
#ifdef _RTC
_RTC_Initialize();
#endif /* _RTC */
/*
* Guard the remainder of the initialization code and the call
* to user's main, or WinMain, function in a __try/__except
* statement.
*/ __try { if ( _ioinit() < 0 ) /* initialize lowio */
_amsg_exit(_RT_LOWIOINIT);#ifdef WPRFLAG
/* get wide cmd line info */
_wcmdln = (wchar_t *)__crtGetCommandLineW(); /* get wide environ info */
_wenvptr = (wchar_t *)__crtGetEnvironmentStringsW(); if ( _wsetargv() < 0 )
_amsg_exit(_RT_SPACEARG);
if ( _wsetenvp() < 0 )
_amsg_exit(_RT_SPACEENV);
#else /* WPRFLAG */
/* get cmd line info */
_acmdln = (char *)GetCommandLineA(); /* get environ info */
_aenvptr = (char *)__crtGetEnvironmentStringsA(); if ( _setargv() < 0 )
_amsg_exit(_RT_SPACEARG);
if ( _setenvp() < 0 )
_amsg_exit(_RT_SPACEENV);
#endif /* WPRFLAG */ initret = _cinit(TRUE); /* do C data initialize */
if (initret != 0)
_amsg_exit(initret);#ifdef _WINMAIN_ StartupInfo.dwFlags = 0;
GetStartupInfo( &StartupInfo );#ifdef WPRFLAG
lpszCommandLine = _wwincmdln();
mainret = wWinMain(
#else /* WPRFLAG */
lpszCommandLine = _wincmdln();
mainret = WinMain(
#endif /* WPRFLAG */
GetModuleHandleA(NULL),
NULL,
lpszCommandLine,
StartupInfo.dwFlags & STARTF_USESHOWWINDOW
? StartupInfo.wShowWindow
: SW_SHOWDEFAULT
);
#else /* _WINMAIN_ */#ifdef WPRFLAG
__winitenv = _wenviron;
mainret = wmain(__argc, __wargv, _wenviron);
#else /* WPRFLAG */
__initenv = _environ;
mainret = main(__argc, __argv, _environ);
#endif /* WPRFLAG */#endif /* _WINMAIN_ */ if ( !managedapp )
exit(mainret); _cexit(); }
__except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
{
/*
* Should never reach here
*/ mainret = GetExceptionCode(); if ( !managedapp )
_exit(mainret); _c_exit(); } /* end of try - except */ return mainret;
这个函数名字叫WinMainCRTStartup不信你可以自己反汇编看看是不是这样的。