您好請我這個包裝記錄:德爾福複製的MemoryStream到動態數組
type
TMyRecord = packed record
BufSize: Word;
TargetUser:array[0..80] of char;
StreamHolder: Byte;
end;
PMyRecord = ^TMyRecord;
//我想將MemoryStream保存到StreamHolder 請看下面我的方法:
Procedure AddToRec(ATargetUser:String);
var
MyRecord: PMyRecord;
Strm:TMemoryStream;
Size: Integer;
begin
Strm:=TMemoryStream.Create;
try
Strm.LoadFromFile('myFile.dat');
Strm.position:=0;
Size:=Strm.size;
GetMem(MyRecord,Size);
ZeroMemory(MyRecord,Size);
MyRecord.BufSize := Size;
StrCopy(MyRecord.TargetUser,PChar(ATargetUser));
// here how could i copy the Strm into the StreamHolder ?
//SendMyBuffer(MyRecord,Size);
finally
Strm.free;
end;
end;
那麼請我如何將Strm複製到StreamHolder?
千恩萬謝
@大衛赫弗南:StreamHolder:字節;在TMyRecord中聲明 – Sdean
@David Heffernan:我想將流複製到MyRecord但保留StrCopy(MyRecord.TargetUser,PChar(ATargetUser)); – Sdean