1 //==- llvm/Support/Windows/COM.inc - Windows COM Implementation -*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the Windows portion of COM support.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 //=== WARNING: Implementation here must contain only Windows code.
15 //===----------------------------------------------------------------------===//
22 InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading,
23 bool SpeedOverMemory) {
25 if (Threading == COMThreadingMode::SingleThreaded)
26 Coinit |= COINIT_APARTMENTTHREADED;
28 Coinit |= COINIT_MULTITHREADED;
30 Coinit |= COINIT_SPEED_OVER_MEMORY;
31 ::CoInitializeEx(nullptr, Coinit);
34 InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); }