線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3797
推到 Plurk!
推到 Facebook!

請問如何在印QuickRep前偵測印表機的狀態?

尚未結案
cutena
一般會員


發表:11
回覆:10
積分:4
註冊:2006-08-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-02-27 13:02:23 IP:59.125.xxx.xxx 訂閱
各位前輩你好~
請問如何在印QuickRep前偵測印表機的狀態?
像是有無預設印表機?印表機未開?印表機無紙張?....

感謝各位指教~
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-02-27 13:30:59 IP:59.124.xxx.xxx 未訂閱
http://delphi.ktop.com.tw/board.php?cid=30&fid=73&tid=62643

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20874844.html?qid=20874844


uses WinSpool, Printers

<textarea class="delphi" rows="10" cols="60" name="code">function TfrmMain.PrinterStatus(MyPrinterName:string):integer; var PrinterName: string; szPrinterName: array[0 .. 127] of char; pPrinter: array[0 .. 19] of TPrinterInfo2;//PRINTER_INFO_2A; //20 is a guess pcReturned, pcbNeeded: DWORD; l: integer; pBuffer: pointer; begin l:= 0; //MyPrinterName:='hp laserjet iiid'; EnumPrinters(PRINTER_ENUM_NAME, // types of printer objects to enumerate nil, //PChar(MyPrinterName), // name of printer object 2, // specifies type of printer info structure nil, // pointer to buffer to receive printer info structures 0, // we use 0 so that Windows tells us how big a buffer it wants pcbNeeded, // pointer to variable with no. of bytes copied (or required) pcReturned // pointer to variable with no. of printer info. structures copied ); GetMem(pBuffer,pcbNeeded); //create a buffer of the required size fillchar(pBuffer^,pcbNeeded,0); EnumPrinters(PRINTER_ENUM_NAME, //now we read the printer list nil, 2, pBuffer, pcbNeeded, // this is the real size, in bytes, of buffer pcbNeeded, pcReturned ); //now we copy that part of the buffer that we are interested in to our array system.move(pBuffer^,pPrinter,pcReturned*sizeof(TPrinterInfo2)); // Find my printer for l:= 0 to pcReturned - 1 do begin if l > 3 then ShowMessage('Value l: ' IntToStr(l)); PrinterName:= string(pPrinter[l].pPrinterName); if UpperCase(PrinterName) = UpperCase(MyPrinterName) then begin Result:= pPrinter[l].Status; {either 0 or one of the following PRINTER_STATUS_BUSY PRINTER_STATUS_DOOR_OPEN PRINTER_STATUS_ERROR PRINTER_STATUS_INITIALIZING PRINTER_STATUS_IO_ACTIVE PRINTER_STATUS_MANUAL_FEED PRINTER_STATUS_NO_TONER PRINTER_STATUS_NOT_AVAILABLE PRINTER_STATUS_OFFLINE PRINTER_STATUS_OUT_OF_MEMORY PRINTER_STATUS_OUTPUT_BIN_FULL PRINTER_STATUS_PAGE_PUNT PRINTER_STATUS_PAPER_JAM PRINTER_STATUS_PAPER_OUT PRINTER_STATUS_PAPER_PROBLEM PRINTER_STATUS_PAUSED PRINTER_STATUS_PENDING_DELETION PRINTER_STATUS_PRINTING PRINTER_STATUS_PROCESSING PRINTER_STATUS_TONER_LOW PRINTER_STATUS_USER_INTERVENTION PRINTER_STATUS_WAITING PRINTER_STATUS_WARMING_UP } break; end; end; FreeMem(pBuffer,pcbNeeded); end; </textarea><font face="Courier New">


Fishman
------
Fishman
cutena
一般會員


發表:11
回覆:10
積分:4
註冊:2006-08-16

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-03-01 09:12:48 IP:59.125.xxx.xxx 訂閱
前輩你好~
非常感謝您的大力幫忙~
不過資質愚笨的我還是想請您能否多些註解?(最好可以來中文的..)讓自己可以多些了解~
另外想請問為何 if l > 3 then
要秀 ShowMessage('Value l: ' IntToStr(l)); ??
您Mark {either 0 or one of the following
PRINTER_STATUS_BUSY........
} 這一段
是代表什麼意義呢??
Result:= pPrinter[l].Status; 其回傳值又是什麼意思呢?
....

