|
|
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
7: // QuickHelp documentation provided with the library.
8: // See these sources for detailed information regarding the
9: // Microsoft Foundation Classes product.
10:
11:
12: #include "bibref.h"
13: #include "mainwnd.h"
14: #include "bibsvr.h"
15:
16: /////////////////////////////////////////////////////////////////////////////
17: // One instance of this server application per client
18:
19: CBibApp app;
20: static CBibServer server;
21:
22: BOOL CBibApp::InitInstance()
23: {
24: BOOL bEmbedded = FALSE;
25:
26: // check if run with /Embedding
27: LPCSTR lpsz = m_lpCmdLine;
28: while (*lpsz == ' ')
29: lpsz++;
30: if ((*lpsz == '-' || *lpsz == '/') &&
31: _fstrncmp("Embedding", lpsz+1, 9) == 0)
32: {
33: lpsz += 10;
34: bEmbedded = TRUE;
35: server.SetLaunchEmbedded();
36: }
37: // BibRef ignores rest of command line - normally use this as a
38: // document file name
39:
40: // BibRef data file
41: strIniFile = CString(m_pszAppName) + ".ini";
42: // NOTE: ini file contains settings as well as data
43:
44: CMainWnd* pWnd = new CMainWnd(bEmbedded);
45: m_pMainWnd = pWnd;
46: pWnd->ShowWindow(m_nCmdShow);
47: pWnd->UpdateWindow();
48:
49: if (!bEmbedded)
50: {
51: AfxOleRegisterServerName(SERVER_NAME, SERVER_LOCAL_NAME);
52: }
53:
54: if (!server.Register(SERVER_NAME, TRUE)) // multi-instance server
55: {
56: MessageBox(NULL, "Could not register server - Exiting",
57: SERVER_NAME, MB_OK);
58: return FALSE;
59: }
60:
61: return TRUE;
62: }
63:
64: void CBibApp::ShutDown()
65: {
66: if (server.IsOpen())
67: server.BeginRevoke(); // revoke the server, OLE will terminate the app
68: else
69: ::PostQuitMessage(0);
70: }
71:
72: int CBibApp::ExitInstance()
73: {
74: if (m_pMainWnd != NULL)
75: m_pMainWnd->DestroyWindow();
76: return CWinApp::ExitInstance();
77: }
78:
79: /////////////////////////////////////////////////////////////////////////////
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.