DaveG
asked on
Getting a printers status if there is no windows print driver
I want to be able to get the status from a printer connected to LPT1,LPT2 etc. The printer has no windows print driver installed, its data is sent via a text file opened as LPT1 etc. Any solutions?
Can this software be used for COM ports also???
What delphi and windows version(s) do you need to support?
Regards,
Erik.
Regards,
Erik.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here it is DaveG,I am using this in my POS program:
function TPrinterStatusForm.CheckCO M(Printer: Word): Word;
var
PS: Word; {PS = Printer Status}
begin
asm
mov dx,Printer {COM, starts from 0}
mov ax,300h
int 14h
and ax, 127
mov PS,ax
end;
Result := PS;
end;
function TPrinterStatusForm.CheckLP T(Printer: Word): Word;
var
PS: Byte; {PS = Printer Status}
begin
asm
mov dx,Printer {LPT}
mov ah,02h {Status request}
int 17h
mov PS,ah
end;
Result := PS;
end;
And this works!!!
function TPrinterStatusForm.CheckCO
var
PS: Word; {PS = Printer Status}
begin
asm
mov dx,Printer {COM, starts from 0}
mov ax,300h
int 14h
and ax, 127
mov PS,ax
end;
Result := PS;
end;
function TPrinterStatusForm.CheckLP
var
PS: Byte; {PS = Printer Status}
begin
asm
mov dx,Printer {LPT}
mov ah,02h {Status request}
int 17h
mov PS,ah
end;
Result := PS;
end;
And this works!!!
This is the routine I worked out myself from investigation- it is more or less the same:
function PrinterStatus(OutFile: Word) : byte;
var
PrinterPort: Word;
function GetStatus : byte;
asm
mov AH,$02 {get printer status}
mov DX, PrinterPort {lpt1=0, lpt2=1}
Int $17 {get printer status}
mov AL, AH
end;
begin
PrinterPort := OutFile;
Result := GetStatus;
end;
The bits returned should correspond as follows
7 6 5 4 3 2 1 0 bit value
-------------------------- ---
1 printer not busy
0 printer busy
1 printer acknowledgment
1 out of paper
1 printer selected
1 i/o error
? ? unused
1 timeout
This code works too....
function PrinterStatus(OutFile: Word) : byte;
var
PrinterPort: Word;
function GetStatus : byte;
asm
mov AH,$02 {get printer status}
mov DX, PrinterPort {lpt1=0, lpt2=1}
Int $17 {get printer status}
mov AL, AH
end;
begin
PrinterPort := OutFile;
Result := GetStatus;
end;
The bits returned should correspond as follows
7 6 5 4 3 2 1 0 bit value
--------------------------
1 printer not busy
0 printer busy
1 printer acknowledgment
1 out of paper
1 printer selected
1 i/o error
? ? unused
1 timeout
This code works too....
I withdraw this question...
Ok, what do you want then?????????
So the value for this question is 200 + 230 points (isn't that worth the answer??).
(FOR WHAT KIND OF APPLICATION THAT)