如何取消印表機佇列中的某一個 job ???? |
答題得分者是:hagar
|
wenjung
一般會員 發表:21 回覆:61 積分:21 註冊:2002-04-29 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
小弟找到一篇是刪除所有 print jobs 的, 參考看看。
不過作者也說 Not Tested!
至於刪除某個 print job 的話, 再找找看吧!
Date: Sat, 22 Sep 2001 11:54:41 0200
Newsgroups: borland.public.delphi.winapi
Subject: Re: Stop printing job.
From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com>
Reply-To: 100113.1101@compuXXserve.com In article <3babfab6_1@dnews>, Samson Fu wrote:
> We can stop and delete current printing job from "Printer manager".
> Can I do it in my code? I want to STOP all "print jobs" and Delete
> them in my program. Try the PurgeJobsOnCurrentPrinter procedure given below. Not tested! 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 must call
ClosePrinter on it once the handle is no longer needed.
Failing to do that creates a serious resource leak!
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 }Peter Below (TeamB) 100113.1101@compuserve.com) -- Everything I say is a lie. |
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |