Is there a way to get the string representation of HRESULT value using win API?

后端 未结 4 1846
陌清茗
陌清茗 2020-12-01 02:55

Is there a function in win API which can be used to extract the string representation of HRESULT value?

The problem is that not all return values are documented in M

4条回答
  •  旧时难觅i
    2020-12-01 03:05

    You can use _com_error:

    _com_error err(hr);
    LPCTSTR errMsg = err.ErrorMessage();
    

    If you don't want to use _com_error for whatever reason, you can still take a look at its source, and see how it's done.

    Don't forget to include the header comdef.h

提交回复
热议问题