home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SRC / WINMAIN.CP_ / WINMAIN.CP
Encoding:
Text File  |  1993-02-08  |  1.9 KB  |  81 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 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 Microsoft
  7. // QuickHelp and/or WinHelp 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 AFX_CORE1_SEG
  14. #pragma code_seg(AFX_CORE1_SEG)
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // Standard WinMain implementation
  19. //  Can be replaced as long as 'AfxWinInit' is called first
  20.  
  21. #ifdef _AFXDLL
  22. #define WinMain AfxWinMain
  23. #endif
  24.  
  25. #ifndef _USRDLL
  26. extern "C"
  27. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  28.     LPSTR lpCmdLine, int nCmdShow)
  29. {
  30.     int nReturnCode = -1;
  31.  
  32.     // AFX internal initialization
  33.     if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
  34.         goto InitFailure;
  35.  
  36.     // App global initializations (rare)
  37.     if (hPrevInstance == NULL && !AfxGetApp()->InitApplication())
  38.         goto InitFailure;
  39.  
  40.     // Perform specific initializations
  41.     if (!AfxGetApp()->InitInstance())
  42.         goto InitFailure;
  43.  
  44.     ASSERT_VALID(AfxGetApp());
  45.  
  46.     nReturnCode = AfxGetApp()->Run();
  47.  
  48. InitFailure:
  49.     AfxWinTerm();
  50.     return nReturnCode;
  51. }
  52.  
  53. #else
  54. // _USRDLL library initialization
  55.  
  56. extern "C"
  57. int FAR PASCAL LibMain(HINSTANCE hInstance,
  58.     WORD wDataSegment, WORD wHeapSize, LPSTR lpszCmdLine)
  59. {
  60.     // Initialize DLL's instance(/module) not the app's
  61.     if (!AfxWinInit(hInstance, NULL, lpszCmdLine, 0))
  62.     {
  63.         AfxWinTerm();
  64.         return 0;       // Init Failed
  65.     }
  66.  
  67.     // initialize the single instance DLL
  68.     if (!AfxGetApp()->InitInstance())
  69.     {
  70.         AfxWinTerm();
  71.         return 0;
  72.     }
  73.  
  74.     // nothing to run
  75.     return 1;   // ok
  76. }
  77.  
  78. #endif //_USRDLL
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81.