http://www.7-zip.org/
파일,데이터 압축 함수 델파이,파스칼 버전

type TLzmaCompress = function(dest: PByte; destLen: PDWORD; const src: PByte; srcLen: DWORD;
  outProps: PByte; outPropsSize: PDWORD; { *outPropsSize must be = 5 }
  level: Integer=9{ 0 <= level <= 9, default = 5 }
  dictSize: DWORD=16777216{ default = (1 << 24) }
  lc: Integer=8{ 0 <= lc <= 8, default = 3 }
  lp: Integer=4{ 0 <= lp <= 4, default = 0 }
  pb: Integer=4{ 0 <= pb <= 4, default = 2 }
  fb: Integer=273{ 5 <= fb <= 273, default = 32 }
  numThreads: Integer=2 { 1 or 2, default = 2 }
):Integer; stdcall;
type TLzmaUncompress = function(dest: PByte; destLen: PDWORD; const src: PByte; srcLen: PDWORD;
  const props: PByte; propsSize: DWORD):Integer; stdcall;
 
사용코드
const
  LZMA_PROPS_SIZE=5;
var
  hLZMA: HMODLUE;
  a: array [0..100of Byte;
  b: String;
  destLen,srcLen: Cardinal;
  prop: array [0..4of Byte;
  propSize: DWORD;
  LzmaCompress: TLzmaCompress;
  LzmaUncompress: TLzmaUncompress;
begin
  hLZMA:=LoadLibraryExW(PWideChar('lzma.dll'),0,0);
  if hLZMA=0 then Exit;
  LzmaCompress:=TLzmaCompress(GetProcAddress(hLZMA,'LzmaCompress'));
  LzmaUncompress:=TLzmaUncompress(GetProcAddress(hLZMA,'LzmaUncompress'));
 
  propSize:=LZMA_PROPS_SIZE;
  ZeroMemory(@a,100);
  b:='TestValue12341234한글테스트';
  destLen:=Length(a);
  Caption:=IntToSTr(Length(b));
  srcLen := Length(b);
  i:=LzmaCompress(@a, PDWORD(@destLen), PByte(@b[1]), srcLen, @prop, PDWORD(@propSize));
  if i=0 then begin
    FillChar(b[1],srcLen,Ord($20));
    i:=LzmaUncompress(PByte(@b[1]), PDWORD(@srcLen), PByte(@a), @destLen, @prop, propSize);
    if i=0 then
      ShowMessage(b);
  end;
  FreeLibrary(hLZMA);
end;


Posted by Nightly Luna
,
® © Tanny Tales
/ rss