0
我的環境是Java 8,在Windows 7 - 64位。因此,這裏是我的要求和程序,我也跟着 的Java:Java版本「1.8.0_131」 32位 雅各布:雅各1.18 x86.dll & jacob.jarjacob不能QI對象IDispatch
我用的是eclipse運行下面的代碼。它的作品好。
import com.jacob.com.*;
import com.jacob.activeX.*;
public class DispatchTest {
public static void main(String[] args) {
ActiveXComponent xl = new ActiveXComponent("Execl.Application");
Dispatch xlo = (Dispatch)(xl.getObject());
try {
System.out.println("version="+xl.getProperty("Version"));
System.out.println("version="+Dispatch.get(xlo, "Version"));
} catch (Exception e) {
e.printStackTrace();
} finally {
xl.invoke("Quit", new Variant[] {});
}
}
}
當我嘗試使用第三方的dll和我滿足以下execption:
import com.jacob.com.*;
import com.jacob.activeX.*;
public class DispatchTest {
public static void main(String[] args) {
ActiveXComponent xl = new ActiveXComponent("ProjectParser.1");
Dispatch xlo = (Dispatch)(xl.getObject());
try {
System.out.println("version="+xl.getProperty("Version"));
System.out.println("version="+Dispatch.get(xlo, "Version"));
} catch (Exception e) {
e.printStackTrace();
} finally {
xl.invoke("Quit", new Variant[] {});
}
}
}
Exception in thread "main" com.jacob.com.ComFailException: Can't QI object for IDispatch
at com.jacob.com.Dispatch.createInstanceNative(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java:99)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
at DispatchTest.main(DispatchTest.java:5)
https://github.com/joval/jacob/blob/master/jni/Dispatch.cpp
任何人都可以請指導我該如何解決?