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 
24 // so_activex.cpp : Implementation of DLL Exports.
25 
26 
27 // Note: Proxy/Stub Information
28 //      To build a separate proxy/stub DLL,
29 //      run nmake -f so_activexps.mk in the project directory.
30 
31 #include "stdafx2.h"
32 #include "resource.h"
33 #include <initguid.h>
34 #include "so_activex.h"
35 
36 #include "so_activex_i.c"
37 #include "SOActiveX.h"
38 
39 
40 CComModule _Module;
41 
42 BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_SOActiveX,CSOActiveX)43 OBJECT_ENTRY(CLSID_SOActiveX, CSOActiveX)
44 END_OBJECT_MAP()
45 
46 /////////////////////////////////////////////////////////////////////////////
47 // DLL Entry Point
48 
49 extern "C"
50 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
51 {
52     if (dwReason == DLL_PROCESS_ATTACH)
53     {
54         _Module.Init(ObjectMap, hInstance, &LIBID_SO_ACTIVEXLib);
55         DisableThreadLibraryCalls(hInstance);
56     }
57     else if (dwReason == DLL_PROCESS_DETACH)
58         _Module.Term();
59     return TRUE;    // ok
60 }
61 
62 /////////////////////////////////////////////////////////////////////////////
63 // Used to determine whether the DLL can be unloaded by OLE
64 
DllCanUnloadNow(void)65 STDAPI DllCanUnloadNow(void)
66 {
67     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
68 }
69 
70 /////////////////////////////////////////////////////////////////////////////
71 // Returns a class factory to create an object of the requested type
72 
DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID * ppv)73 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
74 {
75     return _Module.GetClassObject(rclsid, riid, ppv);
76 }
77 
78 /////////////////////////////////////////////////////////////////////////////
79 // DllRegisterServer - Adds entries to the system registry
80 
DllRegisterServer(void)81 STDAPI DllRegisterServer(void)
82 {
83     HRESULT aResult = _Module.RegisterServer(TRUE);
84 
85 	return aResult;
86 }
87 
88 /////////////////////////////////////////////////////////////////////////////
89 // DllUnregisterServer - Removes entries from the system registry
90 
DllUnregisterServer(void)91 STDAPI DllUnregisterServer(void)
92 {
93     HRESULT aResult = _Module.UnregisterServer(TRUE);
94 
95 	return aResult;
96 }
97 
98