blob: e336be599c0138f7b173888dfaf4835681e842d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
|