Witam. Potrzebuję odczytać z rejestru dostępne w systemie porty COM. Pod Win98 nie ma problemu ale pod XP nie bardzo chce mi się to czytać. Oto kawałek kodu w BCB5:
// Odczyt portów szeregowych dostępnych w systemie.
TRegistry *regKey=new TRegistry;
TStringList *COMList=new TStringList;
regKey->RootKey=HKEY_LOCAL_MACHINE;
bool keyGood=regKey->OpenKey("HARDWARE\\DEVICEMAP\\SERIALCOMM",false);
if(keyGood)
{
regKey->GetValueNames(COMList);
for(int i=0; i<COMList->Count; i++)
{
if(COMList->Strings[i]=="COM1") RadioButton1->Enabled=true;
if(COMList->Strings[i]=="COM2") RadioButton2->Enabled=true;
if(COMList->Strings[i]=="COM3") RadioButton3->Enabled=true;
if(COMList->Strings[i]=="COM4") RadioButton4->Enabled=true;
}
}
delete regKey;
delete COMList;