Delphi 调用的DLL串口函数
int TMS_DownLoad ( HANDLE hd_no ,Char CommType,struct down_info downfile,char *ret_info)其中hd_no 是在DELPHI中打开并初始化好的串口句柄,但是现在问题是:DELPHI 可以调用DLL,并且成功传入参数,但是DLL无法接收到数据,DLL接收函数是:bool bResult=ReadFile(hd_comm,&inBuffer,nWantRead,&nRealRead,&wrOverlapped);
bResult=GetOverlappedResult(hd_comm,&wrOverlapped,&nRealRead,TRUE);Delphi打开串口方式是:
CommHandle := CreateFile(PChar(ComboBox1.Text),GENERIC_WRITE or GENERIC_READ,
0,nil,OPEN_EXISTING,FILE_FLAG_OVERLAPPED or FILE_ATTRIBUTE_NORMAL,0);急等
int TMS_DownLoad ( HANDLE hd_no ,Char CommType,struct down_info downfile,char *ret_info)其中hd_no 是在DELPHI中打开并初始化好的串口句柄,但是现在问题是:DELPHI 可以调用DLL,并且成功传入参数,但是DLL无法接收到数据,DLL接收函数是:bool bResult=ReadFile(hd_comm,&inBuffer,nWantRead,&nRealRead,&wrOverlapped);
bResult=GetOverlappedResult(hd_comm,&wrOverlapped,&nRealRead,TRUE);Delphi打开串口方式是:
CommHandle := CreateFile(PChar(ComboBox1.Text),GENERIC_WRITE or GENERIC_READ,
0,nil,OPEN_EXISTING,FILE_FLAG_OVERLAPPED or FILE_ATTRIBUTE_NORMAL,0);急等
解决方案 »
- winExec调用批处理的问题??急。在线等。。
- 将具体的数据库文件转换成 sql脚本文件的优点是什么?
- 急诊,在线,TQuery的Close方法出现莫名其妙的访问地址错误
- 跨数据库查询
- 请问如何制作安装程序的程序组部分?
- 到底dephi是怎样调用api函数的???????????????????????
- 确定DbGrid单元格的数据是否发生改变,怎么办
- 在将数据导入到Excel后,如果数字太长,将会转为科学计数法,如何解决
- 怎样用程序给windows的计算器发消息.怎样用findwindowex找到它们的handle
- 将listbox1中每一行的值,写入到自定义文本文件中
- qreport求救,急用,请大家指教
- 请问如何判斷stringGrid的某一列為只读?
0,nil,OPEN_EXISTING,FILE_FLAG_OVERLAPPED or FILE_ATTRIBUTE_NORMAL,0);你先看看 你这个handle的返回值是什么 是否为 INVALID_HANDLE_VALUE...而且你的flag参数 有用到 OVERLAPPED.. FILE_FLAG_OVERLAPPED
Instructs the system to initialize the object, so that operations that take a significant amount of time to process return ERROR_IO_PENDING. When the operation is finished, the specified event is set to the signaled state.
When you specify FILE_FLAG_OVERLAPPED, the file read and write functions must specify an OVERLAPPED structure. That is, when FILE_FLAG_OVERLAPPED is specified, an application must perform overlapped reading and writing.
When FILE_FLAG_OVERLAPPED is specified, the system does not maintain the file pointer. The file position must be passed as part of the lpOverlapped parameter (pointing to an OVERLAPPED structure) to the file read and write functions.
This flag also enables more than one operation to be performed simultaneously with the handle (a simultaneous read and write operation, for example).
0,nil,OPEN_EXISTING,FILE_FLAG_OVERLAPPED or FILE_ATTRIBUTE_NORMAL,0);这个handle的返回值是什么一个有效值,
DLL中的接收函数:
bool bResult=ReadFile(hd_comm,&inBuffer,nWantRead,&nRealRead,&wrOverlapped);
bResult=GetOverlappedResult(hd_comm,&wrOverlapped,&nRealRead,TRUE);
// &inBuffer 你的inBuffer是什么?? 如果是数组的话 不需要加&,因为数组名本身就是数组首址
如果是指针就更不用了bResult=GetOverlappedResult(hd_comm,&wrOverlapped,&nRealRead,TRUE);