Вниз
Скачать: 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
1-1119440875
Peter_cc
2005-06-22 15:47
2005.07.11
Перенос слов


10-1095160880
Jaxtor
2004-09-14 15:21
2005.07.11
Отображение формы приложения на DCOM сервере


14-1118266167
Megabyte
2005-06-09 01:29
2005.07.11
Хороший ФАК по FIB


11-1101836172
Nils
2004-11-30 20:36
2005.07.11
Нужен компонент по типу как список файлов в WinRARe


3-1117241713
ali_tash
2005-05-28 04:55
2005.07.11
XSQLDA index out of range




   Наверх