|
|
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: #include "minsvr.h"
12:
13: /////////////////////////////////////////////////////////////////////////////
14: // One instance per client
15:
16: CMinApp app;
17:
18: BOOL CMinApp::InitInstance()
19: {
20: BOOL bEmbedded = FALSE;
21:
22: // check if run with /Embedding
23: LPCSTR lpsz = m_lpCmdLine;
24:
25: while (*lpsz == ' ')
26: lpsz++;
27: if ((*lpsz == '-' || *lpsz == '/') &&
28: _fstrncmp("Embedding", lpsz+1, 9) == 0)
29: {
30: lpsz += 10;
31: bEmbedded = TRUE;
32: }
33:
34: if (!bEmbedded)
35: {
36: // register as a server
37: if (AfxOleRegisterServerName(SERVER_NAME, SERVER_LOCAL_NAME))
38: {
39: MessageBox(NULL,
40: "Server Registered, please run from within host application.",
41: AfxGetAppName(), MB_OK);
42: }
43: else
44: {
45: MessageBox(NULL,
46: "Server failed to register, try using REGEDIT.",
47: AfxGetAppName(), MB_OK);
48: }
49:
50: return FALSE;
51: }
52: // MinApp ignores rest of command line - normally use this as a
53: // document file name
54:
55: CMainWnd* pWnd = new CMainWnd;
56: m_pMainWnd = pWnd;
57: pWnd->ShowWindow(m_nCmdShow);
58: pWnd->UpdateWindow();
59:
60: if (!pWnd->m_server.Register(SERVER_NAME, TRUE))
61: // multi-instance server
62: {
63: MessageBox(NULL, "couldn't register server", AfxGetAppName(), MB_OK);
64: return FALSE;
65: }
66:
67: return TRUE;
68: }
69:
70: int CMinApp::ExitInstance()
71: {
72: // on exit, destroy the main window
73: if (m_pMainWnd != NULL)
74: VERIFY(m_pMainWnd->DestroyWindow());
75: return CWinApp::ExitInstance();
76: }
77:
78: /////////////////////////////////////////////////////////////////////////////
79: // Minimum server
80:
81: CMinServer::CMinServer(CMainWnd* pMainWnd)
82: : COleServer(TRUE), m_doc()
83: {
84: m_pMainWnd = pMainWnd;
85: }
86:
87: COleServerDoc* CMinServer::OnOpenDoc(LPCSTR)
88: {
89: return &m_doc;
90: }
91:
92: COleServerDoc* CMinServer::OnCreateDoc(LPCSTR, LPCSTR)
93: {
94: return &m_doc;
95: }
96:
97: COleServerDoc* CMinServer::OnEditDoc(LPCSTR, LPCSTR)
98: {
99: return &m_doc;
100: }
101:
102: /////////////////////////////////////////////////////////////////////////////
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.