Grupy dyskusyjne Google nie obsługują już nowych postów ani subskrypcji z Usenetu. Treści historyczne nadal będą dostępne.

Delete job from spooler

16 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Alex Leiva

nieprzeczytany,
5 lis 2004, 07:27:085.11.2004
do
Hi everybody!

How can I delete a job from printer spooler?

Please, I need it urgently!

Thanks


Peter Below (TeamB)

nieprzeczytany,
5 lis 2004, 16:03:195.11.2004
do
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


Nowe wiadomości: 0