blob: 636f2c8ad9b2f49cdd906a8475b5fac035fa697b (
plain)
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
|
//+---------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1992-2001.
//
// File: DLLMAIN . C P P
//
// Contents: Main entry points into the DLL
//
// Notes:
//
//----------------------------------------------------------------------------
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
#include <atlbase.h>
extern CComModule _Module; // required by atlcom.h
#include <atlcom.h>
#include <devguid.h>
#include "notify.h"
#include "notifyn_i.c"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_CMuxNotify, CMuxNotify)
END_OBJECT_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain (HINSTANCE hInstance,
DWORD dwReason,
LPVOID /*lpReserved*/)
{
TraceMsg( L"-->DllMain.\n");
if (dwReason == DLL_PROCESS_ATTACH) {
TraceMsg( L" Reason: Attach.\n");
_Module.Init(ObjectMap, hInstance);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH) {
TraceMsg( L" Reason: Detach.\n");
_Module.Term();
}
TraceMsg( L"<--DllMain.\n");
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
__control_entrypoint(DllExport)
STDAPI DllCanUnloadNow(void)
{
HRESULT hr;
TraceMsg( L"-->DllCanUnloadNow.\n");
hr = (_Module.GetLockCount() == 0) ? S_OK : S_FALSE;
TraceMsg( L"-->DllCanUnloadNow(HRESULT = %x).\n",
hr );
return hr;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
_Check_return_
STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
{
TraceMsg( L"-->DllGetClassObject.\n");
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// Registers object, typelib and all interfaces in typelib
TraceMsg( L"-->DllRegisterServer.\n");
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
TraceMsg( L"-->DllUnregisterServer.\n");
_Module.UnregisterServer();
return S_OK;
}
|