home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK10 / MFC / SRC / WINMAIN.CP$ / winmain
Encoding:
Text File  |  1992-03-07  |  1.8 KB  |  75 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 documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "afxwin.h"
  12. #pragma hdrstop
  13.  
  14. #ifdef AFX_CORE_SEG
  15. #pragma code_seg(AFX_CORE_SEG)
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // Standard WinMain implementation
  20. //  Can be replaced as long as 'AfxWinInit' is called first
  21.  
  22. #ifndef _WINDLL
  23. extern "C"
  24. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  25.     LPSTR lpCmdLine, int nCmdShow)
  26. {
  27.     int nReturnCode = -1;
  28.  
  29.     // AFX internal initialization
  30.     if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
  31.         goto InitFailure;
  32.  
  33.     // App global initializations (rare)
  34.     if (hPrevInstance == NULL && !AfxGetApp()->InitApplication())
  35.         goto InitFailure;
  36.  
  37.     // Perform specific initializations
  38.     if (!AfxGetApp()->InitInstance())
  39.         goto InitFailure;
  40.  
  41.     nReturnCode = AfxGetApp()->Run();
  42.  
  43. InitFailure:
  44.     AfxWinTerm();
  45.     return nReturnCode;
  46. }
  47. #else
  48. // _WINDLL initialization
  49.  
  50. extern "C"
  51. int FAR PASCAL LibMain(HINSTANCE hInstance,
  52.     WORD wDataSegment, WORD wHeapSize, LPSTR lpszCmdLine)
  53. {
  54.     // Initialize DLL's instance(/module) not the app's
  55.     if (!AfxWinInit(hInstance, NULL, lpszCmdLine, 0))
  56.     {
  57.         AfxWinTerm();
  58.         return 0;       // Init Failed
  59.     }
  60.  
  61.     // initialize the single instance DLL
  62.     if (!AfxGetApp()->InitInstance())
  63.     {
  64.         AfxWinTerm();
  65.         return 0;
  66.     }
  67.  
  68.     // nothing to run
  69.     return 1;   // ok
  70. }
  71.  
  72. #endif //_WINDLL
  73.  
  74. /////////////////////////////////////////////////////////////////////////////
  75.