//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "IRQMSMPc.h" #include "W32IRQM.h" #include "ACCES32.h" #include "IRQMThrd.h" unsigned char Success; TIRQThread *MyThreads[16]; //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::ExitButtonClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::InitButtonClick(TObject *Sender) { short BusType; unsigned char IRQ, BN, Method; unsigned long BaseAddress, ClearOffset; if (BusTypeCombo->Text == "ISA") BusType = Isa; else if (BusTypeCombo->Text == "PCI") BusType = PCIBus; else BusType = InterfaceTypeUndefined; IRQ = StrToInt(IRQEdit->Text); sscanf(BaseEdit->Text.c_str(), "%lx", &BaseAddress); sscanf(LatchEdit->Text.c_str(), "%lx", &ClearOffset); try { BN = StrToInt(BusNumberEdit->Text); } catch (EConvertError &error) { BN = 0; } if (WriteRadio->Checked) Method = WRITE_TO_CLEAR; else Method = READ_TO_CLEAR; Success = InitGenDriver(BaseAddress, IRQ, BusType, BN, ClearOffset, Method); if (Success) { StatusLabel->Caption = "Setup card using Write Port, then check the IRQ # to monitor"; switch (IRQ) { case 1: CheckBox1->Enabled = true; break; case 2: CheckBox2->Enabled = true; break; case 3: CheckBox3->Enabled = true; break; case 4: CheckBox4->Enabled = true; break; case 5: CheckBox5->Enabled = true; break; case 6: CheckBox6->Enabled = true; break; case 7: CheckBox7->Enabled = true; break; case 8: CheckBox8->Enabled = true; break; case 9: CheckBox9->Enabled = true; break; case 10: CheckBox10->Enabled = true; break; case 11: CheckBox11->Enabled = true; break; case 12: CheckBox12->Enabled = true; break; case 13: CheckBox13->Enabled = true; break; case 14: CheckBox14->Enabled = true; break; case 15: CheckBox15->Enabled = true; break; } } else StatusLabel->Caption = "Driver Error During Initialization"; } //--------------------------------------------------------------------------- void __fastcall TForm1::WriteButtonClick(TObject *Sender) { unsigned long Base; unsigned long Offset; unsigned long Value; sscanf(BaseEdit->Text.c_str(), "%lx", &Base); sscanf(OffsetEdit->Text.c_str(), "%lx", &Offset); sscanf(ValueEdit->Text.c_str(), "%lx", &Value); OutPortB(Base+Offset, Value); } //--------------------------------------------------------------------------- void __fastcall TForm1::ReadButtonClick(TObject *Sender) { unsigned long Base; unsigned long Offset; unsigned short Value; sscanf(BaseEdit->Text.c_str(), "%lx", &Base); sscanf(OffsetEdit->Text.c_str(), "%lx", &Offset); Value = InPortB(Base+Offset); ValueEdit->Text = IntToHex(Value, 2); } //--------------------------------------------------------------------------- void __fastcall TForm1::IRQCheckBoxClick(TObject *Sender) { unsigned char IRQ; IRQ = ActiveControl->Tag; if (!((TCheckBox*)ActiveControl)->Checked) { MyThreads[IRQ]->Terminate(); AbortRequest(IRQ); StatusLabel->Caption = "Aborted - recheck the IRQ # to resume"; // ActiveControl->Enabled = false; } else { MyThreads[IRQ] = new TIRQThread(true); MyThreads[IRQ]->IRQ = IRQ; MyThreads[IRQ]->Resume(); } } //--------------------------------------------------------------------------- void __fastcall TForm1::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); } } //---------------------------------------------------------------------------