Forumunuz.Com

Forumunuz.Com (https://www.forumunuz.com/)
-   Webmaster Forum (https://www.forumunuz.com/webmaster-forum/)
-   -   StreamToString / StringToStream (https://www.forumunuz.com/webmaster-forum/17367-streamtostring-stringtostream.html)

Kaf Dağı 27 Mart 2015 15:09

StreamToString / StringToStream
 
Kod:

function StreamToString(Stream: TStream): String;
var
  Size: Integer;
  p: PChar;
begin
  Size := Stream.Size;
  SetLength(Result, Size * 2);
  GetMem(p, Size);
 
  Stream.Position := 0;
  Stream.Read(p^, Size);
 
  BinToHex(p, PChar(@Result[1]), Size);
 
  FreeMem(p, Size);
end;
 
procedure StringToStream(const s: String; Stream: TStream);
var
  Size: Integer;
  p: PChar;
begin
  Size := Length(s) div 2;
  GetMem(p, Size);
 
  HexToBin(PChar(@s[1]), p, Size * 2);
 
  Stream.Position := 0;
  Stream.Write(p^, Size);
 
  FreeMem(p, Size);
end;



Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 18:44.

Powered by vBulletin® Version 3.8.9   Copyright ©2000 - 2026, vBulletin Solutions, Inc.

Site kurucuları: Damla ve Meltem