HRESULT 返回值

 

The following table lists the values of common HRESULT values. More values are contained in the header file winerror.h.

Name
Description
Value
S_OK
Operation successful
0x00000000
E_UNEXPECTED
Unexpected failure
0x8000FFFF
E_NOTIMPL
Not implemented
0x80004001
E_OUTOFMEMORY
Failed to allocate necessary memory
0x8007000E
E_INVALIDARG
One or more arguments are invalid
0x80070057
E_NOINTERFACE
No such interface supported
0x80004002
E_POINTER
Invalid pointer
0x80004003
E_HANDLE
Invalid handle
0x80070006
E_ABORT
Operation aborted
0x80004004
E_FAIL
Unspecified failure
0x80004005
E_ACCESSDENIED
General access denied error
0x80070005
S_FALSE
Operation failure
 

 

HRESULT 其實是一個雙字節的值,其最高位(bit)如果是0表示成功,1表示錯誤。我們在程序中如果需要判斷返回值,則可以使用比較運算符號;switch開關語句;也可以使用VC提供的宏:

      HRESULT hr = 調用組件函數;      if( SUCCEEDED( hr ) ){...} // 如果成功      ......      if( FAILED( hr ) ){...} // 如果失敗 
發佈了38 篇原創文章 · 獲贊 11 · 訪問量 32萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章