int CUtil::GetSystemPorts(CString *pNameList, CString *pPortList)  
{  
    CRegKey RegKey;  
    int nCount = 0;  
      
    if(RegKey.Open(HKEY_LOCAL_MACHINE, "Hardware\\DeviceMap\\SerialComm") == ERROR_SUCCESS)  
    {  
        while(true)  
        {  
            char ValueName[_MAX_PATH];  
            unsigned char ValueData[_MAX_PATH];  
            DWORD nValueSize = _MAX_PATH;  
            DWORD nDataSize = _MAX_PATH;  
            DWORD nType;  
              
            if(::RegEnumValue(HKEY(RegKey), nCount, ValueName, &nValueSize, NULL, &nType, ValueData, &nDataSize) == ERROR_NO_MORE_ITEMS)  
            {  
                break;  
            }  
              
            if(pNameList)  
                pNameList[nCount] = ValueName;  
              
            if(pPortList)  
                pPortList[nCount] = ValueData;  
              
            nCount++;  
        }  
    }  
      
    return nCount;  
}  

相关文章:

  • 2021-08-25
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
相关资源
相似解决方案