--- /dev/null
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2009 Apple Computer, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+ Change History (most recent first):
+
+$Log: DLLX.cpp,v $
+Revision 1.1 2009/05/26 04:43:54 herscher
+<rdar://problem/3948252> COM component that can be used with any .NET language and VB.
+\r
+\r
+*/\r
+\r
+\r
+#include "stdafx.h"\r
+#include "resource.h"\r
+#include "DLLX.h"\r
+#include "dlldatax.h"\r
+#include <DebugServices.h>\r
+\r
+\r
+class CDLLComponentModule : public CAtlDllModuleT< CDLLComponentModule >\r
+{\r
+public :\r
+ DECLARE_LIBID(LIBID_Bonjour)\r
+ DECLARE_REGISTRY_APPID_RESOURCEID(IDR_DLLX, "{56608F9C-223B-4CB6-813D-85EDCCADFB4B}")\r
+};\r
+\r
+CDLLComponentModule _AtlModule;\r
+\r
+\r
+#ifdef _MANAGED\r
+#pragma managed(push, off)\r
+#endif\r
+\r
+// DLL Entry Point\r
+extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)\r
+{\r
+ debug_initialize( kDebugOutputTypeWindowsDebugger );
+ debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelVerbose );\r
+\r
+#ifdef _MERGE_PROXYSTUB\r
+ if (!PrxDllMain(hInstance, dwReason, lpReserved))\r
+ return FALSE;\r
+#endif\r
+ hInstance;\r
+ return _AtlModule.DllMain(dwReason, lpReserved); \r
+}\r
+\r
+#ifdef _MANAGED\r
+#pragma managed(pop)\r
+#endif\r
+\r
+\r
+\r
+\r
+// Used to determine whether the DLL can be unloaded by OLE\r
+STDAPI DllCanUnloadNow(void)\r
+{\r
+#ifdef _MERGE_PROXYSTUB\r
+ HRESULT hr = PrxDllCanUnloadNow();\r
+ if (hr != S_OK)\r
+ return hr;\r
+#endif\r
+ return _AtlModule.DllCanUnloadNow();\r
+}\r
+\r
+\r
+// Returns a class factory to create an object of the requested type\r
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)\r
+{\r
+#ifdef _MERGE_PROXYSTUB\r
+ if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)\r
+ return S_OK;\r
+#endif\r
+ return _AtlModule.DllGetClassObject(rclsid, riid, ppv);\r
+}\r
+\r
+\r
+// DllRegisterServer - Adds entries to the system registry\r
+STDAPI DllRegisterServer(void)\r
+{\r
+ // registers object, typelib and all interfaces in typelib\r
+ HRESULT hr = _AtlModule.DllRegisterServer();\r
+#ifdef _MERGE_PROXYSTUB\r
+ if (FAILED(hr))\r
+ return hr;\r
+ hr = PrxDllRegisterServer();\r
+#endif\r
+ return hr;\r
+}\r
+\r
+\r
+// DllUnregisterServer - Removes entries from the system registry\r
+STDAPI DllUnregisterServer(void)\r
+{\r
+ HRESULT hr = _AtlModule.DllUnregisterServer();\r
+#ifdef _MERGE_PROXYSTUB\r
+ if (FAILED(hr))\r
+ return hr;\r
+ hr = PrxDllRegisterServer();\r
+ if (FAILED(hr))\r
+ return hr;\r
+ hr = PrxDllUnregisterServer();\r
+#endif\r
+ return hr;\r
+}\r
+\r