Microsoft DirectX 8.1 (C++) |
First, declare a class that will implement error logging. The class inherits the IAMErrorLog interface. It contains declarations for the three IUnknown methods, and for the single method in IAMErrorLog. The class declaration is as follows:
class CErrReporter : public IAMErrorLog
{
protected:
long m_lRef; // Reference count.
public:
CErrReporter() { m_lRef = 0; }
// IUnknown
STDMETHOD(QueryInterface(REFIID, void**));
STDMETHOD_(ULONG, AddRef());
STDMETHOD_(ULONG, Release());
// IAMErrorLog
STDMETHOD(LogError(LONG, BSTR, LONG, HRESULT, VARIANT*));
};
The only member variable in the class is m_lRef, which holds the object's reference count.
Next, define the methods in IUnknown. For details, refer to the sample code at the end of this article. With the COM framework in place, you can now implement the IAMErrorLog interface. The next section describes how to do this.