每当幻灯片放映开始或结束时,我都尝试使用 JACOB 获取回调,使用以下命令:
public class Test {
public static void main(String[] args) {
ActiveXComponent oApp = new ActiveXComponent("PowerPoint.Application");
Dispatch presentations = oApp.getProperty("Presentations").toDispatch();
Dispatch presentation = Dispatch.call(presentations, "Open", "C:\\Users\\Bob\\Documents\\test.ppt").toDispatch();
new DispatchEvents(oApp, new Handler());
}
}
public class Handler {
public void SlideShowBegin(Variant[] args) {
System.out.println("here");
}
}
但是,我有点不解,上面的结果是:
GetEventIID: couldn't get IProvideClassInfo
Exception in thread "main" com.jacob.com.ComFailException: Can't find event iid
at com.jacob.com.DispatchEvents.init3(Native Method)
at com.jacob.com.DispatchEvents.<init>(DispatchEvents.java:138)
at com.jacob.com.DispatchEvents.<init>(DispatchEvents.java:99)
at com.jacob.com.DispatchEvents.<init>(DispatchEvents.java:72)
at tester.Test.main(Test.java:28)
有没有人有任何想法?搜索时间很短。我尝试使用 4 参数构造函数DispatchEvents
,提供“Powerpoint.Application”和 powerpoint exe 的完整路径作为最后两个参数,但没有区别。