徐
徐磊
Unregistered / Unconfirmed
GUEST, unregistred user!
我在DELPHI3下的程序:
hcom:=createfile('com1',generic_read or generic_write,0,nil,open_existing,
file_flag_overlapped,0)
timeout.readintervaltimeout:=10;
timeout.readtotaltimeoutmultiplier:=20;
timeout.readtotaltimeoutconstant:=30;
setcommtimeouts(hcom,timeout);
setevent(hcom);
dataout:='S';
buffersize:=4096;
writefile(hcom,dataout,1,buffersize,@overlapped);
readfile(hcom,datain,1,buffersize,@overlapped);
closehandle(hcom);
用DELPHI4下编译,在writefile(),readfile()行上均产生如下错误(光标停在@前):
[Error] U_com.pas(48): Types of actual and formal var parameters must be identical
但两种开发环境中对它们的说明都和下面一样(详细解释有点不同,不过好像没关系)
BOOL ReadFile(
HANDLE hFile, // handle of file to read
LPVOID lpBuffer, // address of buffer that receives data
DWORD nNumberOfBytesToRead, // number of bytes to read
LPDWORD lpNumberOfBytesRead, // address of number of bytes read
LPOVERLAPPED lpOverlapped // address of structure for data
);
注:buffersize曾被我设为指针,可惜没用;另外overlapped前加不加@没关系,为何?
前一次把问题写错了位置,又没加分,实在不好意思!
hcom:=createfile('com1',generic_read or generic_write,0,nil,open_existing,
file_flag_overlapped,0)
timeout.readintervaltimeout:=10;
timeout.readtotaltimeoutmultiplier:=20;
timeout.readtotaltimeoutconstant:=30;
setcommtimeouts(hcom,timeout);
setevent(hcom);
dataout:='S';
buffersize:=4096;
writefile(hcom,dataout,1,buffersize,@overlapped);
readfile(hcom,datain,1,buffersize,@overlapped);
closehandle(hcom);
用DELPHI4下编译,在writefile(),readfile()行上均产生如下错误(光标停在@前):
[Error] U_com.pas(48): Types of actual and formal var parameters must be identical
但两种开发环境中对它们的说明都和下面一样(详细解释有点不同,不过好像没关系)
BOOL ReadFile(
HANDLE hFile, // handle of file to read
LPVOID lpBuffer, // address of buffer that receives data
DWORD nNumberOfBytesToRead, // number of bytes to read
LPDWORD lpNumberOfBytesRead, // address of number of bytes read
LPOVERLAPPED lpOverlapped // address of structure for data
);
注:buffersize曾被我设为指针,可惜没用;另外overlapped前加不加@没关系,为何?
前一次把问题写错了位置,又没加分,实在不好意思!