From Microsoft support:
CreateFile() is successful when you use "COM1" through "COM9" for the name of the file; however, the message "INVALID_HANDLE_VALUE" is returned if you use "COM10" or greater.
If the name of the port is \.\COM10, the correct way to specify the serial port in a call to CreateFile() is as follows:
CreateFile("\\.\COM10"...) .
URL: https://support.microsoft.com/en-us/topic/howto-specify-serial-ports-larger-than-com9-db9078a5-b7b6-bf00-240f-f749ebfd913e