Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
COM.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_Platform_Windows_COM_h_
5#define _Stroika_Foundation_Execution_Platform_Windows_COM_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#if qStroika_Foundation_Common_Platform_Windows
10#include <Windows.h>
11
12#include <objbase.h>
13#else
14#error "WINDOWS REQUIRED FOR THIS MODULE"
15#endif
16
17#include "Stroika/Foundation/Common/Common.h"
18
20
21 /**
22 */
23 class COMInitializer {
24 public:
25 /**
26 * Declare one of these objects to have the scope/lifetime for which you want COM initialized.
27 *
28 * if (worksWithAnyCoInitFlag) then ignore RPC_E_CHANGED_MODE, and allow any successful COM initialization
29 *
30 * \par Example Usage
31 * \code
32 * COMInitializer initCOMForScope { COINIT_APARTMENTTHREADED };
33 * \endcode
34 *
35 * \par Example Usage
36 * \code
37 * COMInitializer initCOMForScope { COINIT_MULTITHREADED };
38 * \endcode
39 *
40 * \note - if using MFC and/or OleInitialize(), users may wish to create a COMInitializer instance (with COINIT_APARTMENTTHREADED)
41 * very early, to assure application reliably sets up use of COINIT_APARTMENTTHREADED initialization.
42 */
43 COMInitializer () = delete;
44 COMInitializer (COINIT initFlag = COINIT_APARTMENTTHREADED, bool worksWithAnyCoInitFlag = true);
45 COMInitializer (const COMInitializer&) = delete;
46 ~COMInitializer ();
47
48 public:
49 nonvirtual COMInitializer& operator= (const COMInitializer&) = delete;
50
51 private:
52 bool fNeedsShutdown_{false};
53 };
54
55}
56
57/*
58 ********************************************************************************
59 ***************************** Implementation Details ***************************
60 ********************************************************************************
61 */
62#include "COM.inl"
63
64#endif /*_Stroika_Foundation_Execution_Platform_Windows_COM_h_*/