zoukankan      html  css  js  c++  java
  • 监控打印机

    uses Winapi.WinSpool;

    procedure TForm1.Button1Click(Sender: TObject);
    var
    pi2: PRINTER_INFO_2;
    hPrinter: THandle;
    Jobs: array [0 .. 1000] of TJobInfo2;
    BytesNeeded, NumJobs: Dword;
    begin
    pi2.pPrinterName := 'Microsoft XPS Document Writer';
    if OpenPrinter(pi2.pPrinterName, hPrinter, 0) then
    begin
    while true do
    begin
    WaitForPrinterChange(hPrinter, PRINTER_CHANGE_ADD_JOB);
    if EnumJobs(hPrinter, 0, 1000, 2, @Jobs, SizeOf(Jobs), BytesNeeded,
    NumJobs) then
    begin
    if NumJobs <> 0 then
    begin
    with Jobs[NumJobs - 1] do
    showmessage(StrPas(pUserName) + StrPas(pMachineName) +
    StrPas(pDocument));
    end;
    end;
    end;
    end;
    end;

    可监控的打印机状态参数记录:

    _JOB_INFO_2W = record
    JobId: DWORD;
    pPrinterName: LPWSTR;
    pMachineName: LPWSTR;
    pUserName: LPWSTR;
    pDocument: LPWSTR;
    pNotifyName: LPWSTR;
    pDatatype: LPWSTR;
    pPrintProcessor: LPWSTR;
    pParameters: LPWSTR;
    pDriverName: LPWSTR;
    pDevMode: PDeviceModeW;
    pStatus: LPWSTR;
    pSecurityDescriptor: PSECURITY_DESCRIPTOR;
    Status: DWORD;
    Priority: DWORD;
    Position: DWORD;
    StartTime: DWORD;
    UntilTime: DWORD;
    TotalPages: DWORD;
    Size: DWORD;
    Submitted: TSystemTime; { Time the job was spooled }
    Time: DWORD; { How many seconds the job has been printing }
    PagesPrinted: DWORD;
    end;

  • 相关阅读:
    Unity SceneManager 对场景的操作
    Unity [Tooltip("")]
    Unity WWW下载图片并保存到Unity的Assets下
    C# 集合
    C# 枚举与switch用法
    C# String.Format方法
    C# Thread类 线程优先级
    Unity Gizmos可视化辅助工具
    anacanda
    异常和错误
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/4447758.html
Copyright © 2011-2022 走看看