?? iofun.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 + -