Re: Delphi printer ready and int $17??


[ Delphi Forum -- by DelphiLand ]

Posted by webmaster Guido on January 08, 2004 at 16:20:04:

In Reply to: Delphi: printer ready and int $17? posted by Sheirly Dewi on December 23, 2003 at 05:54:30:

: How to detect in my Delphi app whether the printer power is ON or OFF and how to detect the paper of printer is ready? I use Borland Delphi 7 and Windows 2000.
: I try a program, but it always error at -->> int $17 an error is access violation at address... why???

: function PrinterStatus : integer;
: asm
: mov ah, 2 // function 2 - returns status of port
: mov dx, 0 // lpt1 = 0, lpt2 = 1 etc
: int $17 // status in ah
: mov al, ah
: and eax, $FF // status now in eax with top 24 bits cleared
: end;

--------------------

The problem with this code is that it doesn't work under Windows NT, and probably also not under Win2000 and Windows XP: it gives an access violation from the DOS interrupt call "int 17h".

Printing is normally done using Windows' "Spooler" system. The whole point of Windows' print system is to isolate the programmer from the many different types of printers and interface cards out there. That's why more secure OS's (such as Win2000, NT, Windows XP) will not like it when you directly access a printer port.

However, for some old systems, direct access to a printer may be the only way to accomplish certain things. Only in that case use the code with "int 17h".


Related Articles and Replies:



[ Delphi Forum ]
[ DelphiLand: free Delphi source code, tips, tutorials ]