home *** CD-ROM | disk | FTP | other *** search
/ Image Master / L80.iso / Yyong / compreg / COMPREG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-04-22  |  3.5 KB  |  133 lines

  1. {$M 8192,0,0}
  2. uses crt,dos;
  3.  
  4. {╙├└┤╡≈╙├command.com═Ω│╔═Γ▓┐├ⁿ┴ε}
  5. procedure rundoscommand(command:string);
  6. begin
  7. Command := '/C ' + Command;
  8. SwapVectors;
  9. Exec(GetEnv('COMSPEC'), Command);
  10. SwapVectors;
  11. end;
  12.  
  13. {╝∞▓Γ╩╟╖±╡▒╟░╗╖╛│╩╟╖±╬¬windos╧┬╡─MS-DOS BOX}
  14. function inwindows:boolean;
  15. const envname:array[1..6] of char=('w','i','n','d','i','r');
  16. var temp:boolean;
  17.    six,loop:byte;
  18.    tempstr:string;
  19. begin
  20. for loop:=1 to envcount do
  21.   begin
  22.   temp:=true;
  23.   tempstr:=envstr(loop);
  24.   for six:=1 to 6 do
  25.    if tempstr[six]<>envname[six] then temp:=false;
  26.   if temp then
  27.     loop:=envcount;
  28.   end;
  29. inwindows:=temp;
  30. end;
  31.  
  32. {╗±╡├▓ó╖╡╗╪win95╡─░▓╫░┬╖╛╢}
  33. function getsyspath:string;
  34. const envname:array[1..10] of char=('w','i','n','b','o','o','t','d','i','r');
  35. var temppath,tempstr:string;
  36.     ten,loop:byte;
  37.     found:boolean;
  38. begin
  39. temppath:='';
  40. for loop:=1 to envcount do
  41.   begin
  42.   found:=true;
  43.   tempstr:=envstr(loop);
  44.   for ten:=1 to 10 do
  45.    if tempstr[ten]<>envname[ten] then found:=false;
  46.   if found then
  47.     begin
  48.     for loop:=12 to length(tempstr) do
  49.       temppath:=temppath+tempstr[loop];
  50.     loop:=envcount;
  51.     end;
  52.   end;
  53. getsyspath:=temppath+'\';
  54. end;
  55.  
  56. {╗±╚í╓╕╢¿╬─╝■╡─┤≤╨í}
  57. function filesize(filename:string):longint;
  58. var
  59.  DirInfo: SearchRec;
  60. begin
  61.  FindFirst(filename, anyfile, DirInfo);
  62.  filesize:=dirinfo.size;
  63. end;
  64.  
  65. {╕∙╛▌▓╬╩²╛÷╢¿╩╟╖±╥¬▒╕╖▌╫ó▓ß▒φ}
  66. function backup:boolean;
  67. var loop:byte;
  68.     temp:boolean;
  69.     ch:char;
  70. begin
  71. temp:=false;
  72. if paramcount > 0 then
  73.   for loop:=1 to paramcount do
  74.     begin
  75.     if (paramstr(loop)='/Y') or (paramstr(loop)='/y') then
  76.       temp:=true;
  77.     if temp then loop:=paramcount;
  78.     end
  79.   else
  80.     begin
  81.     write('Do you want to backup the regstry file to REGCBACK.REG? ');
  82.     repeat
  83.     write(chr(7));
  84.     gotoxy(wherex-1,wherey);
  85.     ch:=readkey;
  86.     until ch in ['y','Y','n','N'];
  87.     if ch in ['y','Y'] then
  88.       temp:=true
  89.       else temp:=false;
  90.     writeln(ch);
  91.     end;
  92. backup:=temp;
  93. end;
  94.  
  95. var syspath:string;{win95░▓╫░┬╖╛╢}
  96.     orisize,aftersize:longint;
  97.     needbackup:boolean;
  98.  
  99. begin
  100. if dosversion<>7 then {┼╨╢╧╩╟╖±╬¬DOS 7.0╗╖╛│}
  101.   write(chr(7),'Dos Version Error, Require DOS 7.0 to run it.')
  102.   else
  103.   begin
  104.   syspath:=getsyspath;{╗±╚íwin95░▓╫░┬╖╛╢}
  105.   writeln('Chen Danian''s Registry Compressor For win95    Version 2.0');
  106.   writeln('Get technical support at   http://hamlet.yeah.net  now!');
  107.   writeln('Contact me via e-mail     tocdn@163.net',chr(10));
  108.   needbackup:=backup;{╗±╚í╣╪╙┌╙├╗º╩╟╖±╥¬╟≤▒╕╖▌╫ó▓ß▒φ╡├╛÷╢¿}
  109.   rundoscommand('attrib '+syspath+'system.dat -a -s -h -r');
  110.   rundoscommand('attrib '+syspath+'user.dat -a -s -h -r');
  111.   orisize:=filesize(syspath+'system.dat');
  112.   orisize:=orisize+filesize(syspath+'user.dat');
  113.   if inwindows then{╚τ╣√╡▒╟░╘╦╨╨╗╖╛│╩╟windos95╡─MS-DOS BOX ╛══╦│÷}
  114.     write(chr(7),'Do not use it under windows!')
  115.   else
  116.   begin
  117.     writeln('Please wait for preparing...');
  118.     rundoscommand(syspath+'regedit /e regcback.reg');
  119.     writeln('Start compressing...',chr(10));
  120.     rundoscommand(syspath+'regedit /c regcback.reg');
  121.     if not needbackup then
  122.     rundoscommand('delete tempreg.tmp');
  123.     aftersize:=filesize(syspath+'system.dat');
  124.     aftersize:=aftersize+filesize(syspath+'user.dat');
  125.     writeln('Result Report');
  126.     writeln('>>>>>>>>>>>>>');
  127.     writeln('Original Registry Size:  ',orisize);
  128.     writeln('After Compress:  ',aftersize);
  129.     writeln('===============================');
  130.     writeln('Compressing Rate:  ',orisize/aftersize*100:3:2,'%');
  131.   end;
  132.   end;
  133. end.