1 | /** @file
|
---|
2 | *
|
---|
3 | * DLLMAIN - COM DLL exports
|
---|
4 | *
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "VBox/com/defs.h"
|
---|
20 |
|
---|
21 | #include <SessionImpl.h>
|
---|
22 |
|
---|
23 | #include <atlbase.h>
|
---|
24 | #include <atlcom.h>
|
---|
25 |
|
---|
26 | CComModule _Module;
|
---|
27 |
|
---|
28 | BEGIN_OBJECT_MAP(ObjectMap)
|
---|
29 | OBJECT_ENTRY(CLSID_Session, Session)
|
---|
30 | END_OBJECT_MAP()
|
---|
31 |
|
---|
32 | /////////////////////////////////////////////////////////////////////////////
|
---|
33 | // DLL Entry Point
|
---|
34 |
|
---|
35 | extern "C"
|
---|
36 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
---|
37 | {
|
---|
38 | if (dwReason == DLL_PROCESS_ATTACH)
|
---|
39 | {
|
---|
40 | _Module.Init(ObjectMap, hInstance, &LIBID_VirtualBox);
|
---|
41 | DisableThreadLibraryCalls(hInstance);
|
---|
42 | }
|
---|
43 | else if (dwReason == DLL_PROCESS_DETACH)
|
---|
44 | _Module.Term();
|
---|
45 | return TRUE;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /////////////////////////////////////////////////////////////////////////////
|
---|
49 | // Used to determine whether the DLL can be unloaded by OLE
|
---|
50 |
|
---|
51 | STDAPI DllCanUnloadNow(void)
|
---|
52 | {
|
---|
53 | return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
|
---|
54 | }
|
---|
55 |
|
---|
56 | /////////////////////////////////////////////////////////////////////////////
|
---|
57 | // Returns a class factory to create an object of the requested type
|
---|
58 |
|
---|
59 | STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
---|
60 | {
|
---|
61 | return _Module.GetClassObject(rclsid, riid, ppv);
|
---|
62 | }
|
---|
63 |
|
---|
64 | /////////////////////////////////////////////////////////////////////////////
|
---|
65 | // DllRegisterServer - Adds entries to the system registry
|
---|
66 |
|
---|
67 | STDAPI DllRegisterServer(void)
|
---|
68 | {
|
---|
69 | // registers object, typelib and all interfaces in typelib
|
---|
70 | return _Module.RegisterServer(TRUE);
|
---|
71 | }
|
---|
72 |
|
---|
73 | /////////////////////////////////////////////////////////////////////////////
|
---|
74 | // DllUnregisterServer - Removes entries from the system registry
|
---|
75 |
|
---|
76 | STDAPI DllUnregisterServer(void)
|
---|
77 | {
|
---|
78 | return _Module.UnregisterServer(TRUE);
|
---|
79 | }
|
---|
80 |
|
---|