c++ - CreateFile COM port error 2 -


i'm trying open , write com serial port on windows 7, using below code in visual studio 2012 (c++)

printf("argv[2]= '%s'\n", argv[2]);  m_hcommportsend= ::createfile(argv[2] ,generic_read|generic_write,0,0,open_existing,0,0);  if(m_hcommportsend == invalid_handle_value)  {     printf("%s error: %d\n", argv[2], getlasterror());     return -1; } 

this code works argv[2] com1 or com7

i have com port com39, when pass com39 argv[2] not openeded getlasterror() returning 2.

not sure why ?

the msdn page createfile says following under communications resources:

to specify com port number greater 9, use following syntax: \\.\com10. syntax works port numbers , hardware allows com port numbers specified.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -