在NT/2000下原來的代碼打開編號10以上端口用:
01.
CreateFile(
02.
"COM10"
,
03.
GENERIC_READ | GENERIC_WRITE,
04.
0,
05.
NULL,
06.
OPEN_EXISTING,
07.
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
//重疊I/O
08.
NULL
09.
);
將提示錯誤,這樣就OK:
01.
CreateFile(
02.
"\\\\.\\COM10"
,
//對應的就是\\.\COM10
03.
GENERIC_READ | GENERIC_WRITE,
04.
0,
05.
NULL,
06.
OPEN_EXISTING,
07.
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
//重疊I/O
08.
NULL
09.
);
http://www.vckbase.com/index.php/wv/1045
沒有留言:
張貼留言