原文 http://zwkufo.blog.163.com/blog/static/2588251201063033524889/

; 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}\rundll32.exe'), 'advpack.dll,LaunchINFSection '+AddQuotes(ExpandConstant(InfFile))+','+ExpandConstant(InfSection), ExpandConstant('{src}'), SW_HIDE, ewWaitUntilTerminated, ResultCode) then
  {如果上面的代码有问题,就改用下面这行}
//  if Exec(ExpandConstant('{sys}\rundll32.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}\test.inf');
  srcinf:= ExpandConstant('{src}\test.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;

【from http://www.ppcqq.com/read.php?217

Inno Setup 安装inf文件的一个例子的更多相关文章

  1. Inno setup 安装*.inf文件_示例

    nno setup 调用*.Inf文件的条目区段名称_示例 首先自己编写一个INF文件来供 Inno setup 进行测试: ;复制以下代码到记事本然后另存为123.inf .然后把123.inf文件 ...

  2. 一个比较完整的Inno Setup 安装脚本(转)

    一个比较完整的Inno Setup 安装脚本,增加了对ini文件设置的功能,一个安装包常用的功能都具备了. [Setup] ; 注: AppId的值为单独标识该应用程序. ; 不要为其他安装程序使用相 ...

  3. 一个比较完整的Inno Setup 安装脚本

    一个比较完整的Inno Setup 安装脚本,增加了对ini文件设置的功能,一个安装包常用的功能都具备了. [Setup] ; 注: AppId的值为单独标识该应用程序. ; 不要为其他安装程序使用相 ...

  4. 直接用bat命令对Inno Setup的脚本文件.iss进行编译

    直接用bat命令对Inno Setup的脚本文件.iss进行编译 2010-06-17 15:17 qjn0059 | 浏览 2163 次 编程语言外语学习 分享到:   2010-06-29 11: ...

  5. Inno Setup 安装、卸载前检测进程或服务

    [转载]Inno Setup 安装.卸载前检测进程或服务 (2015-04-24 17:37:20) 转载▼ 标签: 转载   原文地址:Inno Setup 安装.卸载前检测进程或服务作者:一去丶二 ...

  6. Inno Setup 安装前卸载原程序

    Inno Setup 安装前卸载原程序 分类: Install Setup 2013-02-02 15:53 2315人阅读 评论(0) 收藏 举报 很多時候我們需要在安裝文件之前卸載原有的程序而不是 ...

  7. Inno Setup 安装

    Inno Setup 安装 一.软件下载:http://www.jrsoftware.org/isdl.php#qsp 二.下载后,双击进行安装(包括inno Setup Compiler和Inno ...

  8. inno setup 安装前判断进程是否存在,以及停止相应进程<转>

    打包的时候遇到了这样的需求:假似用户都是傻瓜                  式操作,如果更新安装程序的时候,之前的老程序还在运行这个时候如果你去提示让用户吧老程序手动退掉也不现实. 所以当遇到这种 ...

  9. Inno Setup 打包的文件以管理员权限执行

    最近发现一个问题,就是Inno Setup打包的程序安装完毕后执行需求管理员权限的程序的时候会失败( inno createprocess   须要提升),解决问题的最简单办法就是打包的后的程序也以管 ...

随机推荐

  1. hdu 4620 Fruit Ninja Extreme

    Fruit Ninja Extreme Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  2. MATLAB三维曲面

    今天终于测试了,发下来第一张试卷中只会做一小题.我蒙了!!! 所以呢,我现在再做一下,总结总结! 作函数 f(x)=2(x1-1)4+2x22 的三维图. 这道题要用到的知识点有函数meshgrid. ...

  3. poj 2299 Ultra-QuickSort(归并排序或是bit 树+离散化皆可)

    题意:给一个数组,计算需要的冒泡排序的次数,元素个数很大,不能用n^2的冒泡排序计算. 解析:这题实际上就是求逆序对的个数,可以用归并排序的方法,我这里用另一种方法写,bit树+离散化.由于元素的值可 ...

  4. POJ3268 Silver Cow Party(dijkstra+矩阵转置)

    Silver Cow Party Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15156   Accepted: 6843 ...

  5. canvas动画文字效果

    Doughnut Chartvar c=document.getElementById("canvas");var ctx=c.getContext("2d") ...

  6. 通过项目逐步深入了解Mybatis<四>

    延迟加载 什么是延迟加载? resultMap可以实现高级映射(使用association.collection实现一对一及一对多映射),association.collection具备延迟加载功能. ...

  7. 从决策树学习谈到贝叶斯分类算法、EM、HMM

    从决策树学习谈到贝叶斯分类算法.EM.HMM                (Machine Learning & Recommend Search交流新群:172114338) 引言 log ...

  8. Html、CSS、JavaScript 实时效果在线编辑器 - 学习的好工具,算不算?!

    关于 二维码 与 NFC 之间的出身贫贱说 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 ...

  9. 忘记root密码修改方法

    好吧,不想重新装(那耗费的时间真心伤不起…),找修改root密码的方法,结果还真找到了… 首先在虚拟机启动时,在Grub界面按“e”进入编辑 在linux /vmlinuz那行后面添加“init=/b ...

  10. ComponentName的意思

    ComponentName是用来打开其它应用程序中的Activity或服务的. 使用方法: Intent i=new Intent(); i.setComponent(new ComponentNam ...