Thema: Delphi LPT-Port steuern

Einzelnen Beitrag anzeigen

runger
(Gast)

n/a Beiträge
 
#16

Re: LPT-Port steuern

  Alt 29. Apr 2005, 06:36
Hallo,

hier ein kleines beispiel mit IO.DLL (Link von Blutiger Anfänger):

Delphi-Quellcode:
implementation

{$R *.dfm}
procedure PortOut(Port : Word; Data : Byte); stdcall; external 'io.dll';
procedure PortWordOut(Port : Word; Data : Word); stdcall; external 'io.dll';
procedure PortDWordOut(Port : Word; Data : DWord); stdcall; external 'io.dll';
function PortIn(Port : Word) : Byte; stdcall; external 'io.dll';
function PortWordIn(Port : Word) : Word; stdcall; external 'io.dll';
function PortDWordIn(Port : Word) : DWord; stdcall; external 'io.dll';
procedure SetPortBit(Port : Word; Bit : Byte); stdcall; external 'io.dll';
procedure ClrPortBit(Port : Word; Bit : Byte); stdcall; external 'io.dll';
procedure NotPortBit(Port : Word; Bit : Byte); stdcall; external 'io.dll';
function GetPortBit(Port : Word; Bit : Byte) : WordBool; stdcall; external 'io.dll';
function RightPortShift(Port : Word; Val : WordBool) : WordBool; stdcall; external 'io.dll';
function LeftPortShift(Port : Word; Val : WordBool) : WordBool; stdcall; external 'io.dll';
function IsDriverInstalled : Boolean; stdcall; external 'io.dll';

procedure TForm1.Button1Click(Sender: TObject);
var b:byte;
begin
   If IsDriverInstalled then
      begin
        //die 0 ausgeben
        PortOut($378,$0);
        //Wert vom Port holen
        b:=PortIn($378);
      end;
end;
Beim ersten Start meckert Delphi. Ignoriere das, dort wird nur der Treiber installiert.
Ich hoffe ich habe dir geholfen.

Warum man bei WIN98 direkt zugreifen kann und warum bei W2k, Winnt oder WinXP nicht, darüber lass ich mich hier zu einem späteren Zeitpunkt aus.

Rainer
  Mit Zitat antworten Zitat