All pastes #79854 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-07-05 19:57 UTC
rendered paste body
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    Timer1: TTimer;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  // inpout32.dll für LPT-Ausgang unter WinNT, Win2000 und WinXP laden
  procedure Out32(PortAddress:word;Value:byte);stdcall;export;
  external 'inpout32.DLL';
  function Inp32(PortAddress:word):byte;stdcall;export;
  external 'inpout32.DLL';

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure Delay(Milliseconds: Integer);
var
  Tick: DWord;
  Event: THandle;
begin
  Event := CreateEvent(nil, False, False, nil);
  try
    Tick := GetTickCount + DWord(Milliseconds);
    while (Milliseconds > 0) and
          (MsgWaitForMultipleObjects(1, Event, False, Milliseconds, QS_ALLINPUT) <> WAIT_TIMEOUT) do
    begin
      Application.ProcessMessages;
      if Application.Terminated then Exit;
      Milliseconds := Tick - GetTickcount;
    end;
  finally
    CloseHandle(Event);
  end;
end;


procedure DataPort(D1,D2,D3,D4,D5,D6,D7,D8: Boolean);
var
  Value: Byte;
begin
  Value := 0;
  if D1 then Value := Value +   1;
  if D2 then Value := Value +   2;
  if D3 then Value := Value +   4;
  if D4 then Value := Value +   8;
  if D5 then Value := Value +  16;
  if D6 then Value := Value +  32;
  if D7 then Value := Value +  64;
  if D8 then Value := Value + 128;
  Out32($378 , Value);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  DataPort(True, False, False, False, False, False, False, False);
  delay(200);
  DataPort(True, True, False, False, False, False, False, False);
  delay(200);
  DataPort(True, True, True, False, False, False, False, False);
  delay(200);
  DataPort(True, True, True, True, False, False, False, False);
  delay(200);

  DataPort(False, True, True, True, False, False, False, False);
  delay(200);
  DataPort(False, False, True, True, False, False, False, False);
  delay(200);
  DataPort(False, False, False, True, False, False, False, False);
  delay(200);
  DataPort(False, False, False, False, False, False, False, False);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Out32($378 , 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Out32($378, 16);
end;

end.