//--------------------------------------------------------------------------- #include #include "registry.hpp" #pragma hdrstop #include "Sample2u.h" #include "acces32.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; const char *myKey = "Software\\PCIFIND\\NTioPCI\\Parameters"; TPCI_COMMON_CONFIG buf[64]; unsigned short BaseAddr; unsigned int Running; unsigned int found; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { Timer1->Enabled = false; Application->Terminate(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { if(!found) BaseAddr = StrToInt("0x" + BaseEdit->Text); Timer1->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { int num, i; TRegistry *DriverRegistry = new TRegistry; if (InPortB(0x61) == 0xAA55) { Application->MessageBox("ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.", "Warning", IDOK); } found = false; DriverRegistry->RootKey = HKEY_LOCAL_MACHINE; DriverRegistry->OpenKey(myKey, true); num = DriverRegistry->ReadInteger("NumDevices"); if (num > 0) DriverRegistry->ReadBinaryData("PCICommonConfig", buf, num*sizeof(TPCI_COMMON_CONFIG)); for (i=0; i<= num-1; i++) { if ((buf[i].DeviceID == 0x22C0) && (buf[i].VendorID == 0x494F)) { BaseAddr = buf[i].BaseAddresses[2] & 0xFFF8; BaseLabel->Caption = IntToHex(BaseAddr,4); found = true; break; } } if (!found){ BaseEdit->Visible = true; Label1->Caption = "Windows95/NT WDG-CSM Sample2"; //some bits different on ISA and PCI boards bit7->Caption = "When unchecked, an INT has occured."; bit4->Caption = "When unchecked, fan speed is okay. (OPTION 4)"; } DriverRegistry->Free(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { unsigned short readback; AnsiString temp; readback = InPortB(BaseAddr+4); Label11->Caption = IntToHex(readback,4); bit0->Checked = false; bit1->Checked = false; bit2->Checked = false; bit3->Checked = false; bit4->Checked = false; bit5->Checked = false; bit6->Checked = false; bit7->Checked = false; if ((readback & 1)== 1) bit0->Checked = true; if ((readback & 2)== 2) bit1->Checked = true; if ((readback & 4)== 4) bit2->Checked = true; if ((readback & 8)== 8) bit3->Checked = true; if ((readback & 16)== 16) bit4->Checked = true; if ((readback & 32)== 32) bit5->Checked = true; if ((readback & 64)== 64) bit6->Checked = true; if ((readback & 128)== 128) bit7->Checked = true; readback = InPortB(BaseAddr+5); Label10->Caption = IntToHex(readback,4); temp = FloatToStr((((readback * (11.0 / 15.0))) + 7.0)); // Temperature is simply ((BASE+5) * 11.0/15.0) + 7.0 TemperatureLabel->Caption = temp.SetLength(7); } //---------------------------------------------------------------------------