Вниз
Скачать: CL | DM;

памяти в память   Найти похожие ветки 

← →
iskatel ©   (2005-06-12 19:42) [0]

есть ли какойнить (бесплатный) компонент для работы с архивами, чтоб мог упаковывать и разпаковывать из памяти в память, без создания файла


← →
Ученик   (2005-06-12 20:04) [1]

>iskatel ©   (12.06.05 19:42)  
ZLib в Delphi


← →
Antonn ©   (2005-06-13 03:55) [2]

линшее поубирать.

procedure Pack_Memory(var _in:TMemoryStream);
procedure UnPack_Memory(var _in:TMemoryStream);

implementation

procedure Pack_Memory(var _in:TMemoryStream);
var
 TmpStream : TMemoryStream; CmpStream : TCompressionStream;
begin
 TmpStream := TMemoryStream.Create;
 CmpStream := TCompressionStream.Create (clMax, TmpStream);
 application.ProcessMessages;
 _in.Seek (0, 0);
 CmpStream.CopyFrom (_in, _in.Size);
 CmpStream.Free;
 TmpStream.Position:=0;
 _in.Position:=0;
 _in.SetSize(TmpStream.Size);
 _in.CopyFrom (TmpStream, TmpStream.Size);
 TmpStream.Free;
end;

procedure DecompressStream(inpStream, outStream: TMemoryStream);
var
 InpBuf, OutBuf: Pointer;
 OutBytes, sz: Integer;
begin
 InpBuf := nil;
 OutBuf := nil;
 sz     := inpStream.Size - inpStream.Position;
 if sz > 0 then  
   try
     GetMem(InpBuf, sz);
     inpStream.Read(InpBuf^, sz);
     DecompressBuf(InpBuf, sz, 0, OutBuf, OutBytes);
     outStream.Write(OutBuf^, OutBytes);
   finally
     if InpBuf <> nil then FreeMem(InpBuf);
     if OutBuf <> nil then FreeMem(OutBuf);
   end;
 outStream.Position := 0;
end;

procedure UnPack_Memory(var _in:TMemoryStream);
var _out:TMemoryStream;
begin
  _out := TMemoryStream.Create;
  _in.Position:=0;
  DecompressStream(_in, _out);
 _in.Seek(0,0);
 _in.CopyFrom(_out, _out.Size);
  _out.Free;
end;



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.025 c
14-1118676013
SPeller
2005-06-13 19:20
2005.07.11
Проблема с IE


14-1118079262
Cheater
2005-06-06 21:34
2005.07.11
Как сделать такую вещь в Excel?


14-1118812512
Vlad Oshin
2005-06-15 09:15
2005.07.11
Системные телефоны GSX/E-21 можно ли заставить быть "обычными"?


1-1119344221
Vikarij
2005-06-21 12:57
2005.07.11
Delphi, Printer


1-1118827537
Andrey Kononov
2005-06-15 13:25
2005.07.11
Посоветуйте как сделать конструктор форм для настройки программы




   Наверх