]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/DLLX/DLLX.cpp
mDNSResponder-212.1.tar.gz
[apple/mdnsresponder.git] / mDNSWindows / DLLX / DLLX.cpp
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2009 Apple Computer, Inc. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16
17 Change History (most recent first):
18
19 $Log: DLLX.cpp,v $
20 Revision 1.1 2009/05/26 04:43:54 herscher
21 <rdar://problem/3948252> COM component that can be used with any .NET language and VB.
22
23
24 */
25
26
27 #include "stdafx.h"
28 #include "resource.h"
29 #include "DLLX.h"
30 #include "dlldatax.h"
31 #include <DebugServices.h>
32
33
34 class CDLLComponentModule : public CAtlDllModuleT< CDLLComponentModule >
35 {
36 public :
37 DECLARE_LIBID(LIBID_Bonjour)
38 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_DLLX, "{56608F9C-223B-4CB6-813D-85EDCCADFB4B}")
39 };
40
41 CDLLComponentModule _AtlModule;
42
43
44 #ifdef _MANAGED
45 #pragma managed(push, off)
46 #endif
47
48 // DLL Entry Point
49 extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
50 {
51 debug_initialize( kDebugOutputTypeWindowsDebugger );
52 debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelVerbose );
53
54 #ifdef _MERGE_PROXYSTUB
55 if (!PrxDllMain(hInstance, dwReason, lpReserved))
56 return FALSE;
57 #endif
58 hInstance;
59 return _AtlModule.DllMain(dwReason, lpReserved);
60 }
61
62 #ifdef _MANAGED
63 #pragma managed(pop)
64 #endif
65
66
67
68
69 // Used to determine whether the DLL can be unloaded by OLE
70 STDAPI DllCanUnloadNow(void)
71 {
72 #ifdef _MERGE_PROXYSTUB
73 HRESULT hr = PrxDllCanUnloadNow();
74 if (hr != S_OK)
75 return hr;
76 #endif
77 return _AtlModule.DllCanUnloadNow();
78 }
79
80
81 // Returns a class factory to create an object of the requested type
82 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
83 {
84 #ifdef _MERGE_PROXYSTUB
85 if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
86 return S_OK;
87 #endif
88 return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
89 }
90
91
92 // DllRegisterServer - Adds entries to the system registry
93 STDAPI DllRegisterServer(void)
94 {
95 // registers object, typelib and all interfaces in typelib
96 HRESULT hr = _AtlModule.DllRegisterServer();
97 #ifdef _MERGE_PROXYSTUB
98 if (FAILED(hr))
99 return hr;
100 hr = PrxDllRegisterServer();
101 #endif
102 return hr;
103 }
104
105
106 // DllUnregisterServer - Removes entries from the system registry
107 STDAPI DllUnregisterServer(void)
108 {
109 HRESULT hr = _AtlModule.DllUnregisterServer();
110 #ifdef _MERGE_PROXYSTUB
111 if (FAILED(hr))
112 return hr;
113 hr = PrxDllRegisterServer();
114 if (FAILED(hr))
115 return hr;
116 hr = PrxDllUnregisterServer();
117 #endif
118 return hr;
119 }
120