package umessage;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Hello {
public static void main(String[] args) {
// TODO Auto-generated method stub
try
{
ActiveXComponent com = new ActiveXComponent("HelloDll.Hello.1");//加载com组件
Dispatch disp = com.getObject(); //得到com组件对象
//------------传出参数BSTR*----------------------------------
//Variant vaTemp = new Variant("", true); //创建Variant类型变量,传入空字符串,true代表传出参数。
//Dispatch.call(disp, "PrintRR", vaTemp);//PrintRR是函数名, vaTemp是参数
//System.out.println(vaTemp.toString()); //通过to转换各种类型。
//------------出入参数BSTR----------------------------------
//Dispatch.call(disp, "PrintWW", new Variant("hello word"));//传入字符串
//System.out.println(vaTemp.toString()); //通过to转换各种类型。
//---------------------传出参数调用,如下写法。VARIANT*-----------
Variant vaTemp = new Variant("", true); //创建Variant类型变量,传入空字符串,true代表传出参数。
JACOB调用 com组件
最新推荐文章于 2025-08-19 09:07:29 发布
本文详细介绍了如何在JAVA项目中利用JACOB库来无缝调用COM组件,包括JACOB的基本使用方法、安装配置以及实例演示,帮助开发者实现JAVA与COM组件的交互。


3042

被折叠的 条评论
为什么被折叠?



