function CompressString(Inp: string): string;
var
OutBuf: Pointer;
OutBytes: Integer;
begin
OutBuf:=nil;
try
CompressBuf(Pointer(Inp),Length(Inp),OutBuf,OutBytes);
SetString(Result,PChar(OutBuf),OutBytes);
finally
if OutBuf <> nil then
FreeMem(OutBuf);
end;
end;
{ Decompress a string }
function DecompressString(Inp: string): string;
var
OutBuf: Pointer;
OutBytes: Integer;
begin
OutBuf:=nil;
try
DecompressBuf(Pointer(Inp),Length(Inp),0,OutBuf,OutBytes);
SetString(Result,PChar(OutBuf),OutBytes);
finally
if OutBuf <> nil then
FreeMem(OutBuf);
end;
end;
http://www.example-code.com/delphi/string-compression-1.asp