title: Cannot open COM port in C++ Windows
body: <p>I'm trying to open a COM port with visual studio 2010. I get an <code>INVALID_HANDLE_VALUE</code> after <code>CreateFile</code>. The COM port 1 is reachable, an external software could connect it.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>  portCom = "\\\\.\\COM1";
    HANDLE hCom = CreateFile(portCom,
                        GENERIC_READ|GENERIC_WRITE,
                        0,                          /* no share  */
                        NULL,                       /* no security */
                        OPEN_EXISTING,
                        0,                          /* no threads */
                        NULL);                      /* no templates */
  
    if(hCom==INVALID_HANDLE_VALUE)
    {
      printf("unable to open portCom\n");
      return(1);
    }
  </code></pre>