|
|
1.1 root 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
1.1.1.4 ! root 7: // QuickHelp and/or WinHelp documentation provided with the library.
1.1 root 8: // See these sources for detailed information regarding the
9: // Microsoft Foundation Classes product.
10:
1.1.1.4 ! root 11: #include "stdafx.h"
1.1 root 12:
1.1.1.4 ! root 13: #ifdef AFX_CORE1_SEG
! 14: #pragma code_seg(AFX_CORE1_SEG)
1.1 root 15: #endif
16:
17: /////////////////////////////////////////////////////////////////////////////
18: // Standard WinMain implementation
19: // Can be replaced as long as 'AfxWinInit' is called first
20:
1.1.1.4 ! root 21: #ifndef _USRDLL
1.1 root 22: extern "C"
23: int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
24: LPSTR lpCmdLine, int nCmdShow)
25: {
26: int nReturnCode = -1;
27:
28: // AFX internal initialization
29: if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
30: goto InitFailure;
31:
32: // App global initializations (rare)
33: if (hPrevInstance == NULL && !AfxGetApp()->InitApplication())
34: goto InitFailure;
35:
36: // Perform specific initializations
37: if (!AfxGetApp()->InitInstance())
38: goto InitFailure;
39:
1.1.1.4 ! root 40: ASSERT_VALID(AfxGetApp());
! 41:
1.1 root 42: nReturnCode = AfxGetApp()->Run();
43:
44: InitFailure:
45: AfxWinTerm();
46: return nReturnCode;
47: }
48:
1.1.1.4 ! root 49: #else
! 50: // _USRDLL library initialization
1.1.1.3 root 51: #include <process.h> // for _cexit()
52:
1.1.1.4 ! root 53: #ifdef CALL_DLL_CRT_INIT
1.1.1.2 root 54: extern "C" BOOL WINAPI
55: _CRT_INIT(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved);
1.1.1.4 ! root 56: #endif //CALL_DLL_CRT_INIT
! 57:
1.1.1.2 root 58: extern "C" int APIENTRY
1.1.1.4 ! root 59: DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
1.1.1.2 root 60: {
1.1.1.4 ! root 61: #ifdef CALL_DLL_CRT_INIT
1.1.1.3 root 62: if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
1.1.1.2 root 63: {
1.1.1.4 ! root 64: // Initialize the C/C++ runtime first
1.1.1.3 root 65: if (!_CRT_INIT(hInstance, dwReason, lpReserved))
1.1.1.4 ! root 66: return 0; // CRT init Failed
1.1.1.2 root 67: }
1.1.1.4 ! root 68: #endif //CALL_DLL_CRT_INIT
! 69:
1.1.1.3 root 70: if (dwReason == DLL_PROCESS_ATTACH)
71: {
72: // Initialize DLL's instance(/module) not the app's
73: if (!AfxWinInit(hInstance, NULL, "", 0))
74: {
75: AfxWinTerm();
76: return 0; // Init Failed
77: }
78:
79: // initialize the single instance DLL
80: if (!AfxGetApp()->InitInstance())
81: {
82: AfxWinTerm();
1.1.1.4 ! root 83: return 0; // Init Failed
1.1.1.3 root 84: }
85: }
86: else if (dwReason == DLL_PROCESS_DETACH)
1.1.1.2 root 87: {
1.1.1.3 root 88: // Terminate the library before destructors are called
1.1.1.2 root 89: AfxWinTerm();
1.1.1.4 ! root 90: }
1.1.1.3 root 91:
1.1.1.4 ! root 92: #ifdef CALL_DLL_CRT_INIT
1.1.1.3 root 93: if (dwReason == DLL_PROCESS_DETACH || dwReason == DLL_THREAD_DETACH)
1.1.1.2 root 94: {
1.1.1.3 root 95: // Terminate the C/C++ runtime last
96: if (!_CRT_INIT(hInstance, dwReason, lpReserved))
97: return 0; // CRT term Failed
1.1.1.2 root 98: }
1.1.1.4 ! root 99: #endif //CALL_DLL_CRT_INIT
1.1.1.2 root 100:
101: return 1; // ok
102: }
1.1.1.4 ! root 103: #endif //_USRDLL
1.1 root 104:
105: /////////////////////////////////////////////////////////////////////////////
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.