// TMemoryStream 轉化為string字元串function MemoryStreamToString(M: TMemoryStream): AnsiString;begin SetString(Result, PChar(M.Memory), M.Size div SizeOf(C....
// TMemoryStream 轉化為string字元串 function MemoryStreamToString(M: TMemoryStream): AnsiString; begin SetString(Result, PChar(M.Memory), M.Size div SizeOf(Char)); end; // TMemoryStream 寫入string字元串 procedure MemoryAddStr(M:TMemoryStream;cStr:String); begin if M=nil then M:=TMemoryStream.Create; M.Write(cStr[1],Length(cStr)*Sizeof(char)); end; // TMemoryStream 保存到文件 procedure MemoryStreamSaveToFile(M:TMemoryStream;cFileName:String); Var FStream:TFileStream; begin if FileExists(cFileName) then begin FStream:=TFileStream.Create(cFileName,fmOpenWrite or fmShareDenyWrite); FStream.Position:=FStream.Size; end else FStream:=TFileStream.Create(cFileName,fmCreate or fmShareDenyWrite); FStream.Write(M.Memory^,M.Position); FStream.Free; end;