appmodul.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include "stdafx.h"
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // export WinMain to force linkage to this module
  17. extern int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  18. LPTSTR lpCmdLine, int nCmdShow);
  19. extern "C" int WINAPI
  20. _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  21. LPTSTR lpCmdLine, int nCmdShow)
  22. {
  23. // call shared/exported WinMain
  24. return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
  25. }
  26. /////////////////////////////////////////////////////////////////////////////
  27. // initialize app state such that it points to this module's core state
  28. BOOL AFXAPI AfxInitialize(BOOL bDLL, DWORD dwVersion)
  29. {
  30. AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
  31. pModuleState->m_bDLL = (BYTE)bDLL;
  32. ASSERT(dwVersion <= _MFC_VER);
  33. UNUSED(dwVersion); // not used in release build
  34. #ifdef _AFXDLL
  35. pModuleState->m_dwVersion = dwVersion;
  36. #endif
  37. #ifdef _MBCS
  38. // set correct multi-byte code-page for Win32 apps
  39. if (!bDLL)
  40. _setmbcp(_MB_CP_ANSI);
  41. #endif //_MBCS
  42. return TRUE;
  43. }
  44. // force initialization early
  45. #pragma warning(disable: 4074)
  46. #pragma init_seg(lib)
  47. #ifndef _AFXDLL
  48. void AFX_CDECL _AfxTermAppState()
  49. {
  50. // terminate local data and critical sections
  51. AfxTermLocalData(NULL, TRUE);
  52. AfxCriticalTerm();
  53. // release the reference to thread local storage data
  54. AfxTlsRelease();
  55. }
  56. #endif
  57. #ifdef __BORLANDC__
  58. char _afxInitAppState = (char)(AfxInitialize(FALSE, _MFC_VER));
  59. #ifndef _AFXDLL
  60. void _borland_exit(void)
  61. {
  62. #pragma exit _borland_exit 10 // correct shut down priority for Borland version
  63. _AfxTermAppState();
  64. }
  65. #endif
  66. #else // __BORLANDC__
  67. #ifndef _AFXDLL
  68. char _afxInitAppState = (char)(AfxInitialize(FALSE, _MFC_VER), atexit(&_AfxTermAppState));
  69. #else
  70. char _afxInitAppState = (char)(AfxInitialize(FALSE, _MFC_VER));
  71. #endif
  72. #endif // __BORLANDC__
  73. /////////////////////////////////////////////////////////////////////////////