Delphi: printer ready and int $17?Posted by Sheirly Dewi on December 23, 2003 at 05:54:30:
Hello, ============================== P R O G R A M ========================================== unit ps1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, printers; type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; Button2: TButton; procedure Button1Click(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.DFM} const PrinterCodes : array [0..7] of string = ('printer timed-out', 'unused', 'unused', 'I/O error', 'printer selected', 'out of paper', 'printer acknowedgment', 'printer not busy'); 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; procedure TForm1.Button1Click(Sender: TObject); var L, P : integer; begin P := PrinterStatus; ListBox1.Clear; for L := 0 to 7 do if P and (1 shl L) > 0 then ListBox1.Items.Add (PrinterCodes [L]); end; end.
[ DelphiLand: free Delphi source code, tips, tutorials ] |