From 0cccdcf9b215a41f4f600207f326e93b3c11fdfe Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Wed, 2 Dec 2020 07:19:36 +0800 Subject: [PATCH] src/win32: Add support for COINIT_APARTMENTTHREADED --- src/win32/Com.hxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/win32/Com.hxx b/src/win32/Com.hxx index 0c3c400fb..a2aa062a1 100644 --- a/src/win32/Com.hxx +++ b/src/win32/Com.hxx @@ -31,7 +31,17 @@ public: COM() { if (HRESULT result = CoInitializeEx(nullptr, COINIT_MULTITHREADED); FAILED(result)) { - throw FormatHResultError(result, "Unable to initialize COM"); + throw FormatHResultError( + result, + "Unable to initialize COM with COINIT_MULTITHREADED"); + } + } + COM(bool) { + if (HRESULT result = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + FAILED(result)) { + throw FormatHResultError( + result, + "Unable to initialize COM with COINIT_APARTMENTTHREADED"); } } ~COM() noexcept { CoUninitialize(); }