Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有消息的EOleSysError';参数数量无效';从Delphi应用程序自动化PDFCreator时_Delphi_Automation_Ole - Fatal编程技术网

带有消息的EOleSysError';参数数量无效';从Delphi应用程序自动化PDFCreator时

带有消息的EOleSysError';参数数量无效';从Delphi应用程序自动化PDFCreator时,delphi,automation,ole,Delphi,Automation,Ole,我正尝试使用以下示例代码从Delphi应用程序中自动化PDFCreator: procedure TForm13.Button1Click(Sender: TObject); var PDFCreatorQueue, job: OleVariant; begin PDFCreatorQueue := CreateOleObject('PDFCreatorBeta.JobQueue'); if not VarIsNull(PDFCreatorQueue)then begin

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

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没有任何参数:

[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()
    {
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[Guid(“66A9CAB1-404A-4918-8DE2-29C26B9B271E”)]
[ProgId(“PDFCreatorBeta.JobQueue”)]
公共类队列:IQueue
{
...
/// 
///初始化COM对象的基本组件,如JobInfoQueue
/// 
公共无效初始化()
{

我遗漏了什么?

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

实现.net com可见程序集的无参数方法时

class CShaprClass
{
  Initialize();
}
在Delphi代码中调用此类无参数方法时:

  PDFCreatorQueue.Initialize();
您将得到无效的参数错误。 Delphi在此调用方法中通知将发送参数的COM

你应该打电话

  PDFCreatorQueue.Initialize;

你有PDFCreator的TypeLib导入单元吗?我没有,但是源代码可以在以下地址找到:对不起,我在那里看不到任何源代码的迹象,只有各种PDFCreator和PDFCreatorBeta可执行文件。在任何情况下,TypeLib导入单元通常是你通过运行Delphi wizar在Delphi内部创建的在.TLB、.OCX、.DLL或更罕见的.Exe文件上运行。我无法运行向导(在D7或XE6中)针对PdfCreator 1.7*或1.9*文件,fwiw。奇怪的是,谷歌发现了一些成功人士的消息,但据我所知,这些消息只出现在早期版本上。顺便说一句,你使用的是什么Delphi版本?顺便说一句,我不确定你是否知道,但制作Delphi导入单元的一个要点是它告诉你没有每个类的方法都需要参数。显示的代码显然是来自pdfCreator某些元素的c#源代码。pdfCreator注册的唯一接口是AxPdfReader ActiveX,因此这显然不是包的标准COM接口。在我看来,您应该做的是构建pdfCreator,然后导入将相关dll设置为.NET程序集.RAD studio菜单“组件\导入组件”,选择.NET程序集,然后通过直接引用潜在地添加相关dll。