//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Sample1u.h" #include "Acces32.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TSample1Form *Sample1Form; Word Address; TPanel *PortPanels[3]; //--------------------------------------------------------------------------- __fastcall TSample1Form::TSample1Form(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TSample1Form::ExitButtonClick(TObject *Sender) { exit(0); } //--------------------------------------------------------------------------- void __fastcall TSample1Form::TestButtonClick(TObject *Sender) { if (TestTimer->Enabled) { TestTimer->Enabled = false; TestButton->Caption = "Start Test"; BaseEdit->Enabled = true; } else { PortPanels[0]=Port0Text; PortPanels[1]=Port1Text; PortPanels[2]=Port2Text; Address = StrToInt("0x"+BaseEdit->Text); TestTimer->Enabled = true; TestButton->Caption = "Abort Test"; BaseEdit->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TSample1Form::TestTimerTimer(TObject *Sender) { int port, i; unsigned data,mask; unsigned char ofs[] = { 0,1,2,4,5,6 }; // Table of offsets to input registers PortPanels[0]->Caption = ""; PortPanels[1]->Caption = ""; PortPanels[2]->Caption = ""; for (port = 0; port <= 2; port++) { // Read the first 8 input channels of current port data = InPortB(Address + ofs[2*port])*256; data += InPortB(Address + ofs[(2*port)+1]); // Check the status of each bit field and display result mask = 1; for (i = 0; i < 16; i++) { if (mask & data) PortPanels[port]->Caption = "1" + PortPanels[port]->Caption; else PortPanels[port]->Caption = "0" + PortPanels[port]->Caption; mask <<= 1; } // end for i } // end for port } // end TestTimerTimer //--------------------------------------------------------------------------- void __fastcall TSample1Form::FormCreate(TObject *Sender) { 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); } } //---------------------------------------------------------------------------