1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 // XCallback_Impl.cpp : Implementation of DLL Exports.
24 
25 
26 // Note: Proxy/Stub Information
27 //      To build a separate proxy/stub DLL,
28 //      run nmake -f XCallback_Implps.mk in the project directory.
29 
30 #include "stdafx.h"
31 #include "resource.h"
32 #include <initguid.h>
33 #include "XCallback_Impl.h"
34 
35 #include "XCallback_Impl_i.c"
36 #include "Callback.h"
37 #include "Simple.h"
38 
39 
40 CComModule _Module;
41 
42 BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_Callback,CCallback)43 OBJECT_ENTRY(CLSID_Callback, CCallback)
44 OBJECT_ENTRY(CLSID_Simple, CSimple)
45 END_OBJECT_MAP()
46 
47 /////////////////////////////////////////////////////////////////////////////
48 // DLL Entry Point
49 
50 extern "C"
51 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
52 {
53     if (dwReason == DLL_PROCESS_ATTACH)
54     {
55         _Module.Init(ObjectMap, hInstance, &LIBID_XCALLBACK_IMPLLib);
56         DisableThreadLibraryCalls(hInstance);
57     }
58     else if (dwReason == DLL_PROCESS_DETACH)
59         _Module.Term();
60     return TRUE;    // ok
61 }
62 
63 /////////////////////////////////////////////////////////////////////////////
64 // Used to determine whether the DLL can be unloaded by OLE
65 
DllCanUnloadNow(void)66 STDAPI DllCanUnloadNow(void)
67 {
68     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
69 }
70 
71 /////////////////////////////////////////////////////////////////////////////
72 // Returns a class factory to create an object of the requested type
73 
DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID * ppv)74 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
75 {
76     return _Module.GetClassObject(rclsid, riid, ppv);
77 }
78 
79 /////////////////////////////////////////////////////////////////////////////
80 // DllRegisterServer - Adds entries to the system registry
81 
DllRegisterServer(void)82 STDAPI DllRegisterServer(void)
83 {
84     // registers object, typelib and all interfaces in typelib
85     return _Module.RegisterServer(TRUE);
86 }
87 
88 /////////////////////////////////////////////////////////////////////////////
89 // DllUnregisterServer - Removes entries from the system registry
90 
DllUnregisterServer(void)91 STDAPI DllUnregisterServer(void)
92 {
93     return _Module.UnregisterServer(TRUE);
94 }
95 
96 
97 
98