Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete job from spooler

16 views
Skip to first unread message

Alex Leiva

unread,
Nov 5, 2004, 7:27:08 AM11/5/04
to
Hi everybody!

How can I delete a job from printer spooler?

Please, I need it urgently!

Thanks


Peter Below (TeamB)

unread,
Nov 5, 2004, 4:03:19 PM11/5/04
to
In article <418b...@newsgroups.borland.com>, Alex Leiva wrote:
> How can I delete a job from printer spooler?
>
Uses Winspool, printers;

{-- GetCurrentPrinterHandle
-------------------------------------------}
{: Retrieves the handle of the current printer
@Returns an API printer handle for the current printer
@Desc Uses WinSpool.OpenPrinter to get a printer handle. The caller
takes ownership of the handle and <b>must</b> call ClosePrinter on it
once the handle is no longer needed. Failing to do that creates a
serious resource leak! <P>
Requires Printers and WinSpool in the Uses clause.
@Raises EWin32Error if the OpenPrinter call fails.
}{ Created 30.9.2000 by P. Below
-----------------------------------------------------------------------
}
Function GetCurrentPrinterHandle: THandle;
Const
Defaults: TPrinterDefaults = (
pDatatype : nil;
pDevMode : nil;
DesiredAccess : PRINTER_ACCESS_USE or PRINTER_ACCESS_ADMINISTER
);
Var
Device, Driver, Port : array[0..255] of char;
hDeviceMode: THandle;
Begin { GetCurrentPrinterHandle }
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
If not OpenPrinter(@Device, Result, @Defaults) Then
RaiseLastWin32Error;
End; { GetCurrentPrinterHandle }

{: Kill all pending jobs on the current printer }
Procedure PurgeJobsOnCurrentPrinter;
Var
hPrinter: THandle;
Begin
hPrinter:= GetCurrentPrinterHandle;
try
If not WinSpool.SetPrinter( hPrinter, 0, nil,
PRINTER_CONTROL_PURGE )
Then
RaiseLastWin32Error;
finally
ClosePrinter( hPrinter );
end;
End; { PurgeJobsOnCurrentPrinter }

That will kill all jobs for the printer. If you need to be more
specific look at the API functions EnumJobs, which allows you to
enumerate the jobs in the printer queue, and SetJob, which allows you
to change a jobs status, even cancel it. If you need examples for
these routines, search the newsgroup archives.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


0 new messages