在这个时候,我们可以使用的java技术有jni、jna、jnative,这个大部分都可以完成任务。但是有时候我们在实际情况中拿到的dll有变化,当我们需要用的函数是在dll中的类里面的话,我们再使用前面的3种方法就会报Error looking up function '方法名'。
所以在这个时候就可以使用jacob,这个就可以访问得到了。
java代码事例:
public static String CreateBstrCommand(long controllerSN,String strFuncData){
//声明java调用的COM组件 相当于连接dll
ActiveXComponent component=new ActiveXComponent("WComm_UDP.Wcomm_Operate");
//执行函数 var为通用返回值
Variant var=Dispatch.call(component,"CreateBstrCommand", controllerSN,strFuncData);
//对返回值进行转化类型
String result=var.getString();