title: Reading comport with QT through winapi
body: <p>I'm trying to get a list of comports that are currently in use to present them in my GUI.
  I'm using the following code:</p>
  
  <pre><code>   TCHAR szComPort[8];
     HANDLE hCom = NULL;
     char str[20];
  
     for (int i = 1; i &lt;= 255; ++i)
     {
         if (i &lt; 10)
           wsprintf(szComPort, ("COM%d"), i);
         else
           wsprintf(szComPort, ("\\\\.\\COM%d"), i);
  
         hCom = CreateFile(szComPort,
             GENERIC_READ|GENERIC_WRITE, 
             0,                          
             NULL,                       
             OPEN_EXISTING,             
             0,                          
             NULL);                      
  
         if (INVALID_HANDLE_VALUE != hCom)
         {
             sprintf_s(str,"COM%d",i);
             ui-&gt;COMLIST-&gt;addItem(str);
         }
         CloseHandle(hCom);
     }
  </code></pre>
  
  <p>This works fine on my laptop but for some reason it crashes QT on my PC for comports 10 and higher (meaning if i change i&lt;=255 to i&lt;=9 it works fine),</p>
  
  <p>Any ideas?</p>
  
  <p>Thank you!</p>