CreateFile()
can be used to access serial ports using "COM1" through "COM9" for the name of the file; however, the message
INVALID_HANDLE_VALUE
is returned if you use "COM10" or greater.
For ports > 9, the correct way to specify the serial port in a call to
CreateFile()
is as follows:
CreateFile(
"\\\\.\\COM10", // address of name of the communications device
fdwAccess, // access (read-write) mode
0, // share mode
NULL, // address of security descriptor
OPEN_EXISTING, // how to create
0, // file attributes
NULL); // handle of file with attributes to copy
Also, be sure the COM device you are trying to access is actually installed. You can use the freeware program SIW to verify this:
http://www.gtopala.com/[
^]