zoukankan      html  css  js  c++  java
  • Inno Setup 安装inf文件的一个例子

     INF安装例子


    [Setup]
    ; 注意: AppId 的值是唯一识别这个程序的标志。
    ; 不要在其他程序中使用相同的 AppId 值。
    ; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
    AppId={{DC1559D2-A4CC-471F-8FDF-45F4278AFAEA}
    AppName=我的程序
    AppVerName=我的程序 1.5
    AppPublisher=我的公司
    AppPublisherURL=http://www.example.com/
    AppSupportURL=http://www.example.com/
    AppUpdatesURL=http://www.example.com/
    DefaultDirName={pf}我的程序
    DefaultGroupName=我的程序
    OutputBaseFilename=setup
    Compression=lzma
    SolidCompression=yes

    [Languages]
    Name: "chinese"; MessagesFile: "compiler:Default.isl"

    [Tasks]
    Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

    [Files]
    Source: "test.inf"; Flags: dontcopy

    [code]
    //安装inf的函数
    function InstallInf(const InfFile, InfSection: string): Boolean;
    var
      ResultCode: Integer;
    begin
      if Exec(ExpandConstant('{sys} undll32.exe'), 'advpack.dll,LaunchINFSection '+AddQuotes(ExpandConstant(InfFile))+','+ExpandConstant(InfSection), ExpandConstant('{src}'), SW_HIDE, ewWaitUntilTerminated, ResultCode) then
      {如果上面的代码有问题,就改用下面这行}
    //  if Exec(ExpandConstant('{sys} undll32.exe'), 'setupapi,InstallHinfSection '+ExpandConstant(InfSection)+' 132 '+AddQuotes(ExpandConstant(InfFile)), ExpandConstant('{src}'), SW_HIDE, ewWaitUntilTerminated, ResultCode) then
        Result:= (ResultCode = 1); {假设正常安装的返回代码是1的话}
    end;

    //定义按钮和要执行的操作
    procedure MyButtonOnClick(Sender: TObject);
    var
      tmpinf, srcinf: String;
      bbb: Boolean;
    begin
      tmpinf:= ExpandConstant('{tmp} est.inf');
      srcinf:= ExpandConstant('{src} est.inf');
      ExtractTemporaryFile('test.inf'); //解压文件
      if RenameFile(tmpinf, srcinf) then  //移动文件到程序所在目录
        if InstallInf(srcinf, 'DefaultInstall') then
        //ShellExec('Install', srcinf, '', ExpandConstant('{src}'), SW_SHOW, ewWaitUntilTerminated, ResultCode) then  //安装inf
          bbb := True;
      //处理返回代码
      if bbb then
        MsgBox('安装成功!!', mbInformation, MB_OK) else
      begin
        MsgBox('安装失败!!', mbCriticalError, MB_OK);
      end;
      DeleteFile(srcinf);
    end;

    //创建按钮
    procedure InitializeWizard();
    var
      MyButton: TButton;
    begin
      with WizardForm do
      begin
        MyButton := TButton.Create(WizardForm);
        with MyButton do begin
          Left := ScaleX(208);
          Top := ScaleX(192);
          Width := ScaleX(75);
          Height := ScaleX(23);
          Caption := '安装inf';
          OnClick := @MyButtonOnClick; //按钮点击事件
          Parent := WizardForm;
        end;
      end;
    end;


    procedure CurPageChanged(CurPageID: Integer);
    var
      ResultCode: Integer;
    begin
      if CurPageID = wpWelcome then
        WizardForm.NextButton.Enabled:= False; //禁用下一步按钮
    end;

  • 相关阅读:
    FileUpload1上传控件
    docker如何push镜像到docker hub个人的仓库
    docker的ubuntu镜像无ifconfig和ping命令
    keystone同步数据库的时候提示error
    openstack安装dashboard后访问horizon出错 500 or 504
    装了ubuntu之后,只能进入ubuntu系统,不能进入windows系统
    Kernal Panic
    无法获得锁 /var/lib/dpkg/lock -open
    用户 'NT AUTHORITYIUSR' 登录失败
    配置错误:不能在此路径中使用此配置节。
  • 原文地址:https://www.cnblogs.com/zhangzhifeng/p/6549245.html
Copyright © 2011-2022 走看看