使用JACOB创建ActiveXComponent

时间:2014-01-27 20:46:30

标签: java vbscript activex jacob com-automation

我是java的新手,之前从未使用过JACOB。我试图将此VBScript代码转换为java。我知道VBScript更适合使用COM自动化,但这是我需要做的:

将此VBScript代码转换为工作java -

Set LPS = CreateObject("atlDirectorObject.atlDirector")
if LPS.CreateTool("3270", 1, True, True, 0, atl3270Tool, ErrMsg) <> 0 Then
  Msgbox "Unable to connect to current 3270 Explorer session."
  wscript.quit
end if

此外,这里是我正在尝试使用的CreateTool函数的描述。

Function CreateTool(ToolName As String, CreateOptions As Long, Visible As Boolean, FocusTool As Boolean, TabHandle As Long, ToolDisp, ErrMsg) As Long
Member of atlDirectorObject.atlDirector

这是我目前在eclipse中编码的内容。你可以说,我不知道我在做什么。请帮忙:'(

import com.jacob.com.*;
import com.jacob.activeX.*;

public class atlDirectorObject {
public ActiveXComponent portal;
public Object portalObj;
public Object atl3270Tool;
public int ErrMsg;

    atlDirectorObject() {
     portal = new ActiveXComponent(atlDirectorObject.atlDirector);
     portalObj = portal.getObject();
}

    public void CreateTool() {
        boolean True;

        if (portalObj.CreateTool("3270",1,True,True,0,atl3270Tool,ErrMsg) !=  0)
         {
             System.out.println("Unable to connect to current 3270 Explorer session.");
         }
    }

    public static void main(String[] args) {
        atlDirectorObject LPS = new atlDirectorObject();
        LPS.CreateTool();
    }

}

0 个答案:

没有答案