unit Sample2u; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, Registry, ExtCtrls ; type TMainFrm = class(TForm) Label5: TLabel; ExitBtn: TButton; StartBtn: TButton; Label1: TLabel; BaseLbl: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label6: TLabel; Timer1: TTimer; Label7: TLabel; Bit0: TCheckBox; Bit1: TCheckBox; Bit2: TCheckBox; Bit3: TCheckBox; Bit4: TCheckBox; Bit5: TCheckBox; Bit6: TCheckBox; Bit7: TCheckBox; Label8: TLabel; TemperatureLbl: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; BaseEdit: TEdit; procedure ExitBtnClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure StartBtnClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); private DriverRegistry:TRegistry; { Private declarations } public { Public declarations } end; const myKey = 'Software\PCIFIND\NTioPCI\Parameters'; type TPCI_COMMON_CONFIG = record VendorID : word; DeviceID : word; Command : word; Status : word; RevisionID : byte; ProgIf : byte; SubClass : byte; BaseClass : byte; CacheLineSize : byte; LatencyTimer : byte; HeaderType : byte; BIST : byte; BaseAddresses : Array[0..5] of longint; Reserved1 : Array[0..1] of longint; RomBaseAddress : longint; Reserved2 : Array[0..1] of longint; InterruptLine : byte; InterruptPin : byte; MinimumGrant : byte; MaximumLatency : byte; end; var buf: array [0..63] of TPCI_COMMON_CONFIG; MainFrm: TMainFrm; found: Boolean; BaseAddr : word; Running : boolean; implementation uses ACCES32; {$R *.DFM} // exit button procedure TMainFrm.ExitBtnClick(Sender: TObject); begin Timer1.Enabled := False; Close; end; (* Check for existence of card *) procedure TMainFrm.FormCreate(Sender: TObject); var num, i: Integer; begin found := false; DriverRegistry:=TRegistry.Create; DriverRegistry.RootKey:=HKEY_LOCAL_MACHINE; DriverRegistry.OpenKey(MyKey, True); if (InPortB($61) = $AA55) then begin Application.MessageBox('ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.', 'Warning', IDOK); end; try num := DriverRegistry.ReadInteger('NumDevices'); except on ERegistryException do num := 0; end; if (num > 0) then DriverRegistry.ReadBinaryData('PCICommonConfig', buf, num*sizeof(TPCI_COMMON_CONFIG)); for i := 0 to num - 1 do begin with buf[i] do begin if (DeviceID = $22C0) and (VendorID=$494F) then begin BaseAddr := BaseAddresses[2] AND $FFF8; BaseLbl.Caption:=IntToHex(BaseAddr,4); found := true; Break; end; end; end; if not found then begin BaseEdit.Visible := true; Label5.caption:='Windows 95/NT WDG-CSM Sample 2'; Bit4.caption:='When unchecked, fan speed is okay (OPTION 4)'; Bit7.caption:='When unchecked, an INT has occured'; end; DriverRegistry.Free; end; procedure TMainFrm.StartBtnClick(Sender: TObject); begin if not found then BaseAddr := StrToInt('$' + BaseEdit.Text); Timer1.Enabled := True; end; procedure TMainFrm.Timer1Timer(Sender: TObject); var readback : word; begin readback := InPortB(BaseAddr+4); label11.caption := inttohex(readback,4); Bit0.Checked := ((readback AND 1)=1); Bit1.Checked := ((readback AND 2)=2); Bit2.Checked := ((readback AND 4)=4); Bit3.Checked := ((readback AND 8)=8); Bit4.Checked := ((readback AND 16)=16); Bit5.Checked := ((readback AND 32)=32); Bit6.Checked := ((readback AND 64)=64); Bit7.Checked := ((readback AND 128)=128); readback := InPortB(BaseAddr+5); label10.caption := inttohex(readback,4); TemperatureLbl.Caption := FloatToStr((((readback * (11 / 15))) + 7)); { Temperature is simply ((BASE+5) * 11/15) + 7} end; end.