unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, mmsystem, AppEvnts, ShellApi, ExtCtrls, ComCtrls, StdCtrls;
type
TForm1 =
class(TForm)
ProgressBar1: TProgressBar;
Timer1: TTimer;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure OnIdle(Sender: TObject;
var Done: Boolean);
procedure OnTimer;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
Zeit: int64;
Counter: integer;
//Variable zum Zählen der Timer durchläufe
end;
var
Form1: TForm1;
gelesen, schreiben: Integer;
STyp:
String[3] = '
LPT';
BasAdr: Integer = $378;
ComHandle: THandle;
before: boolean = true;
implementation
{$R *.dfm}
procedure Out32(Addresse:Integer; Wert:byte);
stdcall;
export;
external '
INPOUT32.DLL';
function Inp32(Addresse:Integer):Byte;
stdcall;
export;
external '
INPOUT32.DLL';
procedure TForm1.OnIdle(Sender: TObject;
var Done: Boolean);
begin
done:=false;
OnTimer;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnIdle := OnIdle;
end;
procedure TForm1.OnTimer;
var
adr: integer;
begin
adr:=Inp32(BasAdr+1);
//Lesen
if (adr = 254)
and (before = true)
then
begin
inc(counter);
//Zähler um 1 erhöhen
before := false;
end;
if adr = 126
then
before := true;
if timegettime-Zeit>1000
then //Jeweil nach einer Sekunde Frequenz ausgeben
begin
Label1.Caption := IntToStr(counter);
//Freuqenz ausgeben
zeit:= timegettime;
//neue Start Zeit ermitteln
Counter := 0;
//und Zähler wieder auf 0
end;
end;
end.