HOWTO: Specify Serial Ports Larger than COM9PSS ID Number: 115831Article Last Modified on 12/16/2001 -------------------------------------------------------------------------------- The information in this article applies to: Microsoft Win32 Application Programming Interface (API), when used with: the operating system: Microsoft Windows 95 the operating system: Microsoft Windows 98 the operating system: Microsoft Windows 2000 the operating system: Microsoft Windows Millennium Edition the operating system: Microsoft Windows NT the operating system: Microsoft Windows XP--------------------------------------------------------------------------------This article was previously published under Q115831 SUMMARY CreateFile() can be used to get a handle to a serial port. The "Win32 Programmer's Reference" entry for "CreateFile()" mentions that the share mode must be 0, the create parameter must be OPEN_EXISTING, and the template must be NULL. 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", // 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 boards will let you choose the port names yourself. This syntax works for those names as well. Additional query words: 3.10 3.50Keywords: kbAPI kbCommPort kbDSupport kbhowto kbKernBase kbSerial KB115831 Technology: kbAudDeveloper kbOSWin2000 kbOSWin95 kbOSWin98 kbOSWinME kbOSWinNTSearch kbOSWinSearch kbOSWinXP kbOSWinXPSearch kbWin32API kbWin32sSearch
--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Win32 Application Programming Interface (API), when used with:
the operating system: Microsoft Windows 95
the operating system: Microsoft Windows 98
the operating system: Microsoft Windows 2000
the operating system: Microsoft Windows Millennium Edition
the operating system: Microsoft Windows NT
the operating system: Microsoft Windows XP--------------------------------------------------------------------------------This article was previously published under Q115831
SUMMARY
CreateFile() can be used to get a handle to a serial port. The "Win32 Programmer's Reference" entry for "CreateFile()" mentions that the share mode must be 0, the create parameter must be OPEN_EXISTING, and the template must be NULL. 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", // 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 boards will let you choose the port names yourself. This syntax works for those names as well.
Additional query words: 3.10 3.50Keywords: kbAPI kbCommPort kbDSupport kbhowto kbKernBase kbSerial KB115831
Technology: kbAudDeveloper kbOSWin2000 kbOSWin95 kbOSWin98 kbOSWinME kbOSWinNTSearch kbOSWinSearch kbOSWinXP kbOSWinXPSearch kbWin32API kbWin32sSearch