Creating handle for COM Port

Status
Not open for further replies.

KH

Junior Member level 1
Joined
Nov 1, 2004
Messages
15
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,281
Activity points
103
Hi,

Recently I upgrade from VC 6 to VC2005, and ported one program over. This program basically open the COM Port and send some binary data through the port.

The program did not give any compilation error or warnings on VC2005, but it always return an invalid handle. Below is part of the codes


char ComPort[5]="COM1";

ComHandle = ::CreateFile( LPCTSTR(ComPort), GENERIC_WRITE|GENERIC_READ,
0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL , NULL
);


These codes is working fine in VC6, but not VC2005, which part is wrong ?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…