bsSkinUnZip.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:6k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. {*******************************************************************}
  2. {                                                                   }
  3. {       Almediadev Visual Component Library                         }
  4. {       BusinessSkinForm                                            }
  5. {       Version 1.98                                                }
  6. {                                                                   }
  7. {       Copyright (c) 2000-2003 Almediadev                          }
  8. {       ALL RIGHTS RESERVED                                         }
  9. {                                                                   }
  10. {       Home:  http://www.almdev.com                                }
  11. {       Support: support@almdev.com                                 }
  12. {                                                                   }
  13. {*******************************************************************}
  14. unit bsSkinUnZip;
  15. interface
  16. uses
  17.   Windows, Messages, SysUtils, Classes;
  18. type
  19.   TDllPrnt = function(Buffer: PChar; Size: ULONG): integer; stdcall;
  20.   TDllPassword = function(P: PChar; N: Integer; M, Name: PChar): integer; stdcall;
  21.   TDllService = function (CurFile: PChar; Size: ULONG): integer; stdcall;
  22.   TDllSnd = procedure; stdcall;
  23.   TDllReplace = function(FileName: PChar): integer; stdcall;
  24.   TDllMessage = procedure (UnCompSize: ULONG; CompSize: ULONG; Factor: UINT;
  25.                            Month: UINT; Day: UINT; Year: UINT; Hour: UINT;
  26.                            Minute: UINT; C: Char;
  27.                            FileName: PChar; MethBuf: PChar; CRC: ULONG;
  28.                            Crypt: Char); stdcall;
  29.   TUserFunctions = record
  30.     Print: TDllPrnt;
  31.     Sound: TDllSnd;
  32.     Replace: TDllReplace;
  33.     Password: TDllPassword;
  34.     SendApplicationMessage: TDllMessage;
  35.     ServCallBk: TDllService;
  36.     TotalSizeComp: ULONG;
  37.     TotalSize: ULONG;
  38.     CompFactor: Integer;
  39.     NumMembers: UINT;
  40.     cchComment: UINT;
  41.   end;
  42.   TDCL = record
  43.     ExtractOnlyNewer: Integer;
  44.     SpaceToUnderscore: Integer;
  45.     PromptToOverwrite: Integer;
  46.     fQuiet: Integer;
  47.     nCFlag: Integer;
  48.     nTFlag: Integer;
  49.     nVFlag: Integer;
  50.     nUFlag: Integer;
  51.     nZFlag: Integer;
  52.     nDFlag: Integer;
  53.     nOFlag: Integer;
  54.     nAFlag: Integer;
  55.     nZIFlag: Integer;
  56.     C_flag: Integer;
  57.     fPrivilege: Integer;
  58.     lpszZipFN: PChar;
  59.     lpszExtractDir: PChar;   
  60.   end ;
  61.   TbsSkinUnZip = class(TComponent)
  62.   protected
  63.     procedure SetUserFunctions(var UF: TUserFunctions);
  64.     procedure SetUnZipOptions(var AOptions: TDCL; var AFileName, ADirName: PChar);
  65.   public
  66.     procedure UnZipToDir(AFileName, ADir: String);
  67.   end;
  68. function DllPrnt(Buffer: PChar; Size: ULONG): integer; stdcall;
  69. function DllPassword(P: PChar; N: Integer; M, Name: PChar): integer; stdcall;
  70. function DllReplace(FileName: PChar): integer; stdcall;
  71. function DllService(CurFile: PChar; Size: ULONG): integer; stdcall;
  72. procedure DllMessage(UnCompSize: ULONG; CompSize: ULONG; Factor: UINT;
  73.                      Month: UINT; Day: UINT; Year: UINT;
  74.                      Hour: UINT; Minute: UINT; C: Char;
  75.                      FileName: PChar; MethBuf: PChar;
  76.                      CRC: ULONG; Crypt: Char); stdcall;
  77. implementation
  78. uses ShellApi;
  79. type
  80.   PPChar = ^PChar;
  81. const
  82.   UNZIPDLLNAME = 'unzip32.dll';
  83. function DllPrnt(Buffer: PChar; Size: ULONG): integer;
  84. begin
  85.   Result := Size;
  86. end;
  87. function DllReplace(FileName: PChar): integer;
  88. begin
  89.   Result := 1;
  90. end;
  91. function DllPassword(P: PChar; N: Integer; M, Name: PChar): integer;
  92. begin
  93.   Result := 1;
  94. end;
  95. function DllService(CurFile: PChar; Size: ULONG): integer;
  96. begin
  97.   Result := 0;
  98. end;
  99. procedure DllMessage(UnCompSize: ULONG; CompSize: ULONG; Factor: UINT;
  100.                      Month: UINT; Day: UINT; Year: UINT; Hour: UINT; Minute: UINT;
  101.                      C: Char; FileName: PChar; MethBuf: PChar; CRC: ULONG;
  102.                      Crypt: Char);
  103. begin
  104. end;
  105. procedure TbsSkinUnZip.SetUserFunctions;
  106. begin
  107.   with UF do
  108.   begin
  109.     @Print := @DllPrnt;
  110.     @Replace := @DllReplace;
  111.     @Sound := nil;
  112.     @Password := @DllPassword;
  113.     @SendApplicationMessage := @DllMessage;
  114.     @ServCallBk := @DllService;
  115.   end;
  116. end;
  117. procedure TbsSkinUnZip.SetUnZipOptions;
  118. begin
  119.   with AOptions do
  120.   begin
  121.     ExtractOnlyNewer := 0;
  122.     SpaceToUnderscore := 0;
  123.     PromptToOverwrite := 1;
  124.     fQuiet := 0;
  125.     nCFlag := 0;
  126.     nTFlag := 0;
  127.     nVFlag := 0;
  128.     nUFlag := 0;
  129.     nZFlag := 0;
  130.     nDFlag := 0;
  131.     nOFlag := 0;
  132.     nAFlag := 0;
  133.     nZIFlag := 0;
  134.     C_flag := 1;
  135.     fPrivilege := 1;
  136.     lpszExtractDir := ADirName;
  137.     lpszZipFN := AFileName;
  138.   end;
  139. end;
  140. procedure TbsSkinUnZip.UnZipToDir;
  141. var
  142.   UserFunctions: TUserFunctions;
  143.   Opt: TDCL;
  144.   FileName, DirName: PChar;
  145.   UnZip32: Cardinal;
  146.   Wiz_SingleEntryUnzip: function (ifnc: Integer; ifnv: PPChar; xfnc: Integer;
  147.                                   xfnv: PPChar; var Options: TDCL;
  148.                                   var UserFunc: TUserFunctions): Integer; stdcall;
  149. begin
  150.   UnZip32 := LoadLibrary(UNZIPDLLNAME);
  151.   if UnZip32 <> 0
  152.   then
  153.     begin
  154.       Wiz_SingleEntryUnzip := GetProcAddress(UnZip32, 'Wiz_SingleEntryUnzip');
  155.       if (@Wiz_SingleEntryUnzip <> nil)
  156.       then
  157.         begin
  158.           FileName := PChar(AFileName);
  159.           DirName := PChar(ADir);
  160.           SetUserFunctions(UserFunctions);
  161.           SetUnZipOptions(Opt, FileName, DirName);
  162.           WIZ_SingleEntryUnzip(0, nil, 0, nil, Opt, UserFunctions);
  163.         end;
  164.       FreeLibrary(UnZip32);
  165.     end;
  166.  end;
  167. end.