Error with com port on windows with ID > 9 | Es.: COM10 ...COM99

Jun 29, 2016 at 12:01 PM
Hi, I don't know if this is a dead project, but I recently find it and use it. I found an error with the code related to the annoying serial port on windows 7, but perhaps it refers also to windows CE.
To fix this issue is necessary to change the:

return WinCreateFileW(FileName, CreateAccess, 0, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);

To:
return WinCreateFileW("\\.\" + FileName, CreateAccess, 0, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);

I've already fix it in my code but I think is good to tell here the problem.

Out of scope of this thread:
I'd like to edit the code from the main branch but I'm unable to access the server with the code. Also I'd like to port to VS2013 the code. Is there a way to do it over this project?
Jul 4, 2016 at 2:45 PM
Only for completeness, in the previous post there was a mistake due to textbox escapes. The correct code is:

return WinCreateFileW("\\\\.\\" + FileName, CreateAccess, 0, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);