我试图使用以下示例代码从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()
{我遗漏了什么?
发布于 2017-03-18 22:05:13
有从Delphi.调用COM的特定行为。
当您实现.net com可见程序集的参数减少方法时
class CShaprClass
{
Initialize();
}当您在Delphi代码中调用这样的参数less方法时:
PDFCreatorQueue.Initialize();您将得到无效的参数错误。德尔菲在此调用方法中,转录通知COM将发送参数。
你应该打电话
PDFCreatorQueue.Initialize;https://stackoverflow.com/questions/25635859
复制相似问题