我使用Winsock的接收1024byte缓冲区这样的:加入缓冲到的ByteArray
var
buffer : array[0..1023] of byte;
endarray : array of byte;
hFile : THandle;
dwWritten : DWORD;
dwRead : DWORD;
begin
SetLength (endarray, 3000); //fixxed size (doesn't really matter here, cause I know the size)
hFile := CreateFileW('test.bin', GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_NEW, 0, 0);
SetFilePointer(hFile, 0, nil, FILE_BEGIN);
repeat
dwRead := recv(MySock, Buffer, 1024, 0);
WriteFile(hFile, buffer[0], dwRead, dwWritten, nil); // works fine!
// Add the buffer to the endarray but how?
until (dwRead = 0) or (dwRead = -1)
[...]
CloseHandle (hFile);
end;
我怎样才能自动缓存添加到endarray因此它实际上被追加到结尾?
您再次....而不是使用WINAPI创建文件TEST.bin,烧写的,你也可以使用Delphi的TFileStream的或AssignFile /重写/写 – BeniBela 2012-08-03 14:26:11
如此。谢谢你的提示。 – 2012-08-03 14:28:59