#include "StdAfx.h"
CDaveComponent::CDaveComponent() : m_lRefCount(0) {};
CDaveComponent::~CDaveComponent() {};
// The IUnknown Methods
STDMETHODIMP CDaveComponent::QueryInterface (REFIID riid, void** ppv) {
if (riid == IID_IUnknown) *ppv = static_cast<IJack*>(this);
else if (riid == IID_IJack) *ppv = static_cast<IJack*> (this);
else if (riid == IID_IClavdivs) *ppv = static_cast<IClavdivs*> (this);
else {
*ppv = NULL;
return E_NOINTERFACE;
}
static_cast<IUnknown*>(*ppv)->AddRef();
return S_OK;
}
STDMETHODIMP_(ULONG) CDaveComponent::AddRef() {
return InterlockedIncrement(&m_lRefCount);
}
STDMETHODIMP_(ULONG) CDaveComponent::Release() {
ULONG uTemp;
uTemp = InterlockedDecrement(&m_lRefCount);
if (uTemp == 0) delete this;
return uTemp;
}
// IJack interface methods
STDMETHODIMP CDaveComponent::Test() {
MessageBox(NULL, "Hello World!", "IJack:Test",
MB_OK);
return S_OK;
}
// IClavdivs interface methods
STDMETHODIMP CDaveComponent::DisplayStuff() {
MessageBox(NULL, "STUFF!", "IClavdivs:DisplayStuff",
MB_OK);
return S_OK;
}