我知道winrar的图形界面下制作自解压文件怎么做,但是现在要把这个制作过程通过程序实现,不能有winrar界面出现,是不是可以用winrar命令行,但是我不知道将自解压命令的参数写在什么地方,比如自解压文件图标,标题,解压完成后运行的程序等等一些参数,这些东西都写在哪?如何实现?

解决方案 »

  1.   

    用这个研究研究HINSTANCE ShellExecute(    HWND hwnd, // handle to parent window
        LPCTSTR lpOperation, // pointer to string that specifies operation to perform
        LPCTSTR lpFile, // pointer to filename or folder name string
        LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters 
        LPCTSTR lpDirectory, // pointer to string that specifies default directory
        INT nShowCmd  // whether file is shown when opened
       );
      

  2.   

    两个连接,参考一下http://topic.csdn.net/t/20030617/14/1925512.html
    DELPHI怎样调用WINRAR压缩文件http://www.anywolfs.com/liuhui/article.asp?id=256
    WINRAR命令行简体中文说明 
      

  3.   


    delphi调用winrar好弄,关键问题是,那一堆的自解压参数写在哪
      

  4.   

    用1楼的
    参数写这里
    LPCTSTR lpParameters,
      

  5.   


    你说的参数是WinRAR.exe S -ibck -r -k -o+ -y 1.EXE bin\*.* 后面的这些参数吧,我说的参数是自解压命令中的参数,比如解压后运行,执行程序图标,快捷方式等,如下
    Path=c:\Bin6
    SavePath
    Setup=UpGrade.exe
    Title=********系统
    Text
    {
    ******系统
    }
    Shortcut=D, "main.exe", "", "******系统", "******系统", "main.exe"
      

  6.   

    unsigned,别贴些没用的,这些东西谁都会去看,用不着你往这贴
      

  7.   


    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ShellAPI, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      ShellExecute(0, 'open', 'C:\Program Files\WinRAR\WinRar.exe', 'a  abc.rar Unit1.pas', 0, SW_SHOW );
    end;end.
      

  8.   

    @kampan
    请注意,我要做的是自解压文件,不是压缩包
      

  9.   

    解压  ShellExecute(0, 'open', 'C:\Program Files\WinRAR\WinRar.exe', 'e  abc.rar ', 0, SW_SHOW );
      

  10.   

    @kampan 
    那自解压的那些参数呢,怎么设置
      

  11.   

    仔细看1楼说的那个函数,你查MSDN,好好看看,另外你看winrar安装后 开始-》程序-》winrar->控制台 RAR 中文手册
    所有的命令行参数都在里边
      

  12.   

    除了e 外,x应该也可以,我没试,你自己试试看
        x       带绝对路径解压            例子:            rar x -av- -c- dime 10cents.txt            解压指定的文件到当前路径。AV 检查和注释显示被禁用。
      

  13.   

    我要的是一个切实运行通过的例子,命令行我也试过好多,都不行才过来提问的,光说看winrar手册,msdn谁都会说的,谁都会去看,100那么好赚啊
      

  14.   

    你看过winrar自解压命令参数了吗?或者你看看我6楼写的那些参数,难道这么一大堆东西全都放到LPCTSTR lpParameters中,你感觉可能吗?我只是想你看清楚我的问题再作答,先看清楚问题!!
      

  15.   

    var
      rar: String;
      MyFile: String;
      desc: TStringList;
      hi: HICON;
      ico: TICON;
    begin
      OpenDialog1.Title := '请选择Winrar.exe';
      OpenDialog1.FileName := 'winrar.exe';
      OpenDialog1.Filter := 'Winrar.exe|winrar.exe';
      OpenDialog1.Options := [ofPathMustExist, ofFileMustExist];
      if Not OpenDialog1.Execute then Exit;
      rar := OpenDialog1.FileName;
      OpenDialog1.Title := '请选择打包的可执行文件';
      OpenDialog1.FileName := 'project1.exe';
      OpenDialog1.Filter := '*.exe|*.exe';
      if Not OpenDialog1.Execute  then Exit;
      MyFile := OpenDialog1.FileName;
      desc := TStringList.Create;
      try
        desc.Add('Title=Test self Extract');
        desc.Add('Silent=1');
        desc.Add('TempMode');
        desc.Add('Setup='+ExtractFileName(MyFile));
        desc.Add('Overwrite=1');
        desc.SaveToFile('mydesc.txt');
        hi:=ExtractIcon( HInstance,PAnsiChar(Application.ExeName),0);
        ico := TIcon.Create;
        try
          ico.Handle := hi;
          ico.SaveToFile('myico.ico');
        finally
          ico.Free;
        end;
        Shellexecute(Handle,'open',PAnsiChar('"'+rar+'"'),PAnsiChar('a -ibck -zmydesc.txt -iiconmyico.ico -ep -sfx '+ChangeFileExt( ExtractFileName(MyFile), '.sfx.exe')+' "'+MyFile+'"'),Nil,SW_SHOW);
        Shellexecute(Handle,'open','explorer.exe','.\',Nil,SW_SHOW);
      finally
        desc.Free;
      end;
    end;