title: Convert unicode string into wchar_t
body: <p>I'm having a little problem with my application while trying to use WindowsAPI...
  I'm trying to connect to a handle in a way it works, but if I change the code it doesn't works anymore...</p>
  
  <p>The code that works:</p>
  
  <pre><code>   handle_t porta; // Global var
     COMMTIMEOUTS tempos;  // Global var
     DCB configuracao; // Global var
  
     wchar_t pcCommPort[]= TEXT("COM1");
     //gate address to be accessed (COM1)
  </code></pre>
  
  <p>The code I'm trying to do:</p>
  
  <pre><code>   handle_t porta; // Global var
     COMMTIMEOUTS tempos;  // Global var
     DCB configuracao; // Global var
  
     String GATE = "COM" + Label1-&gt;Text;
     wchar_t pcCommPort[]= TEXT(GATE);
     //gate address to be accessed (Any gate)
  </code></pre>
  
  <p>I've also tried it:</p>
  
  <pre><code>   handle_t porta; // Global var
     COMMTIMEOUTS tempos;  // Global var
     DCB configuracao; // Global var
  
     wchar_t pcCommPort[]= TEXT("COM" + Label1-&gt;Text);
     //gate address to be accessed (Any gate)
  </code></pre>
  
  <p>And it:</p>
  
  <pre><code>   handle_t porta; // Global var
     COMMTIMEOUTS tempos;  // Global var
     DCB configuracao; // Global var
  
     String GATE = "COM" + Label1-&gt;Text;
     wchar_t pcCommPort[]= GATE;
     //gate address to be accessed (Any gate)
  </code></pre>
  
  <p>In any way or it says that I haven't mede the correct syntax or the error: Cannot convert unicode string into a wchar_t.</p>
  
  <p>EDIT:</p>
  
  <p>Full source (function):</p>
  
  <pre><code>void abrirporta(){
     wchar_t pcCommPort[]= TEXT("COM1");
     //endereço da porta a ser acessada (COM1)
     //porta foi declarado como HANDLE na seção private da declaração de classe Form
     //HANDLE porta
     porta = CreateFile(pcCommPort,GENERIC_READ+GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
     if(porta == INVALID_HANDLE_VALUE){
          log(7);
          throw Exception("Não foi possível abrir a porta COM.\nPor favor, tente novamente!");
      }
  
     //Tempo máximo entre o recebimento de 2 bytes (ms)
     tempos.ReadIntervalTimeout = 20;
  
     //Multiplicador de tempo de recebimento por byte
     tempos.ReadTotalTimeoutMultiplier = 0;
     tempos.ReadTotalTimeoutConstant = 100;
     tempos.WriteTotalTimeoutMultiplier = 0;
     tempos.WriteTotalTimeoutConstant = 100;
     if(!SetCommTimeouts(porta ,&amp;tempos))
     {
        CloseHandle(porta);
        frmPrincipal-&gt;spLig-&gt;Visible = False;
        frmPrincipal-&gt;spStatusInd-&gt;Visible = False;
        log(6);
        throw Exception("Erro na configuração de Timeout");
     }
  
     GetCommState(porta, &amp;configuracao);
  
     configuracao.BaudRate = 19200;
     configuracao.ByteSize = 8;
     configuracao.Parity = NOPARITY;
     configuracao.StopBits = ONESTOPBIT;
  
     if(!SetCommState(porta,&amp;configuracao))
     {
          CloseHandle(porta);
          frmPrincipal-&gt;spLig-&gt;Visible = False;
          frmPrincipal-&gt;spStatusInd-&gt;Visible = False;
          log(5);
          throw Exception("Erro na Configuração da porta");
     }
      frmPrincipal-&gt;spLig-&gt;Visible = True;
      frmPrincipal-&gt;spStatusInd-&gt;Visible = False;
      log(3);
      frmPrincipal-&gt;btEnviar-&gt;Enabled = true;
      frmPrincipal-&gt;swSaida1-&gt;Enabled = true;
      log(8);
  }
  </code></pre>
  
  <p>I hope you can help me...
  Since now thanks XD.</p>