【问题标题】:How to pass out argument of type BarTender.Messages如何传递 BarTender.Messages 类型的参数
【发布时间】:2019-10-21 07:55:05
【问题描述】:

我尝试使用 jacob 1.19 库将 Java 应用程序与 Bartender Seagull ActiveX 界面集成。我对print 方法有疑问,因为我不知道如何从 jacob 调用此方法。 我尝试了以下代码:

public void print( String printJobName, Boolean waitForSpoolJobToComplete, Integer timeoutMs )
    {    
     Variant args[] = new Variant[ 4 ];
     args[ 0 ] = new Variant( printJobName );
     args[ 1 ] = new Variant( waitForSpoolJobToComplete );
     args[ 2 ] = new Variant( timeoutMs );
     args[ 3 ] = new Variant();
     args[ 3 ].putNoParam();
     Variant ret = format.invoke( "Print", args );
}

其中格式是 .com.jacob.activeX.ActiveXComponent 实例,我得到异常:

遇到了 COM 异常:在调用时:打印说明: 80020005 / 类型不匹配。

我认为 Messages 参数会导致此异常。如何传递这个论点?

【问题讨论】:

  • MessagesBarTender BarTender.Messages 下的一个类,我对 jacob 不熟悉,但对您的了解很少代码你需要找到一种方法来获取 class Messages under Bartender
  • 可以用jacob检索Messages ObjectBarTender.Messages吗?
  • 我认为更好的办法是检索Messages Collection Object。我试图找回它,但我失败了。我不知道该怎么做。
  • 你有类似ActiveXComponent comp=ActiveXComponent.createNewInstance("BarTender.Application"); 的东西吗?可以从comp获取Messages Collection吗?
  • 我有'ActiveXComponent comp = new ActiveXComponent("BarTender.Application");'。它是Application Object,我不知道如何从中获取消息集合对象。我可以获取/设置属性和调用方法,但没有任何方法可以返回消息对象。

标签: jacob bartender


【解决方案1】:

不是 100% 确定代码,因为我没有尝试以下代码。如果发生任何 Java 错误,请纠正我。

Help Seagull阅读了几篇文章:

1.声明 BarTender 变量

ActiveXComponent btApp = new ActiveXComponent( "BarTender.Application" );

2。准备 Format.Print 函数

//Format.Print: Returns an object of btPrnRslt
public boolean print( String printJobName, Boolean waitForSpoolJobToComplete, Integer timeoutMs, Variant btMsgCol )
{    
    Variant args[] = new Variant[ 4 ];
    args[ 0 ] = new Variant( printJobName );
    args[ 1 ] = new Variant( waitForSpoolJobToComplete );
    args[ 2 ] = new Variant( timeoutMs );
    args[ 3 ] = new Variant( btMsgCol ); 

    Variant result = format.invoke( "Print", args );

    //if (btPrnRslt <> btPrnRsltSuccess)
    //    return false;
    //else
    //    return true;
}

3。试运行

if (myFormat.print(firstJob, true, timeOutMS, btMsgCol))
    //Do something if success
else
    //Do something not success

【讨论】:

  • 感谢您的帮助。代码ActiveXComponent btMsgCol = new ActiveXComponent( "BarTender.Messages" ); 抛出异常com.jacob.com.ComFailException: Can't get object clsid from progid
  • 我发现here 命令显示所有COM 对象gci HKLM:\Software\Classes -ea 0| ? {$_.PSChildName -match '^\w+\.\w+$' -and (gp "$($_.PSPath)\CLSID" -ea 0)} | ft PSChildName。列表中没有 BarTender.Messages。有:BarTender.Application、BarTender.Format、BarTender.PreviewHandler、BarTender.PropertyHandler、BarTender.ThumbnailExtension
  • 我不太了解 ActiveX/COM,但我认为 BarTender.Application 是 ActiveX 应用程序的某种处理程序。我必须使用 BarTender.Application 处理程序,并且可以从中获取其他处理程序,但我无法在需要时创建任何对象的实例。
  • 您可以尝试使用Variant 作为 BarTender.Messages 看看.invoke 是否有效?
  • Variant msgCol;args[ 3 ] = new Variant( msgCol);
猜你喜欢
  • 2020-02-04
  • 2016-11-07
  • 2021-04-17
  • 1970-01-01
  • 2016-04-25
  • 2021-08-03
  • 2012-02-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多