Jump to content

How to capture events with Java & Jacob


Recommended Posts

I'm trying to capture events with Java and JACOB

Not sure if the code is correct. it throws com.jacob.com.ComFailException: Can't find event iid

Any suggestions?

try {
	 DVBViewer = ActiveXComponent.connectToActiveInstance(
   "DVBViewerServer.DVBViewer");
	 if (DVBViewer == null) {
   DVBViewer = new ActiveXComponent("DVBViewerServer.DVBViewer");
	 }
	 Dispatch src = DVBViewer.getProperty("Events").toDispatch();
	 DVBEvents dvbevents = new DVBEvents();
	 DispatchEvents de = new DispatchEvents(src,dvbevents);
}
 catch (Exception e) {
	 e.printStackTrace();
 }

 

import com.jacob.com.*;
import com.jacob.activeX.*;

public class DVBEvents {
 public void OnChannelChange(Variant[] args)
{
  System.out.println("test");
}
}

 

additional info http://danadler.com/jacob/

Events

 

The current model is conceptually similar to the Visual Basic WithEvents construct. Basically, I provide a class called com.jacob.com.DispatchEvents which has a constructor that takes a source object (of type com.jacob.com.Dispatch) and a target object (of any type). The source object is queried for its IConnectionPointContainer interface and I attempt to obtain an IConnectionPoint for its default source interface (which I obtain from IProvideClassInfo). At the same time, I also create a mapping of DISPID's for the default source interface to the actual method names. I then use the method names to get jmethodID handles from the target Java object. All event methods currently must have the same signature: one argument which is a Java array of Variants, and a void return type.

 

The dependency on IProvideClassInfo means that the Type Library for the component must exist if you want to support events. Version 1.7 also includes code to read the type library directly from the progid. This makes it possible to work with all the Microsoft Office application events, as well as IE5 events. For an example see the samples/test/IETest.java example.

Link to comment

Still no go...

Dispatch src = DVBViewer.getProperty("Events").toDispatch();
DVBEvents dvbevents = new DVBEvents();
DispatchEvents de = new DispatchEvents(src,dvbevents,"DVBViewerServer.DVBViewer","C:\\Program Files\\DVBViewer\\DVBViewer.exe");

com.jacob.com.ComFailException: Can't FindConnectionPoint

at com.jacob.com.DispatchEvents.init3(Native Method) B)

 

Dispatch src = DVBViewer.QueryInterface("{B397FB16-A027-4D5B-88EB-FD9A2AA28D92}");
DVBEvents dvbevents = new DVBEvents();
DispatchEvents de = new DispatchEvents(src,dvbevents,"DVBViewerServer.DVBViewer","C:\\Program Files\\DVBViewer\\DVBViewer.exe");

com.jacob.com.ComFailException: QI on IID from String Failed

at com.jacob.com.Dispatch.QueryInterface(Native Method);)

 

I'll try Jacob support forum now...

Link to comment
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...