Get the connected serial port in arduino via code

  arduino, c++, serial-port

I have a simple serial connection with arduino, and I need to know the COM that the arduino is connected via code.

For example, i have another application in Java that connect on COM3 and send/receive commands via serial with the arduino, in Java program I know the port (is COM3), but i need to know the communication port in arduino code.

Source: Windows Questions C++