Click here to Skip to main content
15,894,266 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,
Now i am doing Medical Device Project.The Purpose of this Project is Convert a medical Device data into PDF(s) or Image File(s). i am new for C++. So Please help.I think, This is a flow of COM Port Program.ReadFile >> Write File >> CreateFile.So I want to Check information(s) are reading from medical Device or Not.
in my Code:
C++
extern "C" __declspec(dllexport) int <methodname>(char *str,char *sFilename)
{
//creatFile Method
//writefile Method
int z =0;
for(;;)
{
ReadFile(hCom,buffer,1,&d,NULL);
if (d == 1)
{
if (z == 0 && buffer[0]!= 27)
continue;
// Get File Size;
else 
{
break;
}
//Delete FileSize
buffer [0] =0;
//CloseHandle(hCom);
Return finished;
}
}
} 

Here finished is return value of Method. I want to return value is 0 when file doesn't create.So how to achieve this? Please very Urgent.
Thanks
Lakshmi Narayanan.S
Posted
Updated 9-Sep-12 18:07pm
v4
Comments
__John_ 6-Sep-12 8:10am    
I think you need to re-phrase your question. It is not clear what you are asking.
[no name] 7-Sep-12 10:58am    
Even after your update, this still does not make any sense. As it stands the answer to "How to identify Port does not read a file" is that the port does not return any data. But it's very difficult to figure out what it is that you are really asking.

1 solution

Every API has a return value that you can check to see if the operation succeeded or resulted in an error.
This way you can determine what to return from your function based on the return value of the API.

For example, the ReadFile case would be some this like this -
if (FALSE == ReadFile(hCom,buffer,1,&d,NULL))
    return 0;
 
Share this answer
 
Comments
naraayanan 11-Sep-12 1:19am    
Hi Superman,
Thanks.But it doesn't work.

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