You are currently offline, waiting for your internet to reconnect

HOWTO: Specify Serial Ports Larger than COM9

This article was previously published under Q115831
CreateFile() can be used to get a handle to a serial port. The "Win32Programmer's Reference" entry for "CreateFile()" mentions that the sharemode must be 0, the create parameter must be OPEN_EXISTING, and thetemplate must be NULL.

CreateFile() is successful when you use "COM1" through "COM9" for the nameof the file; however, the message
is returned if youuse "COM10" or greater.

If the name of the port is \\.\COM10, the correct way to specify the serialport 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   );				
NOTES: This syntax also works for ports COM1 through COM9. Certain boardswill let you choose the port names yourself. This syntax works for thosenames as well.
3.10 3.50

Article ID: 115831 - Last Review: 03/01/2005 15:35:00 - Revision: 3.3

  • Microsoft Win32 Application Programming Interface
  • kbhowto kbapi kbcommport kbkernbase kbserial KB115831