#import引用组件类型库,自动生成.tli文件。
inline long IA::GetnValue ( ) {
long _result = 0;
HRESULT _hr = get_nValue(&_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _result;
}
inline void IA::PutnValue ( long pVal ) {
HRESULT _hr = put_nValue(pVal);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
}
这样,就可以在使用组件接口时抛出异常,并且自动获得返回值。
抛出的异常_com_error定义如下: