Programmierung:
Bei der Programmierung gibt es je nach Betriebssystem und verwendeter Programmiersprache Besonderheiten.
Windows 95 - Me:
Windows 95 bis Me bauen auf der MS-DOS-Plattform auf. Daher ist der direkte Zugriff auf die Schnittstelle LPT möglich.
So sind z.B. QBASIC-Befehle wie OUT 888,1 möglich. Der Einsatz von zusätzlichen Treibern bzw. dlls ist jedoch ebenfalls möglich.
Windows NT - XP:
Da der direkte Weg zu den Schnittstellen vom Betriebssystem blockiert wird, ist das Erreichen nur über einen Umweg möglich. Hierfür kommen Treiber zum Einsatz. Für BASIC, Pascal/Delphi und C/C++ sind viele Varianten verfügbar.
Zwei Beispiele sollen hier betrachtet werden:
1. io.dll (Basic, Pascal/Delphi und C/C++)
Die io.dll lässt sich von Windows 95 aufwärts für alle Windowsversionen verwenden.
C/C++ Prototypen
void WINAPI PortOut(short int Port, char Data);
void WINAPI PortWordOut(short int Port, short int Data);
void WINAPI PortDWordOut(short int Port, int Data);
char WINAPI PortIn(short int Port);
short int WINAPI PortWordIn(short int Port);
int WINAPI PortDWordIn(short int Port);
void WINAPI SetPortBit(short int Port, char Bit);
void WINAPI ClrPortBit(short int Port, char Bit);
void WINAPI NotPortBit(short int Port, char Bit);
short int WINAPI GetPortBit(short int Port, char Bit);
short int WINAPI RightPortShift(short int Port, short int Val);
short int WINAPI LeftPortShift(short int Port, short int Val);
short int WINAPI IsDriverInstalled();
Delphi Prototypen
procedure PortOut(Port : Word; Data : Byte);
procedure PortWordOut(Port : Word; Data : Word);
procedure PortDWordOut(Port : Word; Data : DWord);
function PortIn(Port : Word) : Byte;
function PortWordIn(Port : Word) : Word;
function PortDWordIn(Port : Word) : DWord;
procedure SetPortBit(Port : Word; Bit : Byte);
procedure ClrPortBit(Port : Word; Bit : Byte);
procedure NotPortBit(Port : Word; Bit : Byte);
function GetPortBit(Port : Word; Bit : Byte) : WordBool;
function RightPortShift(Port : Word; Val : WordBool) : WordBool;
function LeftPortShift(Port : Word; Val : WordBool) : WordBool;
function IsDriverInstalled : Boolean;
Wichtig! Um diese Funktionen in Delphi nutzen zu können, müssen sie richtig eingebunden werden. Zum Beispiel:

Visual Basic Prototypen
Private Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Private Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Private Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Private Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Private Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Private Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Private Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Private Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Private Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Private Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Private Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Private Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Private Declare Function IsDriverInstalled Lib "IO.DLL" As Boolean Functionsbeschreibung
PortOut
Gibt ein Byte auf einem speziellen Port aus.
PortWordOut
Gibt ein Word auf einem speziellen Port aus.
PortDWordOut
Gibt ein DWord auf einem speziellen Port aus.
PortIn
Byte von speziellem Port lesen.
PortWordIn
Word von speziellem Port lesen.
PortDWordIn
DWord von speziellem Port lesen.
SetPortBit
Setzt das Bit auf einem speziellen Port.
ClrPortBit
Löscht das Bit auf einem speziellen Port.
NotPortBit
Dreht das Bit auf einem speziellen Port um.
GetPortBit
Gibt das Bit von einem speziellen Port wieder.
RightPortShift
Bitverschiebung nach rechts, das niederwertigste Bit wird ausgegeben.
LeftPortShift
Bitverschiebung nach links, das niederwertigste Bit wird ausgegeben.
IsDriverInstalled
Um festzustellen, ob die io.dll verwendet werden darf.
Orginal beschreibung der io.dll
2. inpout32.dll (C/C++)
Inp32
Liest Bit von Port.
Out32
Schreibt Bit auf Port.

Wie man sehen kann bietet die io.dll mehr Funktionen, doch ist im Gegensatz zur inpout32.dll der Quellcode nicht frei verfügbar.
Orginalbeschreibung der inpout32.dll
Wichtig! Um eine dll verwenden zu können, muss diese entweder im selben Verzeichnis wie das Programm oder im WINDOWS-System32-Verzeichnis befinden. Die dll's funktionieren nur bei Nutzern mit Administratorrechten.
|