c++ open com port with number higher that 9
<p>I am using COM port in C++. I can not open com ports with higher number than 9, for example 10. This is function used for com port detection...</p>

<pre><code>                 WCHAR port_name[7];
                 WCHAR num_port[4];
                 String com="COM";
                 status_chyba=false;

                 for (i=1; i&lt;256; i++)
                    {
                        bool bSuccess = false;

                        wcscpy(port_name,L"COM");
                        wcscat(port_name,_itow(i,num_port,10));

                        HANDLE hPort;

                        //Try to open the port
                        hPort = CreateFile(L"COM10", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
                        //hPort = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);

                        if (hPort == INVALID_HANDLE_VALUE)
                          {
                            DWORD dwError = GetLastError();

                            //Check to see if the error was because some other app had the port open
                            if (dwError == ERROR_ACCESS_DENIED)
                            {
                            bSuccess = TRUE;
                            j=j+1;              //nech sa netestuju porty, ktore su obsadene inymi aplikaciami
                            }

                          }
                        else
                          {
                            //The port was opened successfully
                            bSuccess = TRUE;
                            j=j+1;

                            //Don't forget to close the port, since we are going to do nothing with it anyway
                            CloseHandle(hPort);
                          }

                            if (bSuccess)
                            {
                                //this-&gt;ComboBox_name-&gt;Items-&gt;Add("COM"+IntToStr(i));
                                pole_portov[j]=i;
                            }
                        }
</code></pre>

<p>I can not understand why for example COM10, throws FFFFFFFF back to HANDLE hPort. </p>

<pre><code>hPort = CreateFile(L"COM10", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
</code></pre>

<p>com9, 8,7 ... works fine, </p>

<pre><code>hPort = CreateFile(L"COM9", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
</code></pre>

<p>If anyone has idea, please share it !</p>
