Function StreamToStr(Value: TStream): String; //流转化成16进制字符串
Function StrToStream(Const aStr: String; Value: TStream): Integer;//16进制字符串化为流数据
Function ReadStream(Const Section,aParamName: String; aValue: TStream): Integer;//读取流
Procedure WriteStream(Const Section,aParamName: String; aValue: TStream);//写入流
function TIniFile.StreamToStr(Value: TStream): String;
begin
result := PointToHex(TMemoryStream(Value).memory,Value.Size); //该函数我以前有写过,请看以前的帖子
end;
function TIniFile.StrToStream(const aStr: String;
Value: TStream): Integer;
Var
Text: String;
Stream: TMemoryStream;
Pos: Integer;
Begin
Text := aStr;
If Text <> '' Then
Begin
If Value Is TMemoryStream Then
Stream := TMemoryStream(Value)
Else
Stream := TMemoryStream.Create;
Try
Pos := Stream.Position;
Stream.SetSize(Stream.Size + Length(Text) Div 2);
//转换成二进制流数据,看以前的帖子
HexToBin(Text, Pointer(Integer(Stream.Memory) + Stream.Position), Length(Text) Div 2);
Stream.Position := Pos;
If Value <> Stream Then Value.CopyFrom(Stream, Length(Text) Div 2);
Result := Stream.Size - Pos;
Finally
If Value <> Stream Then Stream.Free;
End;
End
Else
Result := 0;
end;
function TIniFile.ReadStream(const Section, aParamName: String;
aValue: TStream): Integer;
Var
mValue: String;
begin
mValue := ReadString(Section,aParamName, '');
Result := StrToStream(mValue, aValue);
end;
procedure TIniFile.WriteStream(const Section, aParamName: String;
aValue: TStream);
Var
mValue: String;
Begin
mValue := StreamToStr(aValue);
WriteString(Section,aParamName, mValue);
end;