⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iofun.pas

📁 delphi直接访问和控制电脑的打印口(并行口).htm直接访问和控制电脑的打印口(并行口).htm
💻 PAS
字号:
{**********************************************************}
{                                                          }
{  LPT端口的读写和基址检测                                 }
{                                                          }
{  Email: pnzwzw@cdle.net or pnzwzw@163.com                }
{  URL: http://www.cdle.net                                }
{                                       明浩   2002.7      }
{   函数只用于win9x,                                      }
{   用于NT、2K或XP时请使用AllowIo.exe等开放端口            }
{**********************************************************}
unit IOFun;

interface

type
  TIO_Fun = Class
    procedure PortOut(PortAddress: Word; OutData: Byte);
    function PortIn(PortAddress: Word): Byte;
    procedure LPTCheck();
end;

var
  IO_Fun: TIO_Fun;
  LPTBA: array [1..3] of Word;  //用于存放基址
  GLPTBA: Word; //当前使用中的基地址

implementation

procedure TIO_Fun.PortOut(PortAddress: Word; OutData: Byte);  //写端口
begin
  asm
    mov dx,PortAddress;
    mov al,OutData;
    out dx,al;
  end;
end;

function TIO_Fun.PortIn(PortAddress: Word): Byte; //读端口
var
  InData: Byte;
begin
  asm
    mov dx,PortAddress;
    in al,dx;
    mov InData,al;
  end;
  Result := InData;
end;

procedure TIO_Fun.LPTCheck(); //并口基址检测
var
  CycA, TempA: Integer;
  PortAddress: Word;
  VTemp: Byte;
begin
  TempA := 1;
  for CycA:= 1 to 3 do
  begin
    case CycA of
      1: PortAddress := $3BC;
      2: PortAddress := $378;
      3: PortAddress := $278;
    end;
    VTemp := PortIn(PortAddress);
    PortOut(PortAddress, $4);
    if PortIn(PortAddress) = $4 then
      begin
        LPTBA[TempA] := PortAddress;
        TempA := TempA+1;
      end;
    PortOut(VTemp, PortAddress);  //写回原值
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -