获得打印机的信息

I

import

Unregistered / Unconfirmed
GUEST, post messages is not allowed!
#1
下面的代码可以判断所选打印机是否支持双面打印。如返回值为1,则表示支持双面打
印,返回值为0则表示不支持。
DeviceCapabilitiesA(Device,Port,DC_DVPLEX,nil,nil);
下面的代码可以获得一个打印机最多能复制的份数:
DeviceCapabilitiesA(Device,Port,DC_COPIES,nil,nil);
使用GetDeviceCaps()函数确定所选设备的特定属性。在某些情况下,GetDeviceCaps()将返回所需
要的值。下面的代码以毫米为单位返回打印机设备的宽度:
GetDeviceCaps(Printer.Handle,HORISIZE);
在另一些情况下,GetDeviceCaps()返回一个整数,这个整数经过位屏蔽可以获得打印机的某一性
能。例如,GetDeviceCaps()方法返回这样的整型值:
RCaps:=GetDeviceCaps(Printer.Handle,RASTERCAPS);
然后,通过AND运算符屏蔽出RC_BANDING字段,进而确定打印机是否支持分段打印技术。
(RCapsandRC_BANDING)=RC_BANDING
***************
获取打印机状态信息
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
 
Top Bottom