home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / appmodul.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  2KB  |  75 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // export WinMain to force linkage to this module
  20.  
  21. extern int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  22.     LPTSTR lpCmdLine, int nCmdShow);
  23.  
  24. extern "C" int WINAPI
  25. _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  26.     LPTSTR lpCmdLine, int nCmdShow)
  27. {
  28.     // call shared/exported WinMain
  29.     return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
  30. }
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // initialize app state such that it points to this module's core state
  34.  
  35. BOOL AFXAPI AfxInitialize(BOOL bDLL, DWORD dwVersion)
  36. {
  37.     AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
  38.     pModuleState->m_bDLL = (BYTE)bDLL;
  39.     ASSERT(dwVersion <= _MFC_VER);
  40.     UNUSED(dwVersion);  // not used in release build
  41. #ifdef _AFXDLL
  42.     pModuleState->m_dwVersion = dwVersion;
  43. #endif
  44. #ifdef _MBCS
  45.     // set correct multi-byte code-page for Win32 apps
  46.     if (!bDLL)
  47.         _setmbcp(_MB_CP_ANSI);
  48. #endif //_MBCS
  49.     return TRUE;
  50. }
  51.  
  52. // force initialization early
  53. #pragma warning(disable: 4074)
  54. #pragma init_seg(lib)
  55.  
  56. #ifndef _AFXDLL
  57. void AFX_CDECL _AfxTermAppState()
  58. {
  59.     // terminate local data and critical sections
  60.     AfxTermLocalData(NULL, TRUE);
  61.     AfxCriticalTerm();
  62.  
  63.     // release the reference to thread local storage data
  64.     AfxTlsRelease();
  65. }
  66. #endif
  67.  
  68. #ifndef _AFXDLL
  69. char _afxInitAppState = (char)(AfxInitialize(FALSE, _MFC_VER), atexit(&_AfxTermAppState));
  70. #else
  71. char _afxInitAppState = (char)(AfxInitialize(FALSE, _MFC_VER));
  72. #endif
  73.  
  74. /////////////////////////////////////////////////////////////////////////////
  75.