title: CreateFile COM port error 2
body: <p>I'm trying to open and write to a COM serial port on Windows 7, using below code in Visual Studio 2012 (C++)</p>
  
  <pre><code>printf("argv[2]= '%s'\n", argv[2]);
  
  m_hCommPortSend= ::CreateFile(argv[2] ,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
  
  if(m_hCommPortSend == INVALID_HANDLE_VALUE) 
  {
      printf("%s error: %d\n", argv[2], GetLastError());
      return -1;
  }
  </code></pre>
  
  <blockquote>
    <p>This Code works well with argv[2] as COM1 or COM7</p>
  </blockquote>
  
  <p>I have another com port COM39, When I pass COM39 as argv[2] it is not openeded
  GetLastError() returning 2.</p>
  
  <p>Not sure why ?</p>