S
shanliqun
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟就这么点分了,穷啊!<br>这是我在网上下的代码,可每当执行到(int 17h)时系统便提示出错,当我去掉这行时,可得出的fStatus值总是2,各位你们有什么好的见解吗?或者源代码,这最好了。<br>unit PrinterStatus; <br>interface <br>uses <br>Windows, Messages, WinProcs, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; <br><br>// TPrinterstatus <br>// Komponente zum Abfragen des aktuellen Druckerportstatus <br>// Programmiert 2000 von K. Otto <br>// funktioniert unter Win 9x, jedoch nicht unter Win NT <br>// --------------------------------- <br>// Status: Freeware incl. Sourcecode <br>// --------------------------------- <br>// Diese Komponente beruht auf einem Beitrag von Robert Vivrette <br>// f黵 "The unofficial Newsletter of Delphi Users" <br>// http://www.undu.com/articles/990228a.html <br><br>type <br>TPrinterStatus = class(TComponent) <br>private <br>{ Private-Deklarationen } <br>fStatus : Byte; <br>fLPT : Integer; <br>Function GetTimeOut : Boolean; <br>Function GetIOError : Boolean; <br>Function GetPrinterSelected : Boolean; <br>Function GetOutOfPaper : Boolean; <br>Function GetAcknowledgement : Boolean; <br>Function GetPrinterBusy : Boolean; <br>protected <br>{ Protected-Deklarationen } <br>public <br>{ Public-Deklarationen } <br>Procedure CheckPrinterStatus; // Liest den Druckerstatus der angegeben LPT-Schnittstelle <br>Constructor Create(AOwner : TComponent); Override; <br>Property TimeOut : Boolean Read GetTimeOut; <br>Property IOError : Boolean Read GetIOError; <br>Property PrinterSelected : Boolean Read GetPrinterSelected; <br>Property OutOfPaper : Boolean Read GetOutOfPaper; <br>Property Acknowledgement : Boolean Read GetAcknowledgement; <br>Property Busy : Boolean Read GetPrinterBusy; <br>published <br>{ Published-Deklarationen } <br>Property LPT : Integer Read fLPT Write fLPT; <br>end; <br><br>procedure Register; <br><br>implementation <br><br>procedure Register; <br>begin <br>RegisterComponents('Eigene', [TPrinterStatus]); <br>end; <br><br>Function TPrinterStatus.GetTimeOut : Boolean; <br>Begin <br>Result:=(fStatus and $01)=$01; <br>End; <br><br>Function TPrinterStatus.GetIOError : Boolean; <br>Begin <br>Result:=(fStatus and $08)=$08; <br>End; <br><br>Function TPrinterStatus.GetPrinterSelected : Boolean; <br>Begin <br>Result:=(fStatus and $10)=$10; <br>End; <br><br>Function TPrinterStatus.GetOutOfPaper : Boolean; <br>Begin <br>Result:=(fStatus and $20)=$20; <br>End; <br><br>Function TPrinterStatus.GetAcknowledgement : Boolean; <br>Begin <br>Result:=(fStatus and $40)=$40; <br>End; <br><br>Function TPrinterStatus.GetPrinterBusy : Boolean; <br>Begin <br>Result:=not ((fStatus and $80)=$80); <br>End; <br><br>Procedure TPrinterStatus.CheckPrinterStatus; <br>Var <br>Status : Byte; <br>CheckLPT : Word; <br>Begin <br>Status:=0; <br>If (fLPT>=1) and (fLPT<=3) Then <br>Begin <br>CheckLPT:=fLPT-1; <br>asm <br>mov dx,CheckLPT; <br>mov al,0; <br>mov ah,2; <br>int 17h; <br>mov &Status, ah; <br>End; <br>End; <br>fStatus:=Status; <br>End; <br><br>Constructor TPrinterStatus.Create(AOwner : TComponent); <br>Begin <br>Inherited Create(AOwner); <br>fLPT:=1; <br>fStatus:=0; <br>End; <br><br>end.