#pragma once
#include <comdef.h>
namespace misc{
inline void TESTHR(HRESULT hr){
if FAILED(hr){
IErrorInfo* pEI;
GetErrorInfo(0,&pEI);
throw _com_error(hr,pEI);
}
}
//BOOL _com_error_msg(_com_error& e,LPCTSTR file=__FILE__,int linenum=__LINE__,bool bShowcontinue=false,BSTR bstrDesc=0,bool bShowCheck=false);
class ComErrorMsg
{
#ifdef _DEBUG
const char* m_file;
int m_line;
#endif
public:
ComErrorMsg( const char* file, int line)
#ifdef _DEBUG
:m_file( file ),
m_line( line )
#endif
{
}
BOOL operator()(_com_error& e,bool bShowcontinue=false,BSTR bstrDesc=0,bool bShowCheck=false);
};
}//namespace misc;
#define _COM_ERROR_MSG_ (misc::ComErrorMsg( __FILE__, __LINE__ ))