获取传真作业状态

时间:2014-07-05 03:24:56

标签: delphi winfax

我已尝试使用以下代码发送传真:

uses
  ComObj, ActiveX, FAXCOMEXLib_TLB;

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  JobIDs: OleVariant;
  FaxServer: IFaxServer2;
  FaxDocument: IFaxDocument2;
begin
  try
    FaxServer := CoFaxServer.Create;
    FaxServer.Connect('');
    FaxDocument := CoFaxDocument.Create;
    FaxDocument.Body := 'd:\Document.pdf';
    FaxDocument.DocumentName := 'Document name';
    FaxDocument.Recipients.Add('+1 (425) 555-4567', 'Bill');
    FaxDocument.Sender.Name := 'Bob';
    FaxDocument.Sender.BillingCode := '23A54';
    FaxDocument.Sender.Department := 'Accts Payable';
    FaxDocument.Sender.FaxNumber := '+972 (4) 555-9070';
    JobIDs := FaxDocument.ConnectedSubmit(FaxServer);

    for I := VarArrayLowBound(JobIDs, 1) to VarArrayHighBound(JobIDs, 1) do
      ShowMessage('Job ID: ' + VarArrayGet(JobIDs, [I]));
  except
    on E: EOleSysError do
      ShowMessage(
        Format('Sending of the fax failed! %s [%d]', [E.Message, E.ErrorCode])
      );
  end;
end;

我要做的是获取发送传真的作业状态。我试图添加

var
  FaxJobStatus: IFaxJobStatus;
.....

FaxJobStatus := CoFaxJobStatus.Create;

编译了源代码并发现没有错误,但在执行代码后,它失败了     FaxJobStatus:= CoFaxJobStatus.Create 说“班级未注册”。

1 个答案:

答案 0 :(得分:1)

来自IFaxJobStatus documentation

  

您不创建FaxJobStatus对象。当您实现IFaxServerNotify :: OnIncomingJobChanged或IFaxServerNotify :: OnOutgoingJobChanged时,它会作为通知的一部分收到,其中包含FaxJobStatus类型的参数。当事件发生并且调用实现的函数时,您将收到包含动态信息的此对象。

因此,您必须注册IFaxServerNotify.OnIncomingJobChangedIFaxServerNotify.OnOutgoingJobChanged个活动。收到事件后,您将获得FaxJobStatus对象,并可以读取其Status属性。

相关问题