用新浪微博登录

只需一步,快速搞定

 找回密码
 立即注册

用新浪微博登录

只需一步,快速搞定

查看: 6712|回复: 3
打印 上一主题 下一主题

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

[复制链接]

该用户从未签到

667

主题

2111

帖子

5570

积分

LV 11.会员

MS爱好者!!!!

积分
5570

社区居民偶尔光临工蜂最爱沙发在线达人社区平民做个有钱人略有小成常驻会员忠实会员

跳转到指定楼层
楼主
发表于 2011-12-16 21:58:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式 |          
从网上搜索来的,增加了对ini文件设置的功能,一个安装包常用的功能都具备了。

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{A9861883-31C5-4324-BD9A-DC3271EEB675}
;程序名
AppName=ISsample
;版本号
AppVerName=ISsample 1.0.0.0
;发布者名
AppPublisher=Hkiss
;相关连接
AppPublisherURL=http://www.yan.com/
AppSupportURL=http://www.yan.com/
AppUpdatesURL=http://www.yan.com/
;默认安装目录
DefaultDirName={pf}\ISsample
;默认开始菜单名
DefaultGroupName=ISsample
;是否打开->可选安装开始菜单项
;AllowNoIcons=yes
;安装协议
;LicenseFile=C:\Example\原始文件\agreement.txt
;安装前查看的文本文件
;InfoBeforeFile=C:\Example\原始文件\Setup_New.txt
;安装后查看文本文件
;InfoAfterFile=C:\Example\原始文件\Setup_Old.txt
;输出文件夹
OutputDir=C:\Example\InnoSetup\out
;输出文件名
OutputBaseFilename=setup
;安装图标
SetupIconFile=C:\Example\原始文件\title.ico
;安装需要输入密码
assword=123
;Encryption=yes
;压缩相关
Compression=lzma
SolidCompression=yes
;可以让用户忽略选择语言相关
ShowLanguageDialog = yes
;备注版本信息
VersionInfoCompany=HTTP://www.Hkiss.COM
VersionInfoDescription=ISsample 汉化增强版
VersionInfoVersion=1.0.0.0
VersionInfoCopyright=Copyright (C) 2007-2008 Hkiss
;制作选择语言
[Languages]
Name: "chs"; MessagesFile: "compilerefault.isl" ;LicenSeFile :"C:\Example\原始文件\chs\agreement.txt"
Name: "en"; MessagesFile: "compileranguages\English.isl";LicenSeFile :"C:\Example\原始文件\en\agreement.txt"
;用户定制任务
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "Tasks_1" ; Description:"用户自定义任务1"; Flags: unchecked
Name: "Tasks_2" ; Description:"用户自定义任务2"; Flags: unchecked
;选择了组件才会出现的定制任务
Name: "Tasks_3" ; Description:"用户自定义任务3";Components: c1 ; Flags: unchecked
;文件安装
[Files]
;多语言安装环境设置    公共参数Languages 来设置
Source: "C:\Example\原始文件\enfile.txt"; DestDir: "{app}"; Languages: en ; Flags: ignoreversion
Source: "C:\Example\原始文件\chsfile.txt"; DestDir: "{app}"; Languages: chs ; Flags: ignoreversion
;用户自定义任务 Tasks
Source: "C:\Example\原始文件\Tasks\tasks_1.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks : Tasks_1
Source: "C:\Example\原始文件\Tasks\tasks_2.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks :Tasks_2
Source: "C:\Example\原始文件\Tasks\tasks_Components.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks :Tasks_2
;用户定义组件安装
Source: "C:\Example\原始文件\Components\Components_1.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a1;
Source: "C:\Example\原始文件\Components\Components_2.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a2;
Source: "C:\Example\原始文件\Components\Components_3.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a3;
Source: "C:\Example\原始文件\Components\Components_4.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a1 a2 a3;
;用户注册自定义Dll文件      regserver 注册 noregerror 不显示错误信息
Source: "C:\Example\原始文件\jmail.dll"; DestDir: "{app}"; Flags: ignoreversion regserver
;添加自述文件
Source: "C:\Example\原始文件\ISsample.txt"; DestDir: "{app}"; Flags: ignoreversion
;添加一个文件到缓存文件夹{Tmp} deleteafterinstall 安装后删除
Source: "C:\Example\原始文件\test.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
Source: "C:\Example\原始文件\ISsample.chm"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.rar"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample_sys.dll"; DestDir: "{win}\System32"; Flags: ignoreversion
Source: "C:\Example\原始文件\log\*"; DestDir: "{app}\log"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
;安装类型设置
[Types]
Name: Full ;Description:"完全安装"; Flags: iscustom
Name: Compact ;Description:"简洁安装";
Name: Custom; Description:"自定义安装";
;组件安装
[Components]
Name: c1; Description: "自定义任务3" ; Types: Full
Name: a1; Description: "安装Components_1"; Types: Full Compact Custom ;
Name: a2; Description: "安装Components_2"; Types : Full   Compact
Name: a3; Description: "安装Components_3"; Types : Full
;开始菜单,桌面快捷方式
[Icons]
Name: "{group}\ISsample"; Filename: "{app}\ISsample.exe"
Name: "{group}\{cmrogramOnTheWeb,ISsample}"; Filename: "http://www.yan.com/"
Name: "{group}\{cm:UninstallProgram,ISsample}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: quicklaunchicon
;添加一个帮助文挡
Name: {group}\ISsample 1.0.0.0 帮助文档;Filename: {app}\ISsample.chm
;用来在程序安装完成后 在安装程序显示最终对话框之前执行程序 常用与运行主程序 显示自述文件 删除临时文件
[Run]
Filename: "{app}\ISsample.exe"; Description: "{cm:LaunchProgram,ISsample}"; Flags: nowait postinstall skipifsilent
Filename: "{app}\ISsample.txt"; Description: "查看显示自述文件"; Flags: postinstall skipifsilent shellexec
;更改显示在程序中显示的消息文本
[Messages]
BeveledLabel=HKiss科技
;卸载对话框说明
ConfirmUninstall=您真的想要从电脑中卸载ISsample吗?%n%n按 [是] 则完全删除 %1 以及它的所有组件;%n按 [否]则让软件继续留在您的电脑上.
;定义解压说明
;StatusExtractFiles=解压并复制主程序文件及相关库文件...
;用于在用户系统中创建,修改或删除ini文件健值
[INI]
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Flags: uninsdeletesection
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server ip"; String: "127.0.0.1"
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server port"; String: "8080"
;用于在用户系统中创建,修改或删除注册表健值
[Registry]
Root: HKLM ;SubKey:"Software\ISsample";ValueType:dword;ValueName:config;ValueData:10 ;Flags:uninsdeletevalue
;在执行脚本
[code]
//全局变量
var MyProgChecked: Boolean;
//判断程序是否存在
//初始华程序事件
function InitializeSetup(): boolean;
var Isbl: boolean;         //声明变量
var Isstr: string;
begin       //开始
Isbl := true;             //变量赋值
Isstr := '欢迎';
if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\ISsample', 'config') then
begin
    MsgBox('已安装过,请先卸载在安装',mbConfirmation, MB_OK);
    isbl := false;
