We help IT Professionals succeed at work.

What is TESTHR

s_lavie
s_lavie asked
on
Hi,
I saw in an ADO sample code the following line:

TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

My question is:
What is TESTHR and why should I use it?
Comment
Watch Question

TESTHR is usually just an simple function or macro that tests the results of calls that return HRESULTS (as almost all COM calls do) and takes some action, i.e. it may raise an exception on failure.  It is, however, not a standard function and must be defined somewhere in your own code, an example is:

inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};