gpt4 book ai didi

error-handling - 如何获得DXGI_ERROR描述?

转载 作者:行者123 更新时间:2023-12-03 08:44:14 24 4
gpt4 key购买 nike

在D3D12程序中,我遇到了DGXI_ERROR(CreateSharedHandle返回int <0),但是我找不到将其转换为“错误描述”或“错误名称”(或两者)的方法。

我对Microsoft的描述是:https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/dxgi-error

有这样的功能吗?

最佳答案

出于开发目的,Visual Studio中的“错误查找工具”可以告诉您值的转换和代码。

您还可以启用“DXGI调试”,这将在调试输出的调试输出窗口中提供有关错误情况的更多信息。参见this blog post

通过编程,您可以在Windows 10上使用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
}

参见 this blog post

关于error-handling - 如何获得DXGI_ERROR描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58248914/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com