打印机没提供相应的DLL和SDK, job_info_*,和 printer_into_*两个结构都试过了,返回的 status 都不对,缺纸状态下,都取不到正确值
获得缺纸等信息,通过安装在XP的打印机驱动可能获得不了,只有通过直接向打印机的串口或并口(有些打印机是并口,有些是串口)发送打印机命令(也就是串口编程或者并口编程),然后打印机会返回相关的信息,通常为十六进制字节信息,然后根据这个信息,来判断打印机的状态。对于USB打印机,我觉得不存在两段都是USB的打印机,可能跟电脑连接端是USB ,打印机端直接连。 这样的话,你只好分别用串口或者并口编程试一试了。Windows API 好像没有检测打印机缺纸缺墨的东西,但是可能有检测打印机是否连接的API
用TPrinter类能通过异常信息知道是否安装打印机或者打印机故障 Use TPrinter to manage any printing performed by an application. Obtain an instance of TPrinter by calling the Printer function in the Printers unit. To determine how the printed image of the form appears, use the PrintScale property of a TForm component. A print job is started by a call to BeginDoc. The application sends commands by rendering through a Text variable or the printer’s canvas. You can move to a new page by calling the NewPage method. The job stays open until the application calls EndDoc. If a problem occurs and you need to terminate a print job that was not sent to the printer successfully, call the Abort method. Use the TPrinter properties to configure the print job. For example, the title displayed in the Print Manager (and on network header pages) is determined by the Title property. Copies determines the number of copies to print, and Orientation lets you specify whether to print in portrait or landscape mode. TPrinter includes several read-only properties as well, that let you determine which page is currently being printed, the fonts available on the printer, the paper size, and so on.
function TestPrinterStatus(LPTPort: Word): Byte; var Status: byte; CheckLPT: word; begin Status := 0; if (LPTPort >= 1) and (LPTPort <= 3) then begin CheckLPT := LPTPort - 1; asm mov dx, CheckLPT; mov al, 0; mov ah, 2; int 17h; mov &Status, ah; end; end; Result := Status; end;{ Pass in the LPT port number you want to check & get the following back: 01h - Timeout 08h - I/O Error 10h - Printer selected 20h - Out of paper 40h - Printer acknowledgement 80h - Printer not busy (0 if busy) Note: This function doesn't work under NT, it gives an access violation from the DOS interrupt call. }
job_info_*,和 printer_into_*两个结构都试过了,返回的 status 都不对,缺纸状态下,都取不到正确值
这样的话,你只好分别用串口或者并口编程试一试了。Windows API 好像没有检测打印机缺纸缺墨的东西,但是可能有检测打印机是否连接的API
var
Status: byte;
CheckLPT: word;
begin
Status := 0;
if (LPTPort >= 1) and (LPTPort <= 3) then
begin
CheckLPT := LPTPort - 1;
asm
mov dx, CheckLPT;
mov al, 0;
mov ah, 2;
int 17h;
mov &Status, ah;
end;
end;
Result := Status;
end;{
Pass in the LPT port number you want to check & get the following back:
01h - Timeout
08h - I/O Error
10h - Printer selected
20h - Out of paper
40h - Printer acknowledgement
80h - Printer not busy (0 if busy)
Note:
This
function doesn't work under NT, it gives an access violation
from the DOS interrupt call.
}
要不你与epson联系一下
就说你有多大多大的量
VB代码,有检测打印机是否离线以及是否有纸张等