//WTL(ATL)中的全局变量
//文件:externs.cpp
CAtlAllocator g_Allocator;
static const bool g_bInitialized = Init();
//文件:atlbase.cpp
ATL::CAtlBaseModule _AtlBaseModule;
ATL::CAtlWinModule _AtlWinModule;
ATL::CAtlComModule _AtlComModule;
//文件:atlapp.h,DEBUG版本中才有
WTL::ATL::CTraceCategory atlTraceUI(_T("atlTraceUI"));
//你自己的应用程序入口文件,文件中包括WinMain()函数
CAppModule _Module;
//文件:atlbase.h
extern "C" IMAGE_DOS_HEADER __ImageBase;
extern CAtlComModule _AtlComModule;
extern CAtlWinModule _AtlWinModule;
__declspec(selectany) CComModule* _pModule = NULL;
//关键的构造函数,请注意成员变量:m_hInst及m_hInstResource,变量:__ImageBase
CAtlBaseModule::CAtlBaseModule() throw()
{
cbSize = sizeof(_ATL_BASE_MODULE);
m_hInst = m_hInstResource = reinterpret_cast<HINSTANCE>(&__ImageBase);
dwAtlBuildVer = _ATL_VER;
pguidVer = &GUID_ATLVer70;
if (FAILED(m_csResource.Init()))
{
ATLTRACE(atlTraceGeneral, 0, _T("ERROR : Unable to initialize critical section in CAtlBaseModule\n"));
ATLASSERT(0);
CAtlBaseModule::m_bInitFailed = true;
}
}
//文件:crt0.c
__declspec(noinline) int __tmainCRTStartup(void)
{
#ifdef _WINMAIN_
lpszCommandLine = _twincmdln();
mainret = _tWinMain( (HINSTANCE)&__ImageBase, NULL,lpszCommandLine,StartupInfo.dwFlags & STARTF_USESHOWWINDOW? StartupInfo.wShowWindow : SW_SHOWDEFAULT );
#else
_tinitenv = _tenviron;
mainret = _tmain(__argc, _targv, _tenviron);
#endif
}