当前位置:编程学习 > JAVA >>

jacob 调用出错 急等!

下面是代码:
import com.jacob.com.*;
import com.jacob.activeX.*;

public class Jao
{
  public static String  java_Dll(String str,String s,int n){
    String res="";
    try {
        ActiveXComponent pp = new ActiveXComponent("segposCOM.seg");
     Dispatch myCom =(Dispatch) pp.getObject(); //生成一个对象

     Variant result = Dispatch.call( myCom, "SegChs", new Variant(str),new Variant(s),new Variant(n)) ;
     System.out.println(result.toString());
 res=result.toString();
    }catch (Exception e) {
     res="";
        e.printStackTrace();
    }
    return res;
  }
  public static void main(String[] args) {
String str="我是中国人";
String s="_";
int n=1;
java_Dll(str, s, n);
}
}
报错信息如下:
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: SegChs
Description: 内存分配访问无效。

at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:858)
at com.jacob.com.Dispatch.callN(Dispatch.java:455)
at com.jacob.com.Dispatch.call(Dispatch.java:571)
at com.huizhi.util.Jao.java_Dll(Jao.java:14)
at com.huizhi.util.Jao.main(Jao.java:27)
如图:

--------------------编程问答-------------------- 先谢谢大家 了  --------------------编程问答-------------------- 请大家帮帮忙吧  --------------------编程问答-------------------- 怎么没人回答呢 --------------------编程问答-------------------- 只能说,调用方法没错,是不是DLL出问题了,最近也在研究调用DLL,看看我帖子问题有否遇到过
补充:Java ,  Eclipse
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,