请问:delphi 如何获取打印机的作业记录?

litterant 2016-06-13 08:46:35
各位大侠:
您们好!
请问:在delphi中 如何获取打印机的作业记录(如:打印的文件名称、所有者、页数、结果或状态、完成日期、计算机IP等)?
谢谢!
...全文
245 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
litterant 2016-06-15
  • 打赏
  • 举报
回复
谢谢  mdejtod
lyhoo163 2016-06-15
  • 打赏
  • 举报
回复
引用 2 楼 mdejtod 的回复:

uses winspool,printers;

procedure GetJobsList(PrinterName: String; JobList: TStrings);
const
  InfoLevel = 1;
  FirstJob = 0;
  LastJob = 19;
var
  Jobs: array [FirstJob..LastJob] of TJobInfo1;
  PrinterHandle, BytesNeeded, I, NumJobs:cardinal;// Integer;
begin
  NumJobs := 0;
  if OpenPrinter(PChar(PrinterName),PrinterHandle,nil) then
  begin
    if EnumJobs(PrinterHandle,FirstJob,LastJob+1,InfoLevel,@Jobs,SizeOf(Jobs),BytesNeeded,NumJobs) then
    begin
      JobList.Clear;
      if NumJobs = 0 then Exit;
      for I := 0 to NumJobs-1 do
      begin
        JobList.Add( Format('%s(%s)',[StrPas(Jobs[I].pDocument),JobStatusText(Jobs[I].Status)]) );
      end;
    end;
    AbortPrinter  (PrinterHandle);
    ClosePrinter(PrinterHandle);
  end;
end;

顶一下。OK!
jjpweb 2016-06-15
  • 打赏
  • 举报
回复
标记一下下。
mdejtod 2016-06-13
  • 打赏
  • 举报
回复

uses winspool,printers;

procedure GetJobsList(PrinterName: String; JobList: TStrings);
const
  InfoLevel = 1;
  FirstJob = 0;
  LastJob = 19;
var
  Jobs: array [FirstJob..LastJob] of TJobInfo1;
  PrinterHandle, BytesNeeded, I, NumJobs:cardinal;// Integer;
begin
  NumJobs := 0;
  if OpenPrinter(PChar(PrinterName),PrinterHandle,nil) then
  begin
    if EnumJobs(PrinterHandle,FirstJob,LastJob+1,InfoLevel,@Jobs,SizeOf(Jobs),BytesNeeded,NumJobs) then
    begin
      JobList.Clear;
      if NumJobs = 0 then Exit;
      for I := 0 to NumJobs-1 do
      begin
        JobList.Add( Format('%s(%s)',[StrPas(Jobs[I].pDocument),JobStatusText(Jobs[I].Status)]) );
      end;
    end;
    AbortPrinter  (PrinterHandle);
    ClosePrinter(PrinterHandle);
  end;
end;

litterant 2016-06-13
  • 打赏
  • 举报
回复
自已顶下,有知道的吗?

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