The convention for addressing COM ports in serial-port programming using Win32 APIs is \\.\COMx, where x is port number. For example, COM10 is represented using \\.\COM10. This convention should be followed to be able to open and close COM ports.
Visual C++:
Use the format \\\\.\\COMx to address a COM port in application programs that use Visual C++ and Win32 APIs. For example, COM10 is referred to as \\\\.\\COM10.
Borland C++ Builder:
Use the format \\.\COMx to address a COM port in application programs that use Borland C++ and Win32 APIs. For example, COM10 is referred to as \\.\COM10.