Parallel port for short, it has 3 ports: Data port, State port, control port, commonly used and port is LPT1, its 3 ports address are: 378H, 379H and 37AH respectively.
First, the same mouth read and write
In assembly language, you can use in and out instructions to operate with the mouth, and there is no corresponding function in Delphi, the method can be read and written to the parallel port, fortunately Delphi can be embedded assembler program, through the direct embedding assembly instructions in and out can easily read and write to the parallel port. We can also access the port by invoking Windows API functions or third-party-supplied DLLs and VxD, but it is more convenient and quicker to read and write to the same port by using the embedded assembly method.
Use the following Readport function and the Writeport procedure to read and write the interface, and the parameter port is the port address to be manipulated.
function ReadPort(Port:WORD):BYTE;
var
B:BYTE;
begin
ASM
MOV DX, Port;
IN AL, DX;
MOV B, AL;
END;
Result:=B;
end;
procedure WritePort(Port:WORD;ConByte:BYTE);
begin
ASM
MOV DX, Port;
MOV AL, ConByte;
OUT DX, AL;
END;
end;