xref: /trunk/main/embedserv/source/embed/esdll.cxx (revision 79aad27f)
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 #define STRICT
25 #define _WIN32_WINNT 0x0400
26 #define _WIN32_DCOM
27 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
28 #undef _DEBUG
29 #endif
30 #if defined(_MSC_VER) && (_MSC_VER > 1310)
31 #pragma warning(disable : 4917 4555)
32 #endif
33 
34 #ifdef __MINGW32__
35 #define _INIT_ATL_COMMON_VARS
36 #endif
37 
38 #include "stdafx.h"
39 
40 #include <atlbase.h>
41 #ifdef _MSC_VER
42 #pragma warning( push )
43 #pragma warning( disable: 4710 )
44 #endif
45 CComModule _Module;
46 #ifdef _MSC_VER
47 #pragma warning( pop )
48 #endif
49 #include <atlcom.h>
50 
51 BEGIN_OBJECT_MAP(ObjectMap)
52 END_OBJECT_MAP()
53 
54 /////////////////////////////////////////////////////////////////////////////
55 // DLL Entry Point
56 
57 
58 #include "syswinwrapper.hxx"
59 #include "docholder.hxx"
60 
61 
62 HINSTANCE DocumentHolder::m_hInstance;
63 
64 extern "C"
DllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID)65 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
66 {
67     DocumentHolder::m_hInstance = hInstance;
68     if (!winwrap::HatchWindowRegister(hInstance))
69         return FALSE;
70 
71     if (dwReason == DLL_PROCESS_ATTACH)
72     {
73         _Module.Init(ObjectMap, hInstance, NULL);
74         DisableThreadLibraryCalls(hInstance);
75     }
76     else if (dwReason == DLL_PROCESS_DETACH)
77     {
78         _Module.Term();
79     }
80     return TRUE;    // ok
81 }
82 
83 // Fix strange warnings about some
84 // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
85 // warning C4505: 'xxx' : unreferenced local function has been removed
86 #if defined(_MSC_VER)
87 #pragma warning(disable: 4505)
88 #endif