1

I'm developing an application with burning DVD functionality. The IMAPI2 interfaces stack is provided by a COM object, and I've managed to hook into it using com4j. Now the application is able to burn DVD successefully but unfortunately, I'm not able to capture writing-events during burn. I wonder if somebody can take a look on the code and advise how to subsribe to write engine events correctly. When I'm trying to use this code:

        IDiscRecorder2 recorder = ClassFactory.createMsftDiscRecorder2();
        String recorderUniqueId = dm.item(0);

        // initialize disk recorder
        recorder.initializeDiscRecorder(recorderUniqueId);
        //  Define the new disc format and set the recorder
        IDiscFormat2Data dataWriter = ClassFactory.createMsftDiscFormat2Data();
        dataWriter.recorder(recorder);

        // TODO Need subscribe to writeEngine events but getting error
        dataWriter.advise(DWriteEngine2Events.class, new DWriteEngine2EventsReceiver());

But here I'm getting an error in runtime: java.util.concurrent.CompletionException: com4j.ExecutionException: com4j.ComException: 80040200 (Unknown error) : .\invoke.cpp:517

The DWriteEngine2EventsReceiver class is implementation of the DWriteEngine2Events interface:

public class DWriteEngine2EventsReceiver implements DWriteEngine2Events {

    @DISPID(7)
    @Override
    public void update(Com4jObject object, Com4jObject progress) {
        System.out.println("DWriteEngine2EventsReceiver.update");
    }

    @Override
    public int getPtr() {
        System.out.println("DWriteEngine2EventsReceiver.getPtr()");
        return 0;
    }

    @Override
    public long getPointer() {
        System.out.println("DWriteEngine2EventsReceiver.getPointer()");
        return 0;
    }
    // all other methods of DWriteEngine2Events COM interface defined similarly

I expected that DWriteEngine2EventsReceiver.update method should receive event notification. What I'm doing wrong? PS. here the full method code: https://github.com/vzateychuk/iso-writer/blob/master/desktop/src/main/java/ru/vez/iso/desktop/burn/BurnSrvImpl.java#L101 (exception in line 125)

vzateychuk
  • 301
  • 1
  • 3
  • 12

0 Answers0