diff options
author | crupest <crupest@outlook.com> | 2022-02-03 17:55:00 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-03 17:55:00 +0800 |
commit | 5aca7b099c46a87a859f40110efce708200a4bc8 (patch) | |
tree | 76a0daef247ab2b2269eebdbbda10134f213d1ca /src/common/platform/win/ComAutoInit.cpp | |
parent | d15172cfe1ac8558567c1b1c10c2e671b0d1f033 (diff) | |
download | cru-5aca7b099c46a87a859f40110efce708200a4bc8.tar.gz cru-5aca7b099c46a87a859f40110efce708200a4bc8.tar.bz2 cru-5aca7b099c46a87a859f40110efce708200a4bc8.zip |
...
Diffstat (limited to 'src/common/platform/win/ComAutoInit.cpp')
-rw-r--r-- | src/common/platform/win/ComAutoInit.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/platform/win/ComAutoInit.cpp b/src/common/platform/win/ComAutoInit.cpp new file mode 100644 index 00000000..e336be59 --- /dev/null +++ b/src/common/platform/win/ComAutoInit.cpp @@ -0,0 +1,15 @@ +#include "cru/common/platform/win/ComAutoInit.hpp" +#include "cru/common/platform/win/Exception.hpp" + +#include <combaseapi.h> + +namespace cru::platform::win { +ComAutoInit::ComAutoInit() { + const auto hresult = ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + if (FAILED(hresult)) { + throw HResultError(hresult, "Failed to call CoInitializeEx."); + } +} + +ComAutoInit::~ComAutoInit() { ::CoUninitialize(); } +} // namespace cru::platform::win |