blob: 548a7bea6a62ea2112d900cce096d927a23744fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#include "cru/base/platform/win/ComAutoInit.h"
#include "cru/base/platform/win/Exception.h"
#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
|