使用VC ++检查ReadFile是否在COM端口中处理 [英] Check ReadFile is Processing in COM Port using VC++

查看:88
本文介绍了使用VC ++检查ReadFile是否在COM端口中处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
现在我正在执行医疗设备项目.此项目的目的是将医疗设备数据转换为PDF或图像文件.我是C ++的新手.所以请帮忙.我认为,这是COM Port Program.ReadFile>>的流程.写入文件>> CreateFile.So,我想检查是否从医疗设备读取信息.
在我的代码中:

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:

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;
}
}
} 


此处完成的是Method的返回值.当文件未创建时,我想返回值为0.那么如何实现呢?请非常紧急.
谢谢
Lakshmi Narayanan.S


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

推荐答案

每个API都有一个返回值,您可以检查该返回值以查看操作是否成功或导致错误.
这样,您可以根据API的返回值确定从函数返回什么.

例如,ReadFile情况就是这样-
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;


这篇关于使用VC ++检查ReadFile是否在COM端口中处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