Click here to Skip to main content
15,882,552 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I wrote a code to communicate with serial port ("com1:").
Under win32 API this works properly. In evc4, the same code compile without any error and establishes the link with ("com1:") but when it executes the readfile statement:
C++
song=ReadFile(
   hComm   ,       // handlePort_: handle of file to read
   (BYTE*)tmpMsg,  // inputData:handle of file to read
   400     ,       // sizeBuffer:number of bytes to read
   BytesRead,     // pointer to number of bytes read
   NULL    );      // pointer to structure for data
it shows that song is true but BytesRead=0.

Any hint to how to get it to work properly?
Thanks
Posted
Updated 2-Oct-11 7:13am
v2
Comments
André Kraak 2-Oct-11 13:14pm    
Edited question:
Added pre tags

1 solution

Try
C++
DWORD dwError = ::GetLastError();
and call FormatMessage[^] to get the error details.
 
Share this answer
 
v2
Comments
Albert Holguin 3-Oct-11 21:52pm    
OP posted as solution:
the code for GetLastError() is 0, indicates that "the operation completed successfully".

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