1 | /** @file
|
---|
2 | * MS COM / XPCOM Abstraction Layer - COM initialization / shutdown.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2005-2020 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef VBOX_INCLUDED_com_com_h
|
---|
27 | #define VBOX_INCLUDED_com_com_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include "VBox/com/defs.h"
|
---|
33 | #include "VBox/com/utils.h"
|
---|
34 |
|
---|
35 | /** @defgroup grp_com MS COM / XPCOM Abstraction Layer
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 | namespace com
|
---|
40 | {
|
---|
41 |
|
---|
42 | /** @name VBOX_COM_INIT_F_XXX - flags for com::Initialize().
|
---|
43 | * @{ */
|
---|
44 | /** Windows: Caller is the GUI and needs a STA rather than MTA apartment. */
|
---|
45 | #define VBOX_COM_INIT_F_GUI RT_BIT_32(0)
|
---|
46 | /** Windows: Auto registration updating, if privileged enough. */
|
---|
47 | #define VBOX_COM_INIT_F_AUTO_REG_UPDATE RT_BIT_32(1)
|
---|
48 | /** Windows: Opt-out of COM patching (client code should do this). */
|
---|
49 | #define VBOX_COM_INIT_F_NO_COM_PATCHING RT_BIT_32(2)
|
---|
50 | /** The default flags. */
|
---|
51 | #define VBOX_COM_INIT_F_DEFAULT (VBOX_COM_INIT_F_AUTO_REG_UPDATE)
|
---|
52 | /** @} */
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Initializes the COM runtime.
|
---|
56 | *
|
---|
57 | * Must be called on the main thread, before any COM activity in any thread, and by any thread
|
---|
58 | * willing to perform COM operations.
|
---|
59 | *
|
---|
60 | * @return COM result code
|
---|
61 | */
|
---|
62 | HRESULT Initialize(uint32_t fInitFlags = VBOX_COM_INIT_F_DEFAULT);
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Shuts down the COM runtime.
|
---|
66 | *
|
---|
67 | * Must be called on the main thread before termination.
|
---|
68 | * No COM calls may be made in any thread after this method returns.
|
---|
69 | */
|
---|
70 | HRESULT Shutdown();
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Resolves a given interface ID to a string containing the interface name.
|
---|
74 | *
|
---|
75 | * If, for some reason, the given IID cannot be resolved to a name, a NULL
|
---|
76 | * string is returned. A non-NULL string returned by this function must be
|
---|
77 | * freed using SysFreeString().
|
---|
78 | *
|
---|
79 | * @param aIID ID of the interface to get a name for
|
---|
80 | * @param aName Resolved interface name or @c NULL on error
|
---|
81 | */
|
---|
82 | void GetInterfaceNameByIID(const GUID &aIID, BSTR *aName);
|
---|
83 |
|
---|
84 | #ifdef RT_OS_WINDOWS
|
---|
85 | void PatchComBugs(void);
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | } /* namespace com */
|
---|
89 |
|
---|
90 | /** @} */
|
---|
91 | #endif /* !VBOX_INCLUDED_com_com_h */
|
---|
92 |
|
---|