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*---------
JACOB调用 com组件
最新推荐文章于 2023-05-18 15:28:15 发布