|
最近项目要测试控件,用户指定要用jacob。希望高手指点!!!!小弟感激不尽。。。。。。
- package jacob;
- import com.jacob.activeX.*;
- import com.jacob.com.*;
- public class MyJacobTest {
- public void initTest() {
- //获得控件id
- ActiveXComponent acomx = new ActiveXComponent("TAXDISK.TaxDiskCtrl.1");
- try {
- //获得控件对象
- Dispatch obj = (Dispatch)acomx.getObject();
- //取得属性
- Dispatch a1= Dispatch.get(obj,"a1").toDispatch();
- Dispatch a2 = Dispatch.get(obj,"a2").toDispatch();
- Dispatch a3 = Dispatch.get(obj,"a3").toDispatch();
- Dispatch a4 = Dispatch.get(obj,"a4").toDispatch();
- Dispatch a5 = Dispatch.get(obj,"a5").toDispatch();
- Dispatch a6 = Dispatch.get(obj,"a6").toDispatch();
-
- Dispatch b1 = Dispatch.invoke(a1,"getTxx",Dispatch.Get,new Object[]{"A1"},new int[1]).toDispatch();
- Dispatch b2 = Dispatch.invoke(a2,"getTxx",Dispatch.Get,new Object[]{"A2"},new int[1]).toDispatch();
- Dispatch b3 = Dispatch.invoke(a3,"getTxx",Dispatch.Get,new Object[]{"A3"},new int[1]).toDispatch();
- Dispatch b4 = Dispatch.invoke(a4,"getTxx",Dispatch.Get,new Object[]{"A4"},new int[1]).toDispatch();
- Dispatch b5 = Dispatch.invoke(a5,"getTxx",Dispatch.Get,new Object[]{"A5"},new int[1]).toDispatch();
- Dispatch b6 = Dispatch.invoke(a6,"getTxx",Dispatch.Get,new Object[]{"A6"},new int[1]).toDispatch();
- //设置属性值
- Dispatch.put(b1, "a1","1");
- Dispatch.put(b2, "a2","888");
- Dispatch.put(b3, "a3","777");
- Dispatch.put(b4, "a4","9999");
- Dispatch.put(b5, "a5","7777");
- Dispatch.put(b6, "a6","88888");
- //取属性值
- Variant result=Dispatch.call(b1,"a1");
- System.out.println(result);
- } catch (RuntimeException e) {
- System.out.println("*****1*******"+e.toString()+"\n"));
- e.printStackTrace();
- System.out.println("*****2*******"+e.toString()+"\n");
- }
- }
- public static void main(String[] args) {
- ComThread.InitSTA();
- MyJacobTest mt = new MyJacobTest();
- mt.initTest();
- ComThread.Release();
- }
- }
复制代码 我的jdk1.4 jacob1.15 dll(放到了指定目录 system32 jre/bin)为什么运行时总是出错
com.jacob.com.ComFailException: Can't map name to dispid:a1 |
|