谁有验证通过的获取打印机状态的代码? (300分)

  • 主题发起人 主题发起人 yczjs
  • 开始时间 开始时间
Y

yczjs

Unregistered / Unconfirmed
GUEST, unregistred user!
由于偶手头没有打印机,没法测试,所以....
 
原来研究了很长时间,网上也有很多汇编写的SOURCE,不过都不成,看来是要泡汤了[:(!]
 
var
Device:Array[0..256] of Char;
Driver:Array[0..256] of Char;
Port:Array[0..32] of Char;
hDMode:THandle;
regist:TRegistry;
begin
Printer.PrinterIndex:=Printer.Printers.IndexOf(Printer.Printers);
Printer.GetPrinter(Device,Driver,Port,hDMode);
regist:=Tregistry.Create;
with registdo
begin
RootKey:=HKEY_LOCAL_MACHINE;//设置根键值为HKEY_LOCAL_MACHINE
try
if OSVersion=0 then
begin
if OpenKey('SYSTEM/CurrentControlSet/Control/Print/Printers/'
+Device,False) then
begin
showmessage(Driver);
if (ReadInteger('Attributes')=64) or (ReadInteger('Attributes')=80) then
showmessage('后台打印')
else
showmessage('直接打印到打印机');
end;
end
else
begin
if OpenKey('SYSTEM/CurrentControlSet/Control/Print/Printers/'
+Device+'/DsSpooler',False) then
begin
SubItems.Add(Driver);
if ReadString('printSpooling')='PrintAfterSpooled' then
showmessage('后台打印')
else
showmessage('直接打印到打印机');
end;
end;
except//不是可用的打印机
showmessage('不可用');
end;
end;
CloseKey;
end;
regist.Free;
end;
 
to delphiroad:
是打印机状态呀
 
COPY一段,没打印机,所以没测试过
var
pinfo: pPRINTERINFO2;

pprt a: Cardinal;

b:PDWORD;

begin

b:=allocmem(256);

pinfo:=AllocMem(1000);

if OpenPrinter('HP DJ 200' pprt nil) then

begin

a:=1000;

if getprinter(pprt 2 pinfo a b) then

showmessage(pinfo.pPrinterName+' ststus:'+inttostr(pinfo.Status));

ClosePrinter(pprt);

end;

freemem(b);

freemem(pinfo);

end;

PRINTER_INFO_2.Status :
Windows NT:
PRINTER_STATUS_PAUSED
PRINTER_STATUS_PENDING_DELETION
Windows 95:
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_UNAVAILABLE
PRINTER_STATUS_USER_INTERVENTION
PRINTER_STATUS_WAITING
PRINTER_STATUS_WARMING_UP
 
如何得到当前的打印机状态?
http://www.delphibbs.com/delphibbs/dispq.asp?lid=64852
如何查询打印机状态?
http://www.delphibbs.com/delphibbs/dispq.asp?lid=232399
 
谢谢大家,请有打印机的朋友帮个忙,验证一下
哎,偶穷没打印机测试啊
 
:( 上边的几个code,由原来都试过了,就是没发现能用的,希望那位大侠给......
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
875
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
1K
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部