试一下下面的 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; 参数是打印机端口,返回值如下: 01h - Timeout 08h - I/O Error 10h - Printer selected 20h - Out of paper 40h - Printer acknowledgement 80h - Printer not busy (0 if busy) ----------- function GetPrinterStatus:byte; asm MOV DX,$379; IN AL,DX; end; //获取打印机是否出错 function CheckPrinter:boolean; var temp:byte; begin temp:=GetPrinterStatus; Result:=not ( ((temp and $80)=0) //打印机忙 or ((temp and $20)<>0) //打印机缺纸 or ((temp and $10)=0) //打印机未联机 or ((temp and $08)=0) ); //打印机出错; end;
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;
参数是打印机端口,返回值如下:
01h - Timeout
08h - I/O Error
10h - Printer selected
20h - Out of paper
40h - Printer acknowledgement
80h - Printer not busy (0 if busy)
-----------
function GetPrinterStatus:byte;
asm
MOV DX,$379;
IN AL,DX;
end;
//获取打印机是否出错
function CheckPrinter:boolean;
var
temp:byte;
begin
temp:=GetPrinterStatus;
Result:=not ( ((temp and $80)=0) //打印机忙
or ((temp and $20)<>0) //打印机缺纸
or ((temp and $10)=0) //打印机未联机
or ((temp and $08)=0) ); //打印机出错;
end;