winrt::to_hresult 函式 (C++/WinRT)

協助程式函式,用於 catch 區塊,將最後擲回的例外狀況轉換成 HRESULT 錯誤碼。 在攔截 winrt::hresult_error的 catch 區塊中,您可以使用 hresult_error::to_abi 成員函式,直接從該類型取得 HRESULT。 在其他 catch 區塊中,您可以呼叫 winrt::to_hresult 函式來取得 HRESULT,如果擲回的例外狀況是下列任一情況: winrt::hresult_errorstd::bad_alloc、std:out_of_rangestd::invalid_argumentstd::exception

to_hresult 是您很少需要使用的低階函式。

語法

inline __declspec(noinline) HRESULT to_hresult() noexcept;

傳回值

最後擲回例外狀況所代表的 HRESULT 錯誤碼。

規格需求

最低支援的 SDK:Windows SDK 10.0.17134.0 版 (Windows 10版本 1803)

命名空間: winrt

標頭: %WindowsSdkDir%IncludeWindowsTargetPlatformVersion <> \cppwinrt\winrt\base.h 預設包含 ()

另請參閱