⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spyprintermainu.pas

📁 Monitor local printer activities
💻 PAS
字号:
unit SpyPrinterMainU;
{$I JEDI.INC}

interface

uses
  Windows, Messages, SysUtils,
  {$IFDEF DELPHI6_UP} Variants, {$ENDIF}
  Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, PBPrintersMonitorU;

Type
  TForm1 = class(TForm)
    ListView1: TListView;
    procedure FormCreate(Sender: TObject);
  private
    FMonitor: TPBPrintersMonitor;
    Procedure JobNotification( const jobinfo: TPBJobInformation );
  public
  end;

var
  Form1: TForm1;

implementation

uses typinfo, printers;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  FMonitor:= TPBPrintersMonitor.Create( self );
 // FMonitor.OnNewJob := JobNotification;
 // FMonitor.OnJobChange := JobNotification;
  FMonitor.OnJobComplete := JobNotification;
  FMonitor.Active := true;
  Align := alTop;
end;

procedure TForm1.JobNotification(const jobinfo: TPBJobInformation);
const
  orientations: Array [TPrinterOrientation] Of  String =
    ('Portrait', 'Landscape');
var
  item: TListitem;
begin
  listview1.Items.BeginUpdate;
  Try
    item:= listview1.Items.Add;
    item.Caption := FormatDateTime('yyyy-mm-dd', Date );
    item.SubItems.Add( FormatDateTime( 'hh:nn:ss:zzz', Time ));
    item.SubItems.Add( GetEnumName( Typeinfo( TPBJobStatus), Ord( jobinfo.Status)));
    item.SubItems.Add( IntToStr( jobinfo.JobID ));
    item.SubItems.Add( jobinfo.Computer );
    item.SubItems.Add( jobinfo.User );
    item.SubItems.Add( jobinfo.PrinterName );
    item.SubItems.Add( jobinfo.Document );
    item.SubItems.Add( IntToStr( jobinfo.Pages ));
    item.SubItems.Add( IntToStr( jobinfo.BytesPrinted ));
    item.SubItems.Add( IntToStr( jobinfo.TotalPages ));
    item.SubItems.Add( IntToStr( jobinfo.TotalBytes ));
    item.Subitems.Add( IntToStr( jobinfo.Copies ));
    item.Subitems.Add( orientations[ jobinfo.Orientation ]
    );
  Finally
    listview1.Items.EndUpdate;
  End; { Finally }
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -