473,385 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

IMAPI how to register IDiscMasterProgressEvents

Hey guys,
I got IMAPI to burn, but I would like to set up this progress events so
I can make a progress bar to go along with the burn process. Right now
I'm not exactly sure how to get this to work. I'm assuming I need to
implement the IDiscMasterProgressEvents interface, so I created my own
class and created empty stubs. Then I called the following code.

Code:

CDProgressEvents pDiscMasterProgressEvents;
...

// set up IDiscMaster, IDiscRecord, IJolietDiscMaster, etc...

HRSEULT hr =
pDiscMaster->ProgressAdvise(&pDiscMasterProgressEvents, progressID);
On the last line of code HRESULT keeps returning that a null reference
pointer was passed to the stub. Aren't I suppose to be passing an empty
object so that ProgressAdvise can fill it up? If that is not it, could
someone explain to me what I am doing wrong?

Thanks,
Tony

Feb 15 '06 #1
9 3073
<to****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...

HRSEULT hr =
pDiscMaster->ProgressAdvise(&pDiscMasterProgressEvents, progressID);
On the last line of code HRESULT keeps returning that a null reference
pointer was passed to the stub. Aren't I suppose to be passing an empty
object so that ProgressAdvise can fill it up? If that is not it, could
someone explain to me what I am doing wrong?


Could you elaborate on 'progressID' ?

--
Jeff Partch [VC++ MVP]
Feb 15 '06 #2
progressID is just a ID so I can pass it to a ProgressUnadvise call and
deactivate the notfication.

Feb 15 '06 #3
sorry to be more clear

this is the function header

HRESULT ProgressAdvise(
IDiscMasterProgressEvents* pEvents,
UINT_PTR* pnCookie
);

pEvents
[in] Pointer to an IDiscMasterProgressEvents interface that
receives the progress notifications.
pnCookie
[out] Uniquely identifies this registration. Save this value
because it will be needed by the ProgressUnadvise method.

I just create a UINT_PTR *progressID = 0;
and pass that into the function call.

I even tried using a local variable rather than a pointer..gave it some
junk id and passed in the address. HRESULT then gave me U_UNEXPECTED
return

Feb 15 '06 #4
<to****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
sorry to be more clear

I just create a UINT_PTR *progressID = 0;
and pass that into the function call.

I even tried using a local variable rather than a pointer..gave it some
junk id and passed in the address. HRESULT then gave me U_UNEXPECTED
return


That last description is more what I was looking for. FWIW, this quick test
seems to go through the motions without error...

VOID _stdcall DXS_DMTest(VOID)
{
IDiscMaster* pidm = NULL;
HRESULT hr = CoCreateInstance(CLSID_MSDiscMasterObj,
NULL, CLSCTX_INPROC_SERVER|CLSCTX_NO_FAILURE_LOG,
IID_IDiscMaster, (VOID**)&pidm);

if (SUCCEEDED(hr) && (pidm))
{
hr = pidm->Open();
if (SUCCEEDED(hr))
{
IDiscMasterProgressEvents* piEvents = NULL;
hr = DXSDiscMasterProgressEvents::CreateInstance(&piEve nts);
if (SUCCEEDED(hr) && (piEvents))
{
UINT_PTR uID = 0;
hr = pidm->ProgressAdvise(piEvents, &uID);
if (SUCCEEDED(hr) && (uID))
{
pidm->ProgressUnadvise(uID);
}
piEvents->Release();
}
pidm->Close();
}
pidm->Release();
}
}

--
Jeff Partch [VC++ MVP]
Feb 15 '06 #5
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; }

HRESULT STDMETHODCALLTYPE QueryCancel(boolean *pbCancel);

HRESULT STDMETHODCALLTYPE NotifyPnPActivity()
{ return E_NOTIMPL; }

HRESULT STDMETHODCALLTYPE NotifyAddProgress(long nCompletedSteps,
long nTotalSteps);

HRESULT STDMETHODCALLTYPE NotifyBlockProgress(long nCompleted, long
nTotal);

HRESULT STDMETHODCALLTYPE NotifyTrackProgress(long nCurrentTrack,
long nTotalTracks)
{ return E_NOTIMPL; }

HRESULT STDMETHODCALLTYPE NotifyPreparingBurn(long
nEstimatedSeconds)
{ return E_NOTIMPL; }

HRESULT STDMETHODCALLTYPE NotifyClosingDisc(long nEstimatedSeconds)
{ return E_NOTIMPL; }

HRESULT STDMETHODCALLTYPE NotifyBurnComplete(HRESULT status)
{ return E_NOTIMPL; }

HRESULT STDMETHODCALLTYPE NotifyEraseComplete(HRESULT status)
{ return E_NOTIMPL; }
};

HRESULT STDMETHODCALLTYPE CDProgressEvents::QueryCancel(boolean
*pbCancel)
{ return E_NOTIMPL; }

HRESULT STDMETHODCALLTYPE CDProgressEvents::NotifyAddProgress(long
nCompletedSteps, long nTotalSteps)
{ return E_NOTIMPL; }

HRESULT STDMETHODCALLTYPE CDProgressEvents::NotifyBlockProgress(long
nCompleted, long nTotal)
{ return E_NOTIMPL; }

Feb 15 '06 #6
<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]

Feb 15 '06 #7
sorry I'm a little behind on the acronyms..whats QI and FWIW?

Feb 16 '06 #8
<to****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
sorry I'm a little behind on the acronyms..whats QI and FWIW?


Sorry. QI is QueryInterface. FWIW is For What Its Worth.
--
Jeff Partch [VC++ MVP]
Feb 16 '06 #9
hey Jeff..I tested it out w/ your code..and it works. i'm didn't know
I had to set up the QI in a particular way. thanks for all your help =)

Feb 20 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Perry | last post by:
I desperately need help to get the IMAPI (Image Mastering API interface comes with Windows XP to burn CD) to work on my PC. I downloaded the IMAPI sample on Microsoft website: ...
0
by: Nadav | last post by:
Hi, I wonder, does the .NET Framework include an implementation for the IMAPI? ( not the MAPI API ) does it provide a specialized class for that? does ICDBurn is included in the collection...
2
by: Tony B | last post by:
Does anybody know what sdk is needed for VB 5.0 for using the IMAPI functions for writing files to cd in windows XP...or where can i download it from. I think this is it Microsoft Platform SDK,...
7
by: tonylc | last post by:
Hi, I'm trying to program in 2003 Visual Studio to try and burn files onto a cd burner in windows xp service pack 2. http://msdn.microsoft.com/msdnmag/issues/04/04/CQA/ I found some code on...
1
by: tonylc | last post by:
does anyone know what you need to include to get Visual Studio 2003 or 2005 to recognize IDiscMaster, IDiscRecorder and all the other interfaces in IMAPI? Right my visual studio only recognizes...
5
by: tonylc | last post by:
Hey guys, In my burn project, I have everything working except the cancellation of the burn. I have it setup such that when the user initiates a "cancel" the IDiscMasterProgressEvents handler...
6
by: tonylc | last post by:
I would like to do some error checking to see if the CD is write protected or not or whether there is even a CD media at all. From what I gather I should be calling the method QueryMediaType. ...
0
by: tonylc | last post by:
I am getting an error in the DiscMaster's SetActiveDiscRecorder whenever I put in a CD that is formatted by a 3rd party software. I know that IMAPI only works with formatted cds suitable for...
2
by: cagi | last post by:
Hi to all, this is my first post here so I'm hoping you can help me. Now I'm writing a app which, among all other things need to record some data to CD. I'm using IMAPI v1 and here is the problem: i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.