我是新手,正在用ZipTV里的unrar控件编一可以解压缩带密码的.rar文件.可是不知道应该怎么处理密码的问题,请大家帮帮忙,先谢谢大家.
程序如下:
if       OpenDialog1.Execute       then 
begin 
UnRar1.ArchiveFile:=OpenDialog1.FileName; 
UnRar1.ExtractDir:='c:\aa'; 
UnRar1.FileSpec.Add('*.*'); 
UnRar1.RecurseDirs:=True; 
ShowMessage(IntToStr(UnRar1.Extract));
但是密码应该怎么输入程序,如果密码不正确的话又会返回什么参数.
大家帮帮忙.想了快一星期了,头都大了. 

解决方案 »

  1.   

    或者可以参考Demo:
    (*
       This demo was updated to support unicode and the TNT unicode controls. See ..\unicode_notes.txt for usage notes on the TNT_UNICODE
       conditional define (the file is in [ziptv install dir]\demos).  *)
    Unit Unit1;InterfaceUses
       Windows,
       Messages,
       SysUtils,
       Classes,
       Graphics,
       Controls,
       Forms,
       Dialogs,
       StdCtrls,   ztvRegister,
       ztvBase,
       ztvConsts, // _String unicode
       ztvUnRar,
       ztvGbls;Type
       TForm1 = Class(TForm)
          Button1: TButton;
          UnRAR1: TUnRAR;
          CheckBox1: TCheckBox;
        Button2: TButton;
          Procedure Button1Click(Sender: TObject);
    {$ifdef TNT_UNICODE}
          Procedure UnRar1GetPassword(Sender: TObject; FileName: WideString;
           Var Password: String; Var HeaderKeys, DataKeys: TSeedKeyRecord;
             Var TryAgain: Boolean);
    {$else}
          Procedure UnRar1GetPassword(Sender: TObject; FileName: String;
             Var Password: String; Var HeaderKeys, DataKeys: TSeedKeyRecord;
             Var TryAgain: Boolean);
        procedure Button2Click(Sender: TObject);
    {$endif TNT_UNICODE}
       Private
          { Private declarations }
       Public
          { Public declarations }
       End;Var
       Form1: TForm1;Implementation{$R *.DFM}
    //-------------------------------------------------------------Procedure TForm1.Button1Click(Sender: TObject);
    Begin
       UnRAR1.ArchiveFile := 'd:\3\rar\exes.rar';
       UnRAR1.ExtractDir := 'c:\hold1\';
       UnRAR1.UseStoredDirs := CheckBox1.Checked;
       UnRAR1.DateAttribute := daFileDate;
       UnRAR1.ConfirmOverwrites := False;
       UnRAR1.OverwriteMode := omOverwrite;
       UnRAR1.RestoreFileAttr := False;
       UnRAR1.CreateStoredDirs := False;
       UnRAR1.TranslateOemChar := True;
       UnRAR1.RecurseDirs := True;
       UnRAR1.VolumeName := '';
       UnRAR1.FileSpec.Clear();
       //unRar1.FileSpec.Add('SRC\ATL.CPP');
       UnRAR1.FileSpec.Add('*.*');
       UnRAR1.RecurseDirs := True;
       UnRAR1.Extract();
       ShowMessage(IntToStr(UnRAR1.Count));
    End;
    //-------------------------------------------------------------Procedure TForm1.UnRar1GetPassword(Sender: TObject; FileName: _String;
      Var Password: String; Var HeaderKeys, DataKeys: TSeedKeyRecord;
      Var TryAgain: Boolean);
    Begin
    //Password := '-0-OSPREY-0-RAID-0-';
    End;
    //-------------------------------------------------------------procedure TForm1.Button2Click(Sender: TObject);
    begin
    UnRar1.Cancel := True;
    end;End.