主 题:怎么得到串口数?
作 者:NowCan
所属论坛:Visual C++
问题点数:20
回复次数:5
发表时间:2001-4-25 16:27:00
怎样才能知道我的计算机里有几个串口以及它们的编号(COM1、COM2等)呢?用什么函数?要Win9X和WinNT、Win2000通用的。
回复贴子:
回复人:NowCan(能量、激情、雨水、彩虹——雷雨云) (2001-4-25 17:34:00) 得0分
很难吗?
回复人:singlerace(独行者) (2001-4-25 17:45:00) 得10分
我有一段代码,正好干这个用:
int GetCommList()
{ TCHAR szDevices[65535];
int i=0, count= 0; // Get all the current device names...
if(QueryDosDevice(NULL, szDevices, 65535) != 0)
{
for(;;)
{
if(_tcsnicmp(&szDevices[i], _T("COM"), 3) == 0
&& IsDigit(&szDevices[i+3]))
{
_tprintf(_T("%s\n", &szDevices[i]); count++;
} // Go to next NULL character
while(szDevices[i] != _T('\0')) i++; // Bump pointer to the next string
i++; // The list is double-NULL terminated, so if the character is
// now NULL, we're at the end
if(szDevices[i] == _T('\0'))
break;
} }
return count;
}
回复人:vcbear(熊躯沉重,熊心飞扬) (2001-4-25 17:55:00) 得10分
在注册表里有:
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERiALCOMM
作 者:NowCan
所属论坛:Visual C++
问题点数:20
回复次数:5
发表时间:2001-4-25 16:27:00
怎样才能知道我的计算机里有几个串口以及它们的编号(COM1、COM2等)呢?用什么函数?要Win9X和WinNT、Win2000通用的。
回复贴子:
回复人:NowCan(能量、激情、雨水、彩虹——雷雨云) (2001-4-25 17:34:00) 得0分
很难吗?
回复人:singlerace(独行者) (2001-4-25 17:45:00) 得10分
我有一段代码,正好干这个用:
int GetCommList()
{ TCHAR szDevices[65535];
int i=0, count= 0; // Get all the current device names...
if(QueryDosDevice(NULL, szDevices, 65535) != 0)
{
for(;;)
{
if(_tcsnicmp(&szDevices[i], _T("COM"), 3) == 0
&& IsDigit(&szDevices[i+3]))
{
_tprintf(_T("%s\n", &szDevices[i]); count++;
} // Go to next NULL character
while(szDevices[i] != _T('\0')) i++; // Bump pointer to the next string
i++; // The list is double-NULL terminated, so if the character is
// now NULL, we're at the end
if(szDevices[i] == _T('\0'))
break;
} }
return count;
}
回复人:vcbear(熊躯沉重,熊心飞扬) (2001-4-25 17:55:00) 得10分
在注册表里有:
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERiALCOMM
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货