Arduino interface port change

I am trying to read data from com4 for it keeps trying to connect to COM5. How can I change it to COM4?

this->hSerial = CreateFileA(portName,
            GENERIC_READ | GENERIC_WRITE,
            0,
            NULL,
            OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL,
            NULL);

So it's guess the language time!

So it's guess the language time!

That's pretty easy, really. It's C++ on Windows. It has NOTHING to do with the Arduino.

I am trying to read data from com4 for it keeps trying to connect to COM5. How can I change it to COM4?

Assign the proper value to portName. That's pretty obvious, isn't it?