如何取的打印机的状态(80分)

  • 主题发起人 主题发起人 jobsxy
  • 开始时间 开始时间
J

jobsxy

Unregistered / Unconfirmed
GUEST, unregistred user!
如:正在打印,暂停,故障,结束,等待
 
刚在bbs站 210.32.151.66 上看到一篇内容, 具体如何没试过, 转录如下:<br><br>&nbsp;作者 &nbsp;function (function) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;看板 &nbsp;Delphi<br>&nbsp;标题 &nbsp;Re: 请问各位大虾如何在Delphi里判断打印机异常?<br>&nbsp;时间 &nbsp;Mon Sep &nbsp;6 14:36:16 1999<br>———————————————————————————————————————<br><br>※ 引述《steel (天空)》之铭言:<br>&gt; &nbsp; 1.如何判断系统有无安装打印机<br>&gt; &nbsp; 2.如何判断打印机与系统连接不正常<br><br><br>系统有一个预定义实例Printer:TPrinter. 可用这个实例来查询系统的打印机,<br>操作很简单,看一下帮助就可以了.<br>--<br>※ Origin: 笑 书 亭 &lt;bbs.zd.dhs.org&gt;<br>◆ From: 210.32.132.214 &nbsp; &nbsp;
 
Printer我实过没有用,无法判断暂停和故障
 
1. printer.Aborted, printer.Printing.<br>or<br>2. use getprinter api with PRINTER_INFO_2 structure as parameter.<br>in PRINTER_INFO_2.State indicate the state of the current printer.
 
用GetPrinter 得到PRINTER_INFO_2,<br>PRINTER_INFO_2.Status :<br>&nbsp;Windows NT: <br>&nbsp; &nbsp;PRINTER_STATUS_PAUSED<br>&nbsp; &nbsp;PRINTER_STATUS_PENDING_DELETION <br>&nbsp;Windows 95: <br>&nbsp; &nbsp;PRINTER_STATUS_BUSY<br>&nbsp; &nbsp;PRINTER_STATUS_DOOR_OPEN<br>&nbsp; &nbsp;PRINTER_STATUS_ERROR<br>&nbsp; &nbsp;PRINTER_STATUS_INITIALIZING<br>&nbsp; &nbsp;PRINTER_STATUS_IO_ACTIVE<br>&nbsp; &nbsp;PRINTER_STATUS_MANUAL_FEED<br>&nbsp; &nbsp;PRINTER_STATUS_NO_TONER<br>&nbsp; &nbsp;PRINTER_STATUS_NOT_AVAILABLE<br>&nbsp; &nbsp;PRINTER_STATUS_OFFLINE<br>&nbsp; &nbsp;PRINTER_STATUS_OUT_OF_MEMORY<br>&nbsp; &nbsp;PRINTER_STATUS_OUTPUT_BIN_FULL<br>&nbsp; &nbsp;PRINTER_STATUS_PAGE_PUNT<br>&nbsp; &nbsp;PRINTER_STATUS_PAPER_JAM<br>&nbsp; &nbsp;PRINTER_STATUS_PAPER_OUT<br>&nbsp; &nbsp;PRINTER_STATUS_PAPER_PROBLEM<br>&nbsp; &nbsp;PRINTER_STATUS_PAUSED<br>&nbsp; &nbsp;PRINTER_STATUS_PENDING_DELETION<br>&nbsp; &nbsp;PRINTER_STATUS_PRINTING<br>&nbsp; &nbsp;PRINTER_STATUS_PROCESSING<br>&nbsp; &nbsp;PRINTER_STATUS_TONER_LOW<br>&nbsp; &nbsp;PRINTER_STATUS_UNAVAILABLE<br>&nbsp; &nbsp;PRINTER_STATUS_USER_INTERVENTION<br>&nbsp; &nbsp;PRINTER_STATUS_WAITING<br>&nbsp; &nbsp;PRINTER_STATUS_WARMING_UP <br>
 
cytown: "GetPrinter"这个API函数怎么用?给个例子好吗,我对C不太熟
 
var<br>&nbsp; pinfo: pPRINTERINFO2;<br>&nbsp; pprt,a: Cardinal;<br>&nbsp; b:PDWORD;<br>begin<br>&nbsp; b:=allocmem(256);<br>&nbsp; pinfo:=AllocMem(1000);<br>&nbsp; if OpenPrinter('HP DJ 200',pprt,nil) then<br>&nbsp; begin<br>&nbsp; &nbsp; a:=1000;<br>&nbsp; &nbsp; if getprinter(pprt,2,pinfo,a,b) then<br>&nbsp; &nbsp; &nbsp; showmessage(pinfo.pPrinterName+' ststus:'+inttostr(pinfo.Status));<br>&nbsp; ClosePrinter(pprt);<br>&nbsp; end;<br>&nbsp; <br>&nbsp; freemem(b);<br>&nbsp; freemem(pinfo);<br>end;<br>
 
sorry,Cytown:<br><br>&nbsp; 您给我的例子中的<br>&nbsp; if OpenPrinter('HP DJ 200',PPRT,NILL) then<br>&nbsp; 编译不通过, 出错信息如下:<br>&nbsp; Types of actual and formal var parameters must be identical<br><br>苦思瞑想几天,任不得其解, 麻烦再HELP ME, 会不会是编译开关的问题?<br>我用的是WIN97+DELPHI3.0<br><br>
 
d3?<br>也许是openprinter定义中第二个参数类型是integer or THandle吧?(没有d3,无法测试).<br>总之不是cardinal. var传递参数要求类型精确匹配(编译器认为Cardinal和THandle或<br>Integer是不同类型 %$@#~&amp;*). 把定义里改掉即可(改成Integer或THandle).
 
换D4吧, D5都快可以用了(2个SP以后):-)
 
OK,照Another_eYes的方法改动之后就好了,我就不明白DELPHI干吗这么烦,<br>许多人都说它比VB功能强大,比VC简单易学;但换个说法却是比VB难学,比VC<br>功能弱,有时候真得挺羡慕玩VB的家伙,VB的简单易学是众口一词,DELPHI<br>的功能强大?不一定,只能说DELPHI的再生能力强,可我们哪有时间构造自<br>己的库。只能怪自己站错队伍。<br>&nbsp; &nbsp;<br>
 
呵呵, 是这样的, DELPHI可以调用WINAPI, 而VB只支持一些, 你可以试试用VB写<br>上面的程序, 会累吐血的:-)<br>
 
后退
顶部