如何检测打印机是否安装(50分)

  • 主题发起人 主题发起人 老桑
  • 开始时间 开始时间

老桑

Unregistered / Unconfirmed
GUEST, unregistred user!
我想用程序检测打印机是否安装,如安装打印操作继续,否则提示,但不知如何编写检测程序<br>请各位大虾 帮帮忙
 
uses Printers;<br><br>if Printer.Printers.Count=0 then<br>&nbsp; &nbsp; ShowMessage('请首先安装打印机')<br>else<br>&nbsp; ......
 
var fdevice:pchar;<br>&nbsp; &nbsp; fdriver:pchar;<br>&nbsp; &nbsp; fport:pchar;<br>&nbsp; &nbsp; fhandle:thandle;<br>&nbsp; &nbsp;currentprintername:string;<br>begin<br>&nbsp; &nbsp;getmem(fdevice,255);<br>&nbsp; &nbsp;getmem(fdriver,255);<br>&nbsp; &nbsp;getmem(fport,255);<br>&nbsp;printer.getprinter(fdevice,fdriver,fport,fhandle);<br>&nbsp; currentprintername:=fdevice;<br>&nbsp; if fdevice&lt;&gt;nil then freemem(fdevice,255);<br>&nbsp; if fdriver&lt;&gt;nil then freemem(fdriver,255);<br>&nbsp; if fport&lt;&gt;nil then freemem(fport,255);<br>&nbsp; if currentprintername='' then <br>&nbsp; messagedlg('你尚未安装打印机驱动程序。',mterror,[mbok],0);<br>end;
 
vgvanxk:你写的太复杂了,不过你能把程序注释一下也不错,可能在其他地方用的上<br>
 
后退
顶部