欢迎光临
我们一直在努力

一个C++及Delphi做的压缩程序-.NET教程,Windows开发

建站超值云服务器,限时71元/月

{ this is interface of c++ code.
  c++ source code not included to this archive.
  look readme.txt file for more information. }

#ifndef __coding_h__
#define __coding_h__

#ifndef coding_impex
#define coding_impex __declspec(dllimport)
#endif

class coding_impex avldecode
{
   public:
     ~avldecode();
      avldecode();

      virtual int readbuf            
                  ( void     *buf,   
                    unsigned  maxlen,
                    unsigned &rdlen  
                  ) = 0;             

      int  get(void *buf, unsigned  maxlen);
      int  get(void *buf, unsigned  maxlen, unsigned &rdlen)
      {  return ((int)(rdlen = get(buf, maxlen)) < 0)? rdlen :0 ;
      }

      void reset();

   private:

   ????????? private part not included ???????????????????

};

class coding_impex avlencode
{
   public:
     ~avlencode();
      avlencode();

      virtual int writebuf           
                  ( void     *buf,   
                    unsigned  len    
                  ) = 0;             

      int  put(void *buf, unsigned  n);
      void reset();

   private:
  ?????????? private part not icluded ?????????????

};

#endif //__coding_h__

///encode.pas
{$m 8192,120000,120000}
uses avlcodes;

const bufsize=60000;

var p: pointer;
    f,f1: file;
    s: string;
    buf: pointer;
    num: word;

{$f+}

function writetofile(var buf; n: integer): integer;
var num: word;
begin
blockwrite(f1,buf,n,num);
end;

{$f-}

begin
if not getmemory then
  begin
   writeln(not enough memory in heap to compress file.);
   halt;
  end;
s:=paramstr(1);
setencodeoutbuffer(@writetofile);
assign(f,s);
{$i-}
  if s<> then reset(f,1);
{$i+}
if (ioresult<>0) or (s=) then
  begin
   writeln;
   writeln(the author of this turbo pascal program and original c++ code is);
   writeln(alexander larkin   ( translated to turbo pascal from c++ on 27/09/1999 ));
   writeln;
   writeln(e-mail:      avlarkin@writeme.com);
   writeln(internet:    http://www.geocities.com/siliconvalley/6235/tpdl.htm);
   writeln;
   writeln(usage: encode.exe infile outfile [password]);
   writeln;
   freememory;
   halt;
  end;
s:=paramstr(2);
assign(f1,s);
{$i-}
if s<> then rewrite(f1,1);
{$i+}
if (ioresult<>0) or (s=) then
  begin
   close(f);
   writeln(cannot create find file +s);
   freememory;
   halt;
  end;
setpassword(paramstr(3));
  getmem(buf,bufsize);
   repeat
    blockread(f,buf^,bufsize,num);
    encodeput(buf^,num);
   until num<=0;
  if num<0 then writeln(cannot compress file. you do something wrong.);
encodereset;
close(f);
close(f1);
freememory;
end.

///decode.pas
{$m 8192,120000,120000}
uses avlcodes;

const bufsize=60000;

var p: pointer;
    f,f1: file;
    s: string;
    buf: pointer;
    num: word;

{$f+}

function readfromfile(var buf; n: integer; var rdlen: integer): integer;
begin
blockread(f,buf,n,rdlen);
readfromfile:=0;
end;

{$f-}

begin
if not getmemory then
  begin
   writeln(not enough memory in heap to decompress file.);
   halt;
  end;
s:=paramstr(1);
setdecodeinbuffer(@readfromfile);
assign(f,s);
{$i-}
  if s<> then reset(f,1);
{$i+}
if (ioresult<>0) or (s=) then
  begin
   writeln;
   writeln(the author of this turbo pascal program and original c++ code is);
   writeln(alexander larkin   ( translated to turbo pascal from c++ on 27/09/1999 ));
   writeln;
   writeln(e-mail:      avlarkin@writeme.com);
   writeln(internet:    http://www.geocities.com/siliconvalley/6235/tpdl.htm);
   writeln;
   writeln(usage: decode.exe infile outfile [password]);
   writeln;
   freememory;
   halt;
  end;
s:=paramstr(2);
assign(f1,s);
{$i-}
if s<> then rewrite(f1,1);
{$i+}
if (ioresult<>0) or (s=) then
  begin
   close(f);
   writeln(cannot create file +s);
   freememory;
   halt;
  end;
  getmem(buf,bufsize);
  setpassword(paramstr(3));
   repeat
    num:=decodeget(buf^,bufsize);
    if num<65535 then blockwrite(f1,buf^,num,num);
   until (num=0) or (num=65535);
if num=65535 then writeln(error! data corrupted. cannot decompress file.);
close(f);
close(f1);
freememory;
end.

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 一个C++及Delphi做的压缩程序-.NET教程,Windows开发
分享到: 更多 (0)