现在的位置: 首页 > 综合 > 正文

HRESULT 返回值

2013年10月11日 ⁄ 综合 ⁄ 共 752字 ⁄ 字号 评论关闭
 

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 ) ){...} // 如果失败 

抱歉!评论已关闭.