end else
begin
   //MsgBox('无值',mbConfirmation, MB_OK);
     isbl := true;
end;
//下面是个麻烦的 条件语句 end else 注意
//if MsgBox(Isstr, mbConfirmation, MB_OKCANCEL) = IDOK then
//begin
// isbl := true;
// MsgBox('执行了', mbConfirmation, MB_OK);
//end else
//begin
// isbl := false;
//MsgBox('执行了', mbConfirmation, MB_OK);
//end;
Result := Isbl;
end;       //结束
procedure CurStepChanged(CurStep: TSetupStep);
var Isstr :string;
begin
if CurStep=ssInstall then       //实际安装前调用
begin
    //MsgBox('CurStepChanged:实际安装前调用', mbConfirmation, MB_OKCANCEL);           //安装完成后调用
end;
if CurStep=ssPostInstall then
begin
    Isstr := ExpandConstant('{tmp}\tmp.rar');
//    if FileExists(Isstr) then
//    begin
//      MsgBox('文件存在',mbConfirmation, MB_OK);
//    end else
//    begin
//      MsgBox('文件不存在',mbConfirmation, MB_OK);
//    end;
   // MsgBox('CurStepChanged:实际安装后调用', mbConfirmation, MB_OKCANCEL);
end;
end;
//下一步 按钮按钮 事件
function NextButtonClick(CurPageID: Integer): Boolean;
var ResultCode: Integer;
var IsSetup : Boolean;
begin
IsSetup := true ;
case CurPageID of
    wpSelectDir:
       MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardDirValue + '''.', mbInformation, MB_OK);   //WizardDirValue路径
    wpSelectProgramGroup:
       MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardGroupValue + '''.', mbInformation, MB_OK); //开始菜单名
    wpReady:
      begin
       if not RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Test', 'config') then   begin
          if MsgBox('程序执行需要Test.ext,是否安装!', mbConfirmation, MB_YESNO) = idYes then begin
           ExtractTemporaryFile('test.exe');
            if not Exec(ExpandConstant('{tmp}\test.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
              MsgBox('Test.exe出错:' #13#13 ' ' + SysErrorMessage(ResultCode) + '.', mbError, MB_OK);
          end else begin
                IsSetup := false ;
          end ;
          BringToFrontAndRestore();
        end;
      end;
end;
Result := IsSetup;
end;
回复

使用道具 举报

该用户从未签到

667

主题

2111

帖子

5570

积分

LV 11.会员

MS爱好者!!!!

积分
5570

社区居民偶尔光临工蜂最爱沙发在线达人社区平民做个有钱人略有小成常驻会员忠实会员

沙发
 楼主| 发表于 2011-12-16 22:02:33 | 只看该作者
[paragraph]

范例

[Setup]
AppName=迅雷5
AppVerName=迅雷 5.7.2.371 DDR1.5 去广告版
DefaultDirName={pf}\\Thunder\\
DefaultGroupName=迅雷5
OutputBaseFilename=Thunder-ddr5.7.2.371Setup
Compression=lzma
SolidCompression=yes
WizardImageFile=embedded\\WizardImage.bmp
WizardSmallImageFile=embedded\\WizardSmallImage.bmp
AppMutex=thunder5_app_mutex
[Types]
Name: "default"; Description: "默认安装"
Name: "custom"; Description: "自定义安装"; Flags: iscustom
Name: "full"; Description: "完全安装"
[Components]
Name: "main"; Description: "迅雷5"; Types:default custom full; Flags: fixed
Name: &quotlugins"; Description: "其他插件"; Types: full
Name: "Plugins\\kankan"; Description: "迅雷看看"; Types: full
Name: "Plugins\\gougou"; Description: "狗狗搜索排行"; Types: full
Name: "Plugins\\tingting"; Description: "迅雷听听1.2"; Types: full
[Tasks]
Name: desktopicon; Description: "创建桌面快捷方式"; Flags: checkedonce
Name: associate; Description: "在开始菜单创建程序组";Flags: checkedonce
[Files]
;主文件安装
Source: "pureThunder\\*"; DestDir: "{app}"; Flags: recursesubdirs   createallsubdirs ignoreversion
;配置文件安装
Source: "Profiles\\*"; DestDir: "{app}\\Profiles"; Flags:uninsneveruninstall onlyifdoesntexist
;注册文件安装
Source: "comfile\\*"; DestDir: "{app}\\ComDlls"; Flags:ignoreversion regserver   restartreplace   uninsrestartdelete
;迅雷看看安装
Source: "KanKan\\files\\*"; DestDir: "{app}\\Components\\KanKan"; Components: Plugins\\kankan; Flags:ignoreversion
Source: "KanKan\\regdll\\*"; DestDir: "{app}\\Components\\KanKan"; Components: Plugins\\kankan; Flags:ignoreversion regserver   restartreplace   uninsrestartdelete
;狗狗搜索安装
Source: "plugins\\GouGouTop\\*"; DestDir: "{app}\\plugins\\GouGouTop";Components: Plugins\\gougou; Flags: ignoreversion
;听听安装
Source: "plugins\\TingTing\\*"; DestDir: "{app}\\plugins\\TingTing";Components: Plugins\\tingting; Flags: ignoreversion
;复制vc6运行库
Source: "msvcp60.dll"; DestDir:"{sys}\\"; Flags: onlyifdoesntexist uninsneveruninstall
[INI]
;狗狗搜索插件信息写入
Filename: "{app}\\Program\\addins.ini"; Section: "{{1FC7CAC6-2DA8-4cb0-B440-C069956CC0CA}"; Key: "Name"; String: "狗狗搜索排行";Components: Plugins\\gougou
Filename: "{app}\\Program\\addins.ini"; Section: "{{1FC7CAC6-2DA8-4cb0-B440-C069956CC0CA}"; Key: "File"; String: "..\\Plugins\\GouGouTop\\GouGouTop.dll"   ;Components: Plugins\\gougou
Filename: "{app}\\Program\\addins.ini"; Section: "{{1FC7CAC6-2DA8-4cb0-B440-C069956CC0CA}"; Key: "Enable"; String: "1" ;Components: Plugins\\gougou
;迅雷听听插件信息写入
Filename: "{app}\\Program\\addins.ini"; Section: "{{200A93B9-365D-4F4A-9C4F-57F645A7B9D2}"; Key: "Name"; String: "听听插件";Components: Plugins\\tingting
Filename: "{app}\\Program\\addins.ini"; Section: "{{200A93B9-365D-4F4A-9C4F-57F645A7B9D2}"; Key: "File"; String: "..\\Plugins\\TingTing\\TingTing.dll"   ;Components: Plugins\\tingting
Filename: "{app}\\Program\\addins.ini"; Section: "{{200A93B9-365D-4F4A-9C4F-57F645A7B9D2}"; Key: "Enable"; String: "1" ;Components: Plugins\\tingting
[Registry]
Root: HKLM; Subkey: "SOFTWARE\\Thunder Network\\ThunderOem\\thunder_backwnd"; ValueName: "Path"; ValueType: String; ValueData: "{app}\\Thunder.exe"; Flags: uninsdeletekey
Root: HKLM; Subkey: "SOFTWARE\\Thunder Network\\ThunderOem\\thunder_backwnd"; ValueName: "Version"; ValueType: String; ValueData: "5.7.2.371"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Software\\Microsoft\\Internet Explorer\\MenuExt\\使用迅雷下载全部链接"; ValueType: String; ValueData: "{app}\\Program\\GetAllUrl.htm"; Flags: uninsdeletevalue
Root: HKCU; Subkey: "Software\\Microsoft\\Internet Explorer\\MenuExt\\使用迅雷下载全部链接"; ValueName: "Contexts"; ValueType: dword; ValueData: 243; Flags: uninsdeletevalue
Root: HKCU; Subkey: "Software\\Microsoft\\Internet Explorer\\MenuExt\\使用迅雷下载"; ValueType: String; ValueData: "{app}\\Program\\GetUrl.htm"; Flags: uninsdeletevalue
Root: HKCU; Subkey: "Software\\Microsoft\\Internet Explorer\\MenuExt\\使用迅雷下载"; ValueName: "Contexts"; ValueType: dword; ValueData: 34; Flags: uninsdeletevalue
[Run]
Filename: "{app}\\DDR迅雷设置中心.exe"; Description: "运行迅雷设置中心";
;Filename: "{app}\\Program\\SetupHelper.exe"; Parameters: "/register_plugins";
;Filename: "{app}\\Program\\SetupHelper.exe"; Parameters: "/open_firewall";
;Filename: "{app}\\Program\\SetupHelper.exe"; Parameters: "/for_all_users";
[Icons]
Name: "{commondesktop}\\迅雷";Filename: "{app}\\Thunder.exe";Tasks:desktopicon
Name: "{group}\\启动迅雷"; Filename: "{app}\\Thunder.exe";Tasks:associate
Name: "{group}\\DDR迅雷设置中心"; Filename: "{app}\\DDR迅雷设置中心.exe";Tasks:associate
Name: "{group}\\卸载迅雷"; Filename: "{uninstallexe}";Tasks:associate
;[UninstallRun]
;[UninstallDelete]
;Type: filesandordirs ; Name: "{app}";
[Code]
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
   DeleteProfile: string;
   DeleteConfirm: Boolean;
begin
   case CurUninstallStep of
//卸载后的收尾工作
usPostUninstall:
   begin
       // 确认是否删除整个目录
       DeleteProfile := ExpandConstant('{app}');
       DeleteConfirm :=MsgBox('是否保留用户配置文件与历史记录?', mbConfirmation, MB_YESNO) = idYes;
       if DeleteConfirm=False then
         DelTree(DeleteProfile, True, True, True);
       if DeleteConfirm=True then
         DelTree(DeleteProfile+'\\Program',True,True,True);
   end;
   end;
end;
回复 支持 反对

使用道具 举报

该用户从未签到

667

主题

2111

帖子

5570

积分

LV 11.会员

MS爱好者!!!!

积分
5570

社区居民偶尔光临工蜂最爱沙发在线达人社区平民做个有钱人略有小成常驻会员忠实会员

板凳
 楼主| 发表于 2011-12-16 22:16:28 | 只看该作者
添加到启动

[Registry]

Root: HKLM; Subkey: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run; ValueType: string; ValueName: 开机启动; ValueData: """C:\\Program Files\\Thunder\\Thunder.exe"" /s"; Flags: uninsdeletevalue


1 、如何让协议许可页面默认选中我同意按钮
[code]
procedure InitializeWizard();
begin
WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
end;
2、自定义安装程序右上角图片大小
[code]
procedure InitializeWizard();
begin
WizardForm.WizardSmallBitmapImage.width:=150; //设置页眉图片的大小
WizardForm.WizardSmallBitmapImage.left:=WizardForm.width-150; //设置左边页眉留出的空隙
WizardForm.PAGENAMELABEL.width:=0; //设置标题文字显示的大小
WizardForm.PAGEDESCRIPTIONLABEL.width:=0; //设置标题文字显示的大小
end;
或者
//自定义安装向导小图片
[code]
procedure InitializeWizard();
begin
Wizardform.WizardSmallBitmapImage.left:= WizardForm.width-164; //自定义安装向导小图片显示位置
WizardForm.WizardSmallBitmapImage.width:=164; //自定义安装向导小图片宽度
Wizardform.PageNameLabel.width:= 495 - 164 -36; //这儿必须定义,数值根据图片宽度更改,显示软件名称的位置
Wizardform.PageDescriptionLabel.width:= 495 - 164 -42; //显示页面信息的位置
end;
3、自定义BeveledLabel显示代码
[code]
procedure InitializeWizard();
begin
WizardForm.BeveledLabel.Enabled:=true; //允许显示
WizardForm.BeveledLabel.Font.Color:=$00058451;; //显示颜色
WizardForm.BeveledLabel.Font.Style := WizardForm.BeveledLabel.Font.Style + [fsBold]; //显示字体
WizardForm.BeveledLabel.Left:=5; //显示位置
end;
4、自定义安装向导图片
[code]
procedure InitializeWizard();
begin
Wizardform.WELCOMELABEL1.left:= 18; //自定义欢迎页面标题1显示位置
Wizardform.WELCOMELABEL2.left:= 18; //自定义欢迎页面标题2显示位置
Wizardform.WizardBitmapImage.left:= WizardForm.width-164 //自定义安装向导图片显示位置(显示大小,此处为居右显示)
end;
5、显示出组件选择框
[Types]
Name: full; Description: 推荐
Name: default; Description: 典型
Name: custom; Description: 自定义; Flags: iscustom
;告诉安装程序这个类型是自定义类型。必须定义iscustom这个参数,才能显示出组件选择框
6、定义[Messages]的颜色
[code]
procedure InitializeWizard();
begin
WizardForm.BeveledLabel.Enabled:= True;
WizardForm.BeveledLabel.Font.Color:= clblue;
end;
7、不显示一些特定的安装界面
[code]
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if PageID=wpReady then
result := true;
end;
wpReady  是准备安装界面
PageID查询 INNO帮助中的 Pascal 脚本: 事件函数常量
预定义向导页 CurPageID 值
wpWelcome, wpLicense, wpPassword, wpInfoBefore, wpUserInfo, wpSelectDir, wpSelectComponents, wpSelectProgramGroup, wpSelectTasks, wpReady, wpPreparing, wpInstalling, wpInfoAfter, wpFinished
8、换行符号
在  [Messages]   换行符号为%n
在  MsgBox  中换行符号为 #13#10    //#13 为回车字符
9、颜色代码
(1)一个值形如 $bbggrr, 这里的 rr, gg 和 bb 指定了两位的亮度值(以十六进制表示)分别为红色,绿色和蓝色。
(2)预定义的颜色名称:
clBlack(黑色),clMaroon(暗红),clGreen(绿色),clOlive(橄榄绿),
clNavy(深蓝),clPurple(紫色),clTeal(深青),clGray(灰色),
clSilver(浅灰),clRed(红色),clLime(浅绿),clYellow(黄色),
clBlue(蓝色),clFuchsia(紫红),clAqua(青绿),clWhite(白色)。
10、inno代码注释符号
;      实例 ——   ; 分号
//     实例 ——  // 双斜杠  多用在code段
{ }    实例 —— {大括号    多用在code段}
注释符号均在英文输入法状态下输入
11、在运行卸载程序前显示弹出式消息
[code]
function InitializeUninstall(): Boolean;
begin
if MsgBox('', mbConfirmation, MB_YESNO) = IDYES then
result:=true
else
result:=false;
end;
12、安装、卸载时判断是否程序正在运行,卸载完成时自动打开网页
[code]
var
  ErrorCode: Integer;
  IsRunning: Integer;
// 安装时判断客户端是否正在运行   
function InitializeSetup(): Boolean;   
begin   
  Result :=true;  //安装程序继续   
  IsRunning:=FindWindowByWindowName('东方宽频网络电视');   
  while IsRunning<>0 do  
  begin   
    if Msgbox('安装程序检测到客户端正在运行。'  #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then   
    begin   
      Result :=false; //安装程序退出   
      IsRunning :=0;   
    end else begin   
      Result :=true;  //安装程序继续   
      IsRunning:=FindWindowByWindowName('东方宽频网络电视');   
    end;   
  end;   
end;   
// 卸载时判断客户端是否正在运行   
function InitializeUninstall(): Boolean;   
begin   
   Result :=true;  //安装程序继续   
  IsRunning:=FindWindowByWindowName('东方宽频网络电视');   
  while IsRunning<>0 do  
  begin   
  
    if Msgbox('安装程序检测到客户端正在运行。'  #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then   
    begin   
      Result :=false; //安装程序退出   
      IsRunning :=0;   
    end else begin   
      Result :=true;  //安装程序继续   
      IsRunning:=FindWindowByWindowName('东方宽频网络电视');     
    end;   
  end;   
end;   
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);   
begin   
  case CurUninstallStep of   
    usUninstall:     
      begin // 开始卸载   
      end;   
    usPostUninstall:   
      begin      // 卸载完成   
        // MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK);   
        // ...insert code to perform post-uninstall tasks here...   
        ShellExec('open', 'http://www.dreams8.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);   
      end;   
  end;   
end;   
13、 删除文件和删除文件夹
//删除文件    用 DeleteFile 只能删除一个文件,不能使用通配符来删除多个文件
DeleteFile(ExpandConstant('{app}\\abc.exe'));
//删除所有文件及文件夹
DelTree(ExpandConstant('{app}'), True, True, False);
14、BorderStyle
TFormBorderStyle = (bsNone, bsSingle, bsSizeable, bsDialog, bsToolWindow, bsSizeToolWin);
无边界式(bsNone)  ,单边固定式(bsSingle),双边可变式(bsSizeable),对话框式(bsDialog)
15、if   else
function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
begin
  Result := True;
  if (CurPageID = wpSelectDir) then
  begin
  MsgBox('AAAA', mbInformation, MB_OK);
  end
  else
  begin
  MsgBox('BBBB', mbInformation, MB_OK);
  end;
end;
16、安装结束界面增加“设为首页”选项
[Tasks]
Name: changestartpage; Description: "设置vistaqq为默认主页"
[Registry]
Root: HKCU; Subkey: "Software\\Microsoft\\Internet Explorer\\Main"; ValueType: string; ValueName: "Start Page"; ValueData: "http://www.vistaqq.com"; tasks: changestartpage
17、添加“关于”和网站链接按钮
[Code]
procedure URLLabelOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', 'http://www.vistaqq.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
procedure AboutButtonOnClick(Sender: TObject);
begin
  MsgBox(#13 'Vista 状态条风格盘符' #13 #13'本软件由jinn制作,希望各位登陆中天VIP工作室!' #13#13 '版权所有 (C)  中天VIP工作室', mbInformation, MB_OK);
end;
var
    AboutButton, CancelButton: TButton;
    URLLabel: TNewStaticText;
procedure InitializeWizard();
begin
  { Create the pages }
WizardForm.PAGENAMELABEL.Font.Color:= clred;
WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clBlue;
WizardForm.WELCOMELABEL1.Font.Color:= clGreen;
WizardForm.WELCOMELABEL2.Font.Color:= clblack;
   CancelButton := WizardForm.CancelButton;
     AboutButton := TButton.Create(WizardForm);
     AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
     AboutButton.Top := CancelButton.Top;
     AboutButton.Width := CancelButton.Width;
     AboutButton.Height := CancelButton.Height;
     AboutButton.Caption := '&About';
     AboutButton.OnClick := @AboutButtonOnClick;
     AboutButton.Parent := WizardForm;
  URLLabel := TNewStaticText.Create(WizardForm);
    URLLabel.Caption := '中天VIP工作室';
    URLLabel.Cursor := crHand;
    URLLabel.OnClick := @URLLabelOnClick;
    URLLabel.Parent := WizardForm;
    { Alter Font *after* setting Parent so the correct defaults are inherited first }
    URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
    URLLabel.Font.Color := clBlue;
    URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
    URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
end;
18、去掉安装程序左上角“关于安装程序”的代码
procedure InitializeWizard();
begin
WizardForm.BorderIcons:= [biMinimize];
end;
procedure CurPageChanged(CurPage: Integer);
begin
if CurPage=wpWelcome then
WizardForm.BorderIcons:= [biSystemMenu, biMinimize];
end;
或者
procedure InitializeWizard();
begin
WizardForm.BORDERICONS := [biHelp, biSystemMenu, biMinimize];
end;
19、自定义BeveledLabel文字
[Messages]
BeveledLabel=中天VIP工作室
20、自定义安装程序界面左上角“安装”文字
[message]
SetupAppTitle=需要的字
SetupWindowTitle=需要的字
21、自定义安装程序版本号
VersionInfoVersion=1.1
VersionInfoTextVersion=1.1
回复 支持 反对

使用道具 举报

该用户从未签到

557

主题

4523

帖子

10

积分

LV 2.会员

受命于天,既寿永昌

积分
10

社区居民偶尔光临工蜂业余写手最爱沙发常坐沙发沙发如床在线达人社区平民做个有钱人

地板
发表于 2011-12-17 00:44:25 | 只看该作者
技术贴啊~完全不懂~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

     
    Archiver|手机版|小黑屋|( 沪ICP备12034951号 )

GMT+8, 2024-4-28 22:27 , Processed in 0.150546 second(s), 28 queries .

© 2001-2011 Powered by Discuz! X3.1

快速回复 返回顶部 返回列表