2021-12-12 12:04:13 -08:00
|
|
|
// Copyright 2021 Dolphin Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include "HRWrap.h"
|
|
|
|
|
2024-08-29 22:02:28 +02:00
|
|
|
#ifndef _MSC_VER
|
|
|
|
#include <comdef.h>
|
|
|
|
#endif
|
|
|
|
#include "Common/StringUtil.h"
|
|
|
|
|
2021-12-12 12:04:13 -08:00
|
|
|
namespace Common
|
|
|
|
{
|
2024-08-29 22:02:28 +02:00
|
|
|
#ifdef _MSC_VER
|
2021-12-12 12:04:13 -08:00
|
|
|
std::string GetHResultMessage(HRESULT hr)
|
|
|
|
{
|
2023-01-23 06:09:01 -08:00
|
|
|
auto err = winrt::hresult_error(hr);
|
|
|
|
return winrt::to_string(err.message());
|
2021-12-12 12:04:13 -08:00
|
|
|
}
|
2023-06-11 21:51:49 -05:00
|
|
|
std::string GetHResultMessage(const winrt::hresult& hr)
|
|
|
|
{
|
|
|
|
return GetHResultMessage(hr.value);
|
|
|
|
}
|
2024-08-29 22:02:28 +02:00
|
|
|
#else
|
|
|
|
std::string GetHResultMessage(HRESULT hr)
|
|
|
|
{
|
|
|
|
_com_error err(hr);
|
|
|
|
return TStrToUTF8(err.ErrorMessage());
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-12 12:04:13 -08:00
|
|
|
} // namespace Common
|