Skip to main content

 none
Implementing DDiscFormat2DataEvents without ATL RRS feed

  • Question

  • Hi, I'm attempting to write a application that uses IMAPI 2.0 to burn CD's & DVD's within a MFC application.

    So far I have had no issues implementing the code required to build the disc image & erase the disc however
    would really like to add the progress statistics for these operations.

    The issue i have been having is implementing the DDiscFormat2DataEvents& DDiscFormat2EraseEvents.
    They do not seem to follow the standard convention for COM construction using CoCreateInstance. As a result i'm
    having some difficulty working out how to implement these interfaces without using ATL.

    I have looked around on the internet and not found anything thats not C# or ATL that implements these interfaces
    so if anyone can help???

    Thanks,

    Phil
    Thursday, June 12, 2008 5:06 PM

Answers

  • Hi Phil,

     

    I wrote an MFC article here that includes a class CDiscFormatDataEvent that implements DDiscFormat2DataEvents and does not use ATL.  From there, you should probably be able to figure out DDiscFormat2EraseEvents.

     

    Hope that helps!

    Thursday, June 12, 2008 6:48 PM

All replies

  • Hi Phil,

     

    I wrote an MFC article here that includes a class CDiscFormatDataEvent that implements DDiscFormat2DataEvents and does not use ATL.  From there, you should probably be able to figure out DDiscFormat2EraseEvents.

     

    Hope that helps!

    Thursday, June 12, 2008 6:48 PM
  • Hi Eric,

    Thanks a lot for your post and the example on how to implement these IMAPI 2 interfaces Smile.
    Using the BEGIN_INTERFACE_PART to map to the interfaces is not something i would have worked
    out any time soon. Using the example as a guide i have managed to get the DDFormat2EraseEvents working
    within my application.

    Once again. Thanks for the help

    Phil
    Friday, June 13, 2008 10:04 AM
  • Great!  glad I could help.

    Friday, June 13, 2008 1:56 PM
  • hi,

     

    I am trying to make a progress bar for my cd burner/eraser tool. I used imapi2 for this purpose

    but unfortunately, I can not create objects for DDiscFormat2DataEvents and IDiscFormat2DataEventArgs interfaces' implementation.

    this does not work:

     

    result = CoCreateInstance(__uuidof(MsftDiscFormat2Data),

    NULL,

    CLSCTX_ALL,

    __uuidof(IDiscFormat2DataEventArgs),

    (void **)&progressHandler_);

     

    how can I implement these interfaces? is there another way to make a progress bar? I tried get_freeSector and get_totalSector methods, but unfortunately get_freeSector does not refresh itself.

    another problem is, for erasing there are IDiscFormat2Erase and DDiscFormat2EraseEvents interfaces, but there is no IDiscFormat2EraseEventsArg, after I manage to create these objects, how can I obtain elapsedTime, remainingTime, totalTime values at the time of erase operation?

     

    In summary, please help me for progress bar in C++ with imapi2 with code samples or advices..

     

    thanks...

    tugba akbal

     

     

     

     

    Tuesday, September 23, 2008 12:40 PM
  • It would be helpful if you included the failed result code of CoCreateInstance.

     

    The DDiscFormat2EraseEvents::Update method sends the elapsed seconds and estimated total seconds in the parameters, so there is no need for an IDiscFormat2EraseEventsArg interface.  You should be able to calculate all of your values and update the progress bar.

    Tuesday, September 23, 2008 3:13 PM
  • hi Eric,

     

    first of all, thanks for your reply. HRESULT value returns as E_NOINTERFACE. I tried CoCreateInstance but it did not work. maybe, the reason is: I tried to create 3 MsftDiscFormat2Data objects. one for DDiscFormat2DataEvents, another for IDiscFormat2Data and the last one for IDiscFormat2DataEventArgs interfaces(ref: http://msdn.microsoft.com/en-us/library/aa366216(VS.85).aspx). CoCreateInstance method is usable for a single instance. but for progress bar, I need 3 different interface objects. I create and initialize these interface objects consecutively  in one method. I can not reply these questions by myself unfortunately Sad do I have to use CoGetObject or CoCreateInstance? what must do? if I can see a sample C++ code, I will be happy. it is more difficult to implement in C++ than visual or C#. even to create an interface object is too complex..

     

    thanks..

    tugba

     

    Tuesday, September 23, 2008 7:20 PM
  •  

    That is most likely the problem!

     

    As posted above, I have an MFC sample here if that helps.

     

    Tuesday, September 23, 2008 7:31 PM
  • hi Eric,

     

    I will try to implemente these in Qt instead of MFC, but your code may help me. I continue to work on this.

     

    thanks Smile

    tugba

     

     

     

     

    Wednesday, September 24, 2008 6:53 AM
  •  

    hi,

     

    I tried (without MFC):

     

    result = OleInitialize(NULL);

    IUnknown * punk;

    IDispatch * pdisp;

    IDiscFormat2DataEventArgs *progressHandler_;

     

    result = CoCreateInstance(CLSID_MsftDiscFormat2Data,

    NULL,

    CLSCTX_ALL,

    IID_IUnknown,

    (void FAR* FAR*)&punk);

     

    // Call QueryInterface to see if object supports IDispatch.

    result = punk->QueryInterface(IID_IDispatch, (void **)&pdisp);

    result = pdisp->QueryInterface(IID_PPV_ARGS(&progressHandler_));  -> this always returns E_NOINTERFACE

    I can not understand the reason. because msdn says that, MsftDiscFormat2Data supports IDiscFormat2DataEventArgs interface. but I begin to think about that, it does not support. what is your opinion?

     

    thanks

    tugba akbal

     

    Wednesday, September 24, 2008 10:36 AM
  •  

    You do not get the IDiscFormat2DataEventArgs from the MsftDiscFormat2Data interface, you get it from the 2nd parameter in the Update event.  Check out my CDiscFormatDataEvent class in my sample.
    Thursday, September 25, 2008 3:59 PM
  • Hi tugba,

    You wrote that you tried to implement these in Qt.
    Was it succeeded?
    If yes, could you share your result in Qt?

    Thanks for your reply.


    Wednesday, June 7, 2017 1:42 PM