File: visvile.cpp

package info (click to toggle)
vile 9.4-s1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 10,448 kB
  • ctags: 7,909
  • sloc: ansic: 85,708; lex: 7,137; sh: 2,992; perl: 2,926; cpp: 2,869; makefile: 750; awk: 271
file content (147 lines) | stat: -rw-r--r-- 3,749 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// VisVile.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include <initguid.h>
#include "VisVile.h"
#include "DSAddIn.h"
#include "Commands.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
	OBJECT_ENTRY(CLSID_DSAddIn, CDSAddIn)
END_OBJECT_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVisVileApp

class CVisVileApp : public CWinApp
{
public:
	CVisVileApp();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CVisVileApp)
	public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

	//{{AFX_MSG(CVisVileApp)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// CVisVileApp

BEGIN_MESSAGE_MAP(CVisVileApp, CWinApp)
	//{{AFX_MSG_MAP(CVisVileApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// The one and only CVisVileApp object

CVisVileApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CVisVileApp construction

CVisVileApp::CVisVileApp()
{
}

/////////////////////////////////////////////////////////////////////////////
// CVisVileApp initialization

BOOL CVisVileApp::InitInstance()
{
    _Module.Init(ObjectMap, m_hInstance);
    return CWinApp::InitInstance();
}

int CVisVileApp::ExitInstance()
{
    _Module.Term();
    return CWinApp::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////
// Special entry points required for inproc servers

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    return _Module.GetClassObject(rclsid, riid, ppv);
}

STDAPI DllCanUnloadNow(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}

// by exporting DllRegisterServer, you can use regsvr32.exe
STDAPI DllRegisterServer(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    HRESULT hRes = S_OK;
    
    // Registers object, typelib and all interfaces in typelib
    hRes = _Module.RegisterServer(TRUE);
    if (FAILED(hRes))
        return hRes;

    // Register description of this add-in object in its own
    //  "/Description" subkey.
    _ATL_OBJMAP_ENTRY* pEntry = _Module.m_pObjMap;
    CRegKey key;
    LONG lRes = key.Open(HKEY_CLASSES_ROOT, _T("CLSID"));
    if (lRes == ERROR_SUCCESS)
    {
        USES_CONVERSION;
        LPOLESTR lpOleStr;
        StringFromCLSID(*pEntry->pclsid, &lpOleStr);
        LPTSTR lpsz = OLE2T(lpOleStr);

        lRes = key.Open(key, lpsz);
        if (lRes == ERROR_SUCCESS)
        {
            CString strDescription;
            strDescription.LoadString(IDS_VISVILE_DESCRIPTION);
            key.SetKeyValue(_T("Description"), strDescription);
        }
        CoTaskMemFree(lpOleStr);
    }
    if (lRes != ERROR_SUCCESS)
        hRes = HRESULT_FROM_WIN32(lRes);

    return hRes;
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    HRESULT hRes = S_OK;
    _Module.UnregisterServer();
    return hRes;
}