Link to home
Start Free TrialLog in
Avatar of Remmie26
Remmie26Flag for United States of America

asked on

find out when a job have finished printing

Hi, I have a list of document  in a loop to be sent to the a selected printer, How do I  pause the loop execution until the prior document has completed the printing process.
Avatar of Geert G
Geert G
Flag of Belgium image

function GetPrinterTasks(PrinterName: string): Integer;
var
  AHandle: THandle;
  NumJobs, DataSize: Cardinal;
begin
  Result := 0;
  if PrinterName <> '' then
  try
    if OpenPrinter(PChar(PrinterName), AHandle, nil) then
    try
      EnumJobs(AHandle, 0, 5000, 2, nil, 0, DataSize, NumJobs);
      if (NumJobs = 0) and (DataSize <> 0) then
        NumJobs := DataSize div 1048
    finally
      ClosePrinter(AHandle);
    end;
    Result := NumJobs;
  except
    // Catch errors
  end;
end;
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial