xref: /AOO41X/main/extensions/test/ole/AxTestComponents/AxTestComponents.cpp (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 // Note: Proxy/Stub Information
30 //      To build a separate proxy/stub DLL,
31 //      run nmake -f AxTestComponentsps.mk in the project directory.
32 
33 #include "stdafx.h"
34 #include "resource.h"
35 #include <initguid.h>
36 //#include "AxTestComponents.h"
37 
38 //#include "AxTestComponents_i.c"
39 #include "Basic.h"
40 #include "Foo.h"
41 
42 
43 CComModule _Module;
44 
45 BEGIN_OBJECT_MAP(ObjectMap)
46 OBJECT_ENTRY(CLSID_Basic, CBasic)
47 OBJECT_ENTRY(CLSID_Foo, CFoo)
48 END_OBJECT_MAP()
49 
50 /////////////////////////////////////////////////////////////////////////////
51 // DLL Entry Point
52 
53 extern "C"
54 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
55 {
56     if (dwReason == DLL_PROCESS_ATTACH)
57     {
58         _Module.Init(ObjectMap, hInstance, &LIBID_AXTESTCOMPONENTSLib);
59         DisableThreadLibraryCalls(hInstance);
60     }
61     else if (dwReason == DLL_PROCESS_DETACH)
62         _Module.Term();
63     return TRUE;    // ok
64 }
65 
66 /////////////////////////////////////////////////////////////////////////////
67 // Used to determine whether the DLL can be unloaded by OLE
68 
69 STDAPI DllCanUnloadNow(void)
70 {
71     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
72 }
73 
74 /////////////////////////////////////////////////////////////////////////////
75 // Returns a class factory to create an object of the requested type
76 
77 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
78 {
79     return _Module.GetClassObject(rclsid, riid, ppv);
80 }
81 
82 /////////////////////////////////////////////////////////////////////////////
83 // DllRegisterServer - Adds entries to the system registry
84 
85 STDAPI DllRegisterServer(void)
86 {
87     // registers object, typelib and all interfaces in typelib
88     return _Module.RegisterServer(TRUE);
89 }
90 
91 /////////////////////////////////////////////////////////////////////////////
92 // DllUnregisterServer - Removes entries from the system registry
93 
94 STDAPI DllUnregisterServer(void)
95 {
96     return _Module.UnregisterServer(TRUE);
97 }
98 
99 
100 //VT_I4 size_t V_ERROR VARIANT VARIANT_FALSE CComVariant FADF_EMBEDDED