有时我会收到错误(异常):
java.lang.IllegalStateException: Dispatch not hooked to windows memory
这是什么意思?如何预防?
这是导致此错误的示例代码:
import com.jacob.activeX.*;
import com.jacob.com.*;
public class Hooked {
public static void main(String[] args) {
ActiveXComponent e = new ActiveXComponent("Excel.Application");
ActiveXComponent sh = new ActiveXComponent(
e.getProperty("ActiveSheet").toDispatch());
System.out.println(sh.getPropertyAsString("Name"));
}
}