在D3D12程序中,我遇到一个DGXI_ERROR (CreateSharedHandle返回一个int <0),但我找不到一种方法将它转换为“错误描述”或“错误名称”(或两者都有)。
我有一个微软的描述:https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/dxgi-error
有这样的功能吗?
发布于 2019-10-06 02:41:33
出于开发目的,Visual Studio中的"Error Lookup Tool“可以根据值告诉您转换和代码。
您还可以启用"DXGI调试“,这将在调试版本的调试输出窗口中提供有关错误情况的更多信息。参见this blog post。
在编程上,你可以在Windows10上使用FormatMessage来实现:
LPWSTR errorText = nullptr;
DWORD result = FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_ALLOCATE_BUFFER, nullptr, hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPWSTR>(&errorText), 0, nullptr );
if (result > 0)
{
// errorText contains the description of the error code hr
LocalFree( errorText );
}
else
{
// Error not known by the OS
}https://stackoverflow.com/questions/58248914
复制相似问题