Update ooo320-m1
[ooovba.git] / odk / examples / OLE / activex / so_activex.cpp
blob852e2e559bb3110fe873adf9251d825dfd4d229a
1 /*************************************************************************
3 * $RCSfile: so_activex.cpp,v $
5 * $Revision: 1.2 $
7 * last change: $Author: hr $ $Date: 2003-06-30 15:50:57 $
9 * The Contents of this file are made available subject to the terms of
10 * the BSD license.
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
41 // so_activex.cpp : Implementation of DLL Exports.
44 // Note: Proxy/Stub Information
45 // To build a separate proxy/stub DLL,
46 // run nmake -f so_activexps.mk in the project directory.
48 #include "stdafx2.h"
49 #include "resource.h"
50 #include <initguid.h>
51 #include "so_activex.h"
53 #include "so_activex_i.c"
54 #include "SOActiveX.h"
57 CComModule _Module;
59 BEGIN_OBJECT_MAP(ObjectMap)
60 OBJECT_ENTRY(CLSID_SOActiveX, CSOActiveX)
61 END_OBJECT_MAP()
63 /////////////////////////////////////////////////////////////////////////////
64 // DLL Entry Point
66 extern "C"
67 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
69 if (dwReason == DLL_PROCESS_ATTACH)
71 _Module.Init(ObjectMap, hInstance, &LIBID_SO_ACTIVEXLib);
72 DisableThreadLibraryCalls(hInstance);
74 else if (dwReason == DLL_PROCESS_DETACH)
75 _Module.Term();
76 return TRUE; // ok
79 /////////////////////////////////////////////////////////////////////////////
80 // Used to determine whether the DLL can be unloaded by OLE
82 STDAPI DllCanUnloadNow(void)
84 return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
87 /////////////////////////////////////////////////////////////////////////////
88 // Returns a class factory to create an object of the requested type
90 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
92 return _Module.GetClassObject(rclsid, riid, ppv);
95 /////////////////////////////////////////////////////////////////////////////
96 // DllRegisterServer - Adds entries to the system registry
98 STDAPI DllRegisterServer(void)
100 HRESULT aResult = _Module.RegisterServer(TRUE);
102 return aResult;
105 /////////////////////////////////////////////////////////////////////////////
106 // DllUnregisterServer - Removes entries from the system registry
108 STDAPI DllUnregisterServer(void)
110 HRESULT aResult = _Module.UnregisterServer(TRUE);
112 return aResult;