例如,常见的程序代码是这样写的:
CComQIPtr < IErrorInfo > spErrInfo; // 声明 IErrorInfo 接口
hr = ::GetErrorInfo( 0, &spErrInfo ); // 取得接口可是,这个函数是查询了谁的接口,然后赋值给指针的?

解决方案 »

  1.   

    http://msdn.microsoft.com/en-us/library/ms221032.aspxThis function returns a pointer to the most recently set IErrorInfo pointer in the current logical thread. It transfers ownership of the error object to the caller, and clears the error state for the thread.Making a COM call that goes through a proxy-stub will clear any existing error object for the calling thread. A called object should not make any such calls after calling SetErrorInfo and before returning. The caller should not make any such calls after the call returns and before calling GetErrorInfo. As a rule of thumb, an interface method should return as soon as possible after calling SetErrorInfo, and the caller should call GetErrorInfo as soon as possible after the call returns.