posts - 241,  comments - 116,  trackbacks - 0
在公司里,不同的系统使用不能的语言非常正常,我曾经在一个公司就职,原先的博客系统使用asp编写的,里面有很多dll文件,在asp里,可直接调用 dll文件,非常简单,但由于系统升级后,都统一使用了Java,那么原先编写的很多模块(封装在dll里的)就都不能用了,但有一个加密算法还非得在客 服系统里用到(因为新旧系统要并行运行一段时间,客服系统必须同时能管理新旧两大系统),那么如何在Java中调用VB编写的Dll文件呢?代码如下:
import com.jacob.com.*;
import com.jacob.activeX.*;

public class VbdllCall
{
  
public static String md5CallVbdll(String str){
    String res
="";
    
try {
        ActiveXComponent pp 
= new ActiveXComponent("md5.Class1");
        Dispatch myCom 
= (Dispatch) pp.getObject(); //生成一个对象
        Variant result = Dispatch.call( myCom, "MD5", str) ;
        res
=result.toString();
    }
catch (Exception e) {
        res
="";
        e.printStackTrace();
    }
    
return res;
  }
}

posted on 2008-12-09 13:18 墙头草 阅读(803) 评论(1)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
人人游戏网 软件开发网 货运专家