title: serial port works in debug but not release c++ code blocks windows
body: <p>I have an application which performs properly under the CodeBlocks debugger or on the release version if under the bin sub-directory of the project. If the release gets copied to anywhere else it cannot identify or open a serial port on the system. It seems like I must be missing something simple or its not linking to a <code>.lib</code> file.</p>
  
  <p>I use a function to check for existing ports on the system from com1 to com20 when the program starts. Under the project directory it can be connected to a micro-controller device and communication works fine. I use this function to check each port number for existence.</p>
  
  <pre><code>//determine if a serial port does or does not exist
  bool getComPortList(std::string portName)
  {
      bool test;
      char* portNumber = new char[portName.length() + 1];
      for (unsigned int n = 0; n &lt; portName.length(); n++)
      {
          portNumber[n] = portName[n];
      }
      HANDLE testSerial;
      testSerial = CreateFile(portNumber, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, NULL, NULL);
      if (testSerial == INVALID_HANDLE_VALUE)
      {
          test = false;
      }
      else
      {
          test = true;
      }
      CloseHandle(testSerial);
      delete[] portNumber;
      return test;
  }
  </code></pre>