首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用Delphi实现PDFCreator自动化时带有消息“无效参数数”的PDFCreator

用Delphi实现PDFCreator自动化时带有消息“无效参数数”的PDFCreator
EN

Stack Overflow用户
提问于 2014-09-03 03:42:11
回答 1查看 1.3K关注 0票数 1

我试图使用以下示例代码从Delphi应用程序中自动化PDFCreator:

代码语言:javascript
复制
procedure TForm13.Button1Click(Sender: TObject);
var
  PDFCreatorQueue,
  job: OleVariant;
begin
  PDFCreatorQueue := CreateOleObject('PDFCreatorBeta.JobQueue');

  if not VarIsNull(PDFCreatorQueue)then
  begin
    try
      PDFCreatorQueue.Initialize();
//
//      if not PDFCreatorQueue.WaitForJob(15) then
//        MessageDlg(SPDFCreatorTimeout, mtError, [mbOK], 0)
//      else
//      begin
//        job := PDFCreatorQueue.NextJob();
//        job.ConversionProfileByGuid := 'DefaultGuid';
//        job.ConvertTo(FilePath);
//
//        if(not job.IsJobFinished or not job.JobSucceed) then
//          MessageDlg(Format(SPDFCreatorCouldNotConvertFile, [FilePath]), mtError, [mbOK], 0);
//      end;
    finally
      PDFCreatorQueue.ReleaseCom();
    end;
  end
  else
    MessageDlg(SPDFCreatorConnectionError, mtError, [mbOK], 0);
end;

在PDFCreatorQueue.Initialize()行;出现异常:

带有消息“无效参数数”的EOleSysError

PDFCreator端的Initialize方法没有任何参数:

代码语言:javascript
复制
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[Guid("66A9CAB1-404A-4918-8DE2-29C26B9B271E")]
[ProgId("PDFCreatorBeta.JobQueue")]
public class Queue : IQueue
{

...

    /// <summary>
    ///     Initializes the essential components like JobInfoQueue for the COM object
    /// </summary>
    public void Initialize()
    {

我遗漏了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-18 22:05:13

有从Delphi.调用COM的特定行为。

当您实现.net com可见程序集的参数减少方法时

代码语言:javascript
复制
class CShaprClass
{
  Initialize();
}

当您在Delphi代码中调用这样的参数less方法时:

代码语言:javascript
复制
  PDFCreatorQueue.Initialize();

您将得到无效的参数错误。德尔菲在此调用方法中,转录通知COM将发送参数。

你应该打电话

代码语言:javascript
复制
  PDFCreatorQueue.Initialize;
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25635859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档