我对这方面一窍不通,一头雾水,请指教。

解决方案 »

  1.   

    转:
    Uses Zlib
    procedure TMyClass.CompressStream(var AinStream, AoutStream: TMemoryStream);
    var
      InpBuf, OutBuf: Pointer;
      InpBytes, OutBytes: Integer;
    begin
      InpBuf := nil;
      OutBuf := nil;
      try
        GetMem(InpBuf, AinStream.Size);
        AinStream.Position := 0;
        InpBytes := AinStream.Read(InpBuf^, AinStream.Size);
        CompressBuf(InpBuf, InpBytes, OutBuf, OutBytes);
        AoutStream.Write(OutBuf^, OutBytes);
      finally
        if InpBuf <> nil then
          FreeMem(InpBuf);
        if OutBuf <> nil then
          FreeMem(OutBuf);
      end;
    end;procedure TMyClass.DecompressStream(var AinStream, AoutStream: TMemoryStream);
    var
      InpBuf, OutBuf: Pointer;
      OutBytes, sz: Integer;
    begin
      InpBuf := nil;
      OutBuf := nil;
      sz := AinStream.Size - AinStream.Position;
      if sz > 0 then
      try
        GetMem(InpBuf, sz);
        AinStream.Read(InpBuf^, sz);
        DecompressBuf(InpBuf, sz, 0, OutBuf, OutBytes);
        AoutStream.Write(OutBuf^, OutBytes);
      finally
        if InpBuf <> nil then
          FreeMem(InpBuf);
        if OutBuf <> nil then
          FreeMem(OutBuf);
      end;
      AoutStream.Position := 0;
    end;
     
     
      

  2.   

    使用现成的ZIP算法!!!www.torry.net上有许多免费的代码!!!
      

  3.   

    调用winrar进行压缩和解压缩
      a:='a E:\MMTools.rar  E:\MMTools';
      Panel1.Caption:=TimeToStr(time());
      ShellExecute(application.MainForm.Handle,'open','winrar.exe',PChar(a),'',SW_show);