我编的winio怎么不起作用(100)

  • 主题发起人 主题发起人 xgw404
  • 开始时间 开始时间
X

xgw404

Unregistered / Unconfirmed
GUEST, unregistred user!
环境:delphi 7+xp,我的代码如下unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Timer1: TTimer; Memo1: TMemo; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } end;const KBC_KEY_CMD = $64; KBC_KEY_DATA = $60; procedure _WinIo_KBCWait4IBE; procedure _WinIo_KeyDown(vKeyCoad:Integer); procedure _WinIo_KeyUp(vKeyCoad:Integer); function _WinIo_Initialize:Boolean; procedure _WinIo_ShutDown;var Form1: TForm1;implementationfunction InitializeWinIo:Boolean;stdcall;external 'WinIo.dll' name'InitializeWinIo';function InstallWinIoDriver(pszWinIoDriverPath:PString;IsDemandLoaded:boolean=false):Boolean;stdcall;external 'WinIo.dll' name 'InstallWinIoDriver';function RemoveWinIoDriver:Boolean;stdcall;external 'WinIo.dll' name 'RemoveWinIoDriver';function GetPortVal(PortAddr:Word;PortVal:PDWord;bSize:Byte):Boolean;stdcall;external 'WinIo.dll' name 'GetPortVal';function SetPortVal(PortAddr:Word;PortVal:DWord;bSize:Byte):Boolean;stdcall;external 'WinIo.dll' name 'SetPortVal';function GetPhysLong(PhysAddr:PByte;PhysVal:PDWord):Boolean;stdcall;external 'WinIo.dll' name 'GetPhysLong';function SetPhysLong(PhysAddr:PByte;PhysVal:DWord):Boolean;stdcall;external 'WinIo.dll' name 'SetPhysLong';function MapPhysToLin(PhysAddr:PByte;PhysSize:DWord;PhysMemHandle:PHandle):PByte;stdcall;external 'WinIo.dll' name 'MapPhysToLin';function UnMapPhysicalMemory(PhysMemHandle:THandle;LinAddr:PByte):Boolean;stdcall;external 'WinIo.dll' name 'UnmapPhysicalMemory';procedure ShutdownWinIo;stdcall;external 'WinIo.dll' name'ShutdownWinIo';{$R *.dfm}function _WinIo_Initialize:Boolean;begin Result:=false; try Result:=InitializeWinIo; except Result:=false; end;end;procedure _WinIo_ShutDown;begin ShutdownWinIo;end;procedure _WinIo_KBCWait4IBE; //等待键盘缓冲区为空var dwVal:DWord;begin repeat GetPortVal($64,@dwVal,1); until (dwVal and $2)=0;end;procedure _WinIo_KeyDown(vKeyCoad:Integer);var btScancode:DWord;begin btScancode:=MapVirtualKey(vKeyCoad, 0); _WinIo_KBCWait4IBE; SetPortVal($64, $D2, 1); _WinIo_KBCWait4IBE; SetPortVal($60, btScancode, 1);end;procedure _WinIo_KeyUp(vKeyCoad:Integer);var btScancode:DWord;begin btScancode:=MapVirtualKey(vKeyCoad, 0); _WinIo_KBCWait4IBE; SetPortVal($64, $D2, 1); _WinIo_KBCWait4IBE; SetPortVal($64, (btScancode or $80), 1);end;procedure TForm1.Button1Click(Sender: TObject);begin memo1.Lines.Clear; timer1.Enabled:=true; _WinIo_KeyDown(66); _WinIo_KeyUp(66); _WinIo_KeyDown(65); _WinIo_KeyUp(65);end;procedure TForm1.FormCreate(Sender: TObject);begin _WinIo_Initialize;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin _WinIo_ShutDown;end;end.程序能编译通过,但好像没什么结果啊
 
后退
顶部