<to****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I'm assuming DXSDiscMasterProgressEvents is just a simple stubbed class
that just calls the constructor. I did something similar, but on the
pass to ProgressAdvise, I'm getting E_UNEXPECTED in the return value.
I pretty much copied your code and am using it. So does that mean my
implementation of the IDiscMasterProgressEvents is wrong? Here is all
I have so far.
class CDProgressEvents : public IDiscMasterProgressEvents
{
public:
CDProgressEvents() {}
~CDProgressEvents() {}
HRESULT static
CDProgressEvents::CreateInstance(IDiscMasterProgre ssEvents **instance)
{
if (*instance == NULL)
{
*instance = new CDProgressEvents();
}
return S_OK;
}
ULONG STDMETHODCALLTYPE AddRef( void) { return 0; }
ULONG STDMETHODCALLTYPE Release( void) { return 0; }
HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void
__RPC_FAR *__RPC_FAR *ppvObject) { return E_NOTIMPL; }
My guess is that your QI implementation is what is causing the problem. I
don't think QI is even allowed to return E_NOTIMPL. I didn't spend much time
on it, but FWIW, I implemented my event class like so...
class DXSDiscMasterProgressEvents : public IDiscMasterProgressEvents
{
public:
static HRESULT STDMETHODCALLTYPE
CreateInstance(IDiscMasterProgressEvents** ppEvents);
private:
DXSDiscMasterProgressEvents();
protected:
STDMETHOD(QueryInterface)(REFIID riid, LPVOID* ppv);
STDMETHOD_(ULONG, AddRef)(VOID);
STDMETHOD_(ULONG, Release)(VOID);
protected:
STDMETHOD(QueryCancel)(boolean *pbCancel);
STDMETHOD(NotifyPnPActivity)(VOID);
STDMETHOD(NotifyAddProgress)(LONG nCompletedSteps, LONG nTotalSteps);
STDMETHOD(NotifyBlockProgress)(LONG nCompleted, LONG nTotal);
STDMETHOD(NotifyTrackProgress)(LONG nCurrentTrack, LONG nTotalTracks);
STDMETHOD(NotifyPreparingBurn)(LONG nEstimatedSeconds);
STDMETHOD(NotifyClosingDisc)(LONG nEstimatedSeconds);
STDMETHOD(NotifyBurnComplete)(HRESULT status);
STDMETHOD(NotifyEraseComplete)(HRESULT status);
private:
ULONG m_cRefs;
};
DXSDiscMasterProgressEvents::DXSDiscMasterProgress Events() : m_cRefs(0)
{
}
STDMETHODIMP
DXSDiscMasterProgressEvents::CreateInstance(IDiscM asterProgressEvents**
ppEvents)
{
HRESULT hr = E_NOINTERFACE;
if (!(ppEvents))
hr = E_POINTER;
else
{
DXSDiscMasterProgressEvents* pThis = new
DXSDiscMasterProgressEvents;
hr = pThis->QueryInterface(IID_IDiscMasterProgressEvents,
(VOID**)ppEvents);
}
return hr;
}
STDMETHODIMP DXSDiscMasterProgressEvents::QueryInterface(REFIID riid,
LPVOID* ppv)
{
HRESULT hr = E_NOINTERFACE;
if (!(ppv))
hr = E_POINTER;
else
{
*ppv = NULL;
if ((IID_IUnknown == riid) || (IID_IDiscMasterProgressEvents ==
riid))
{
*ppv = this;
AddRef();
hr = S_OK;
}
}
return hr;
}
STDMETHODIMP_(ULONG) DXSDiscMasterProgressEvents::AddRef(VOID)
{
return InterlockedIncrement((LONG*)&m_cRefs);
}
STDMETHODIMP_(ULONG) DXSDiscMasterProgressEvents::Release(VOID)
{
ASSERT(0 != m_cRefs);
ULONG cRef = InterlockedDecrement((LONG*)&m_cRefs);
if (0 == cRef)
{
delete this;
}
return cRef;
}
....and for all the IDiscMasterProgressEvents methods I do just return
E_NOTIMPL.
--
Jeff Partch [VC++ MVP]