我现在通过Pcomm.dll作pc->pc之间的文件(*.zip)的传输。但收到的文件大小不对,不能
打开,源码如下:
传文件:procedure sendfile(filename:string);
var
filehandle,iFileLength:integer;
ff:file;
begin
assignfile(ff,filename);
reset(ff,1);
blockread(ff,sbuf,sizeof(sbuf),iFileLength);
sio_RTS(frmMainForm.ReceiveCommData.Port , 1);
sio_write(frmMainForm.ReceiveCommData.Port, @sbuf[1],iFileLength);
end;
收文件:
var
strtmp : string;
dd:file;
filename:string;
FileHandle:integer;
begin
while not Terminated do
begin
Sleep(50);
fillchar(m_buf,sizeof(m_buf),0);
sio_RTS(1, 0);
intLen := sio_read(1, @rbuf, sizeof(rbuf));
if (intLen > 0) then
begin
str(1,filename);
filename:='d:/ii/dd.txt.'+filename;
assignfile(dd,filename);
Rewrite(dd, 1);
blockwrite(dd,rbuf,intLen);
closefile(dd);
AddtoFile(filename,'d:/ii/tt.txt');
end
end;
end;