//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Detect.h" #include "aiousb.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm2 *Form2; //--------------------------------------------------------------------------- __fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner) { DetectButton->Click(); DeviceList->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TForm2::GoButtonClick(TObject *Sender) { //do stuff DeviceIndex = DeviceList->ItemIndex; ModalResult = mrOk; } //--------------------------------------------------------------------------- void __fastcall TForm2::DetectButtonClick(TObject *Sender) { unsigned long DeviceMask, PID, NameSize; int I; Boolean Found; AnsiString Nom; DeviceList->Clear(); Found = false; DeviceMask = GetDevices(); for (I=0; I < 8; I++) { DeviceOK[I] = false; if (DeviceMask & (1 << I)) { NameSize = 256; Nom.SetLength(NameSize); QueryDeviceInfo(I, &PID, &NameSize, Nom.c_str(), NULL, NULL); Nom.SetLength(NameSize); switch (PID) { case 0x4002: case 0x4003: DeviceOK[I] = TRUE; Found = TRUE; break; default : Nom += " "; } } else { Nom = ""; } DeviceList->Items->Add(Nom); } if (Found) { StatusMemo->Lines->Add("Select the device you want to work with and click Go."); } else { StatusMemo->Lines->Add("No compatible devices found; your device may not be installed, or may not be installed properly. Click Redetect to check again."); } } //---------------------------------------------------------------------------