winmain.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 AFX_CORE1_SEG
  12. #pragma code_seg(AFX_CORE1_SEG)
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // Standard WinMain implementation
  16. // Can be replaced as long as 'AfxWinInit' is called first
  17. int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  18. LPTSTR lpCmdLine, int nCmdShow)
  19. {
  20. ASSERT(hPrevInstance == NULL);
  21. int nReturnCode = -1;
  22. CWinThread* pThread = AfxGetThread();
  23. CWinApp* pApp = AfxGetApp();
  24. // AFX internal initialization
  25. if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
  26. goto InitFailure;
  27. // App global initializations (rare)
  28. if (pApp != NULL && !pApp->InitApplication())
  29. goto InitFailure;
  30. // Perform specific initializations
  31. if (!pThread->InitInstance())
  32. {
  33. if (pThread->m_pMainWnd != NULL)
  34. {
  35. TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
  36. pThread->m_pMainWnd->DestroyWindow();
  37. }
  38. nReturnCode = pThread->ExitInstance();
  39. goto InitFailure;
  40. }
  41. nReturnCode = pThread->Run();
  42. InitFailure:
  43. #ifdef _DEBUG
  44. // Check for missing AfxLockTempMap calls
  45. if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
  46. {
  47. TRACE1("Warning: Temp map lock count non-zero (%ld).\n",
  48. AfxGetModuleThreadState()->m_nTempMapLock);
  49. }
  50. AfxLockTempMaps();
  51. AfxUnlockTempMaps(-1);
  52. #endif
  53. AfxWinTerm();
  54. return nReturnCode;
  55. }
  56. /////////////////////////////////////////////////////////////////////////////