title: How to get serial port name like this in c? Not COM number?
body: <p><a href="https://i.stack.imgur.com/XErWG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XErWG.png" alt="enter image description here"></a></p>
  
  <p>how to get the serial port name by my red pen. Not COM5.COM5 can be gotten by windows-API. If you know it, please let me know. I'll appreciate it!</p>
  
  <p><a href="https://i.stack.imgur.com/rUcNh.png" rel="nofollow noreferrer">enter image description here</a>
  Now, I can get both serial ports full name and COMX. But which is true? I know how to find true one by manual manipulation instead of my coding program. But how to find true one by my coding program. </p>
  
  <pre><code>enter code here
   GUID classGuids = {0x4D36E978L, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18};   //GetClassGUIDs("ports");   //&amp;GUID_DEVCLASS_PORTS
  
  HDEVINFO hDevInfo = SetupDiGetClassDevs((LPGUID)&amp;classGuids, NULL, NULL, 0);
  if(hDevInfo)
  {
      SP_DEVINFO_DATA SpDevInfo={sizeof(SP_DEVINFO_DATA)};
      for(DWORD iDevIndex=0; SetupDiEnumDeviceInfo(hDevInfo, iDevIndex, &amp;SpDevInfo); iDevIndex++)
      {      
          TCHAR szName[512] = {0};
          if(SetupDiGetDeviceRegistryProperty(hDevInfo, &amp;SpDevInfo, SPDRP_FRIENDLYNAME, 
              NULL, (PBYTE)szName, sizeof(szName), NULL))
          {
              _tprintf(_T("........%s\n"), szName);
          }
      }
  
      SetupDiDestroyDeviceInfoList(hDevInfo);
  </code></pre>