Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi Friends,
I am new for C++.Now i am working in a COM Port Project. I have a DLL File for accessing COM Port data(sending and Receiving).Now,I access COM1 to COM9.But i can't access above COM10.Why?how can i solve this problem?please tell me.
Thanks and Regards
Naraayanan.
Posted
Updated 29-Apr-20 3:42am
Comments
Sergey Alexandrovich Kryukov 19-Apr-11 3:19am    
The nature of limitation is more or less clear, but the problem looks a bit tricky. My 5 for the Question.
--SA

1 solution

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/[^]
 
Share this answer
 
v4
Comments
Peter_in_2780 19-Apr-11 3:50am    
I can't find it right now, but there was a previous thread on this topic where I pointed out that under Vista, for some #$%^ M$ reason, you need "run as admin" to access \\.\COMxx XP works fine, don't know about Weven.
Sergey Alexandrovich Kryukov 19-Apr-11 11:41am    
My 5.
--SA
naraayanan 28-Apr-11 6:57am    
Thanks my friend

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900