真是要麻煩你了~感恩哪~
如果問題太蠢..請見諒..
Louis_H
一般會員


發表:7
回覆:18
積分:5
註冊:2005-10-07

發送簡訊給我
#4 引用回覆 回覆 發表時間:2012-08-06 15:01:56 IP:59.120.xxx.xxx 訂閱
請教一下, 目前小弟使用 BCB 6 開發..
下列 Delphi 偵測印表機狀態的 方式如何變更成於 BCB 6 上面可執行程序碼 ?
請高手們協助一下 !! 感謝 !!

===================引 用 Fishman 文 章===================
http://delphi.ktop.com.tw/board.php?cid=30&fid=73&tid=62643

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20874844.html?qid=20874844


uses WinSpool, Printers

<textarea class="delphi" rows="10" cols="60" name="code">function TfrmMain.PrinterStatus(MyPrinterName:string):integer; var PrinterName: string; szPrinterName: array[0 .. 127] of char; pPrinter: array[0 .. 19] of TPrinterInfo2;//PRINTER_INFO_2A; //20 is a guess pcReturned, pcbNeeded: DWORD; l: integer; pBuffer: pointer; begin l:= 0; //MyPrinterName:='hp laserjet iiid'; EnumPrinters(PRINTER_ENUM_NAME, // types of printer objects to enumerate nil, //PChar(MyPrinterName), // name of printer object 2, // specifies type of printer info structure nil, // pointer to buffer to receive printer info structures 0, // we use 0 so that Windows tells us how big a buffer it wants pcbNeeded, // pointer to variable with no. of bytes copied (or required) pcReturned // pointer to variable with no. of printer info. structures copied ); GetMem(pBuffer,pcbNeeded); //create a buffer of the required size fillchar(pBuffer^,pcbNeeded,0); EnumPrinters(PRINTER_ENUM_NAME, //now we read the printer list nil, 2, pBuffer, pcbNeeded, // this is the real size, in bytes, of buffer pcbNeeded, pcReturned ); //now we copy that part of the buffer that we are interested in to our array system.move(pBuffer^,pPrinter,pcReturned*sizeof(TPrinterInfo2)); // Find my printer for l:= 0 to pcReturned - 1 do begin if l > 3 then ShowMessage('Value l: ' IntToStr(l)); PrinterName:= string(pPrinter[l].pPrinterName); if UpperCase(PrinterName) = UpperCase(MyPrinterName) then begin Result:= pPrinter[l].Status; {either 0 or one of the following PRINTER_STATUS_BUSY PRINTER_STATUS_DOOR_OPEN PRINTER_STATUS_ERROR PRINTER_STATUS_INITIALIZING PRINTER_STATUS_IO_ACTIVE PRINTER_STATUS_MANUAL_FEED PRINTER_STATUS_NO_TONER PRINTER_STATUS_NOT_AVAILABLE PRINTER_STATUS_OFFLINE PRINTER_STATUS_OUT_OF_MEMORY PRINTER_STATUS_OUTPUT_BIN_FULL PRINTER_STATUS_PAGE_PUNT PRINTER_STATUS_PAPER_JAM PRINTER_STATUS_PAPER_OUT PRINTER_STATUS_PAPER_PROBLEM PRINTER_STATUS_PAUSED PRINTER_STATUS_PENDING_DELETION PRINTER_STATUS_PRINTING PRINTER_STATUS_PROCESSING PRINTER_STATUS_TONER_LOW PRINTER_STATUS_USER_INTERVENTION PRINTER_STATUS_WAITING PRINTER_STATUS_WARMING_UP } break; end; end; FreeMem(pBuffer,pcbNeeded); end; </textarea><font face="Courier New">


Fishman
系統時間:2017-10-17 17:32:18
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!