1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
void __fastcall TCPortChoiceFrm::FormCreate(TObject *Sender)
{ // Prend liste des ports disponibles dans le Registre
TRegistry * reg = new TRegistry();
reg->RootKey = HKEY_LOCAL_MACHINE;
bool res = reg->OpenKey("Hardware\\DeviceMap\\SerialComm",false);
if(res) reg->GetValueNames(CBoxPort->Items); // Liste des ports
if(CBoxPort->Items->Count)
{ // Si nom des clés != COMx, lit valeurs
if(CBoxPort->Items->Strings[0].SubString(1,3) != "COM")
for(int i=0; i<CBoxPort->Items->Count; i++)
CBoxPort->Items->Strings[i] = reg->ReadString(CBoxPort->Items->Strings[i]);
}
delete reg;
// Affiche le port sélectionné :
CBoxPort->ItemIndex = CBoxPort->Items->IndexOf(*PortName);
} |
Partager