ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
2 мая
1555 Топик полностью
rorbrob (19.12.2003 08:38, просмотров: 1) ответил Xpюн Mopжoв на Чтобы узнать у Windows какие COM порты доступны нужно пытаться их открыть с помошью CreateFile? Другие способы есть?
Ответ: Try this This example is better, then above one. You can detect all COM ports, including already opened (at this moment CreateHandle will
not return handle !).


AnsiString TextCOM;
COMMCONFIG cc;
DWORD dwCCSize = sizeof(cc);
int ComInstalled[256];
int TotalComNumbar = 0;

for (int i = 0; i < 256; i++)
{
TextCOM = "Com" + IntToStr(i+1);
if ( GetDefaultCommConfig(TextCOM.c_str(), &cc, &dwCCSize) )
{
ComInstalled[i] = 1;
TotalComNumbar++;
}
else
FComInstalled[i] = 0;
}