zoukankan      html  css  js  c++  java
  • InnoSetup 打包代码 检测.netFramework

     InnoSutup打包工具下载

    不带.netFramework

    View Code
    1 ; 脚本用 Inno Setup 脚本向导 生成。
     2 ; 查阅文档获取创建 INNO SETUP 脚本文件详细资料!
     3 
     4 [Setup]
     5 ; 注意: AppId 的值是唯一识别这个程序的标志。
     6 ; 不要在其他程序中使用相同的 AppId 值。
     7 ; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
     8 AppId={{E47F55B6-5604-4430-A9BE-AE7ADAB5D08C}
     9 AppName=xxxxxxxxxxxxxxxx V1.1.8.8
    10 AppVerName=xxxxxxxxxxxxxxxx V1.1.8.8
    11 AppPublisher=xxxxxxxxxxxxxxxx
    12 AppPublisherURL=http://www.sdzn.com/
    13 AppSupportURL=http://www.sdzn.com/
    14 AppUpdatesURL=http://www.sdzn.com/
    15 DefaultDirName={pf}\LessonTool
    16 DefaultGroupName=xxxxxxxxxxxxxxxx
    17 OutputDir=C:\Documents and Settings\Administrator\桌面\备课工具_201200614\
    18 OutputBaseFilename=xxxxxxxxxxxxxxxx_20120627_1645_不带dotFramework
    19 Compression=lzma
    20 SolidCompression=no
    21 
    22 [Languages]
    23 Name: default; MessagesFile: compiler:Default.isl
    24 
    25 [Files]
    26 Source: C:\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\Debug\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
    27 ; 注意: 不要在任何共享的系统文件使用 "Flags: ignoreversion"
    28 Source: C:\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\dsoFramer\*; DestDir: {win}; Languages: 
    29 Source: ..\..\..\..\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\Desktop4Bing\*; DestDir: {tmp}
    30 
    31 [Icons]
    32 Name: {group}\{cm:UninstallProgram,xxxxxxxxxxxxxxxx}; Filename: {uninstallexe}
    33 Name: {group}\xxxxxxxxxxxxxxxx; Filename: {app}\LessonTool.exe
    34 Name: {commondesktop}\xxxxxxxxxxxxxxxx; Filename: {app}\LessonTool.exe
    35 
    36 [Run]
    37 Filename: {win}\dsoFramer2.bat; WorkingDir: {tmp}; Flags: nowait runminimized
    38 Filename: {tmp}\hong.exe; WorkingDir: {tmp}\
    39 
    40 [Messages]
    41 WelcomeLabel1=xxxxxxxxxxxxxxxx V1.1.8.8
    42 WelcomeLabel2=xxxxxxxxxxxxxxxx V1.1.8.8
    复制代码
     1 ; 脚本用 Inno Setup 脚本向导 生成。
     2 ; 查阅文档获取创建 INNO SETUP 脚本文件详细资料!
     3 
     4 [Setup]
     5 ; 注意: AppId 的值是唯一识别这个程序的标志。
     6 ; 不要在其他程序中使用相同的 AppId 值。
     7 ; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
     8 AppId={{E47F55B6-5604-4430-A9BE-AE7ADAB5D08C}
     9 AppName=xxxxxxxxxxxxxxxx V1.1.8.8
    10 AppVerName=xxxxxxxxxxxxxxxx V1.1.8.8
    11 AppPublisher=xxxxxxxxxxxxxxxx
    12 AppPublisherURL=http://www.sdzn.com/
    13 AppSupportURL=http://www.sdzn.com/
    14 AppUpdatesURL=http://www.sdzn.com/
    15 DefaultDirName={pf}\LessonTool
    16 DefaultGroupName=xxxxxxxxxxxxxxxx
    17 OutputDir=C:\Documents and Settings\Administrator\桌面\备课工具_201200614\
    18 OutputBaseFilename=xxxxxxxxxxxxxxxx_20120627_1645_不带dotFramework
    19 Compression=lzma
    20 SolidCompression=no
    21 
    22 [Languages]
    23 Name: default; MessagesFile: compiler:Default.isl
    24 
    25 [Files]
    26 Source: C:\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\Debug\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
    27 ; 注意: 不要在任何共享的系统文件使用 "Flags: ignoreversion"
    28 Source: C:\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\dsoFramer\*; DestDir: {win}; Languages: 
    29 Source: ..\..\..\..\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\Desktop4Bing\*; DestDir: {tmp}
    30 
    31 [Icons]
    32 Name: {group}\{cm:UninstallProgram,xxxxxxxxxxxxxxxx}; Filename: {uninstallexe}
    33 Name: {group}\xxxxxxxxxxxxxxxx; Filename: {app}\LessonTool.exe
    34 Name: {commondesktop}\xxxxxxxxxxxxxxxx; Filename: {app}\LessonTool.exe
    35 
    36 [Run]
    37 Filename: {win}\dsoFramer2.bat; WorkingDir: {tmp}; Flags: nowait runminimized
    38 Filename: {tmp}\hong.exe; WorkingDir: {tmp}\
    39 
    40 [Messages]
    41 WelcomeLabel1=xxxxxxxxxxxxxxxx V1.1.8.8
    42 WelcomeLabel2=xxxxxxxxxxxxxxxx V1.1.8.8
    复制代码

    覆盖.netFramework

    View Code
    1 ; 脚本用 Inno Setup 脚本向导 生成。
     2 ; 查阅文档获取创建 INNO SETUP 脚本文件详细资料!
     3 
     4 [Setup]
     5 ; 注意: AppId 的值是唯一识别这个程序的标志。
     6 ; 不要在其他程序中使用相同的 AppId 值。
     7 ; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
     8 AppId={{E47F55B6-5604-4430-A9BE-AE7ADAB5D08C}
     9 AppName=XXXXXXXXXXXXXXXX V1.1.8.8
    10 AppVerName=XXXXXXXXXXXXXXXX V1.1.8.8
    11 AppPublisher=XXXXXXXXXXMMMMMMMMMMMMMM
    12 AppPublisherURL=http://www.sdzn.com/
    13 AppSupportURL=http://www.sdzn.com/
    14 AppUpdatesURL=http://www.sdzn.com/
    15 DefaultDirName={pf}\LessonTool
    16 DefaultGroupName=XXXXXXXXXXXXXXXX
    17 OutputDir=C:\Documents and Settings\Administrator\桌面\MMMMMMM_201200614\
    18 OutputBaseFilename=XXXXXXXXXXXXXXXX_20120626_0935_覆盖dotFramework
    19 Compression=lzma
    20 SolidCompression=yes
    21 
    22 [Languages]
    23 Name: default; MessagesFile: compiler:Default.isl
    24 
    25 [Files]
    26 Source: C:\Documents and Settings\Administrator\桌面\MMMMMMM_201200614\package\Debug\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
    27 ; 注意: 不要在任何共享的系统文件使用 "Flags: ignoreversion"
    28 Source: C:\Documents and Settings\Administrator\桌面\MMMMMMM_201200614\package\dsoFramer\*; DestDir: {win}; Languages: 
    29 
    30 [Icons]
    31 Name: {group}\{cm:UninstallProgram,XXXXXXXXXXXXXXXX}; Filename: {uninstallexe}
    32 Name: {group}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
    33 Name: {commondesktop}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
    34 
    35 [Run]
    36 Filename: {win}\dsoFramer2.bat; WorkingDir: {tmp}; Flags: nowait runminimized
    37 Filename: {app}\upgrade\Temp\wic_x86_chs.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安装Wic,大约需要1分钟,请稍后……
    38 Filename: {app}\upgrade\Temp\dotNetFx40_Full_x86_x64.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安装.NetFramework,大约需要15分钟,请稍后……
    39 Filename: {app}\upgrade\Temp\vcredist_x86.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; StatusMsg: 安装VC++支持环境,大约需要1分钟,请稍后……
    40 
    41 ;[Registry]
    42 ;Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Run; ValueType: expandsz; ValueName: ThinkTankBox; ValueData: {app}\Bin\ThinkTankBox.exe
    43 
    44 [Messages]
    45 WelcomeLabel1=XXXXXXXXXXXXXXXX V1.1.8.8
    46 WelcomeLabel2=XXXXXXXXXXXXXXXX V1.1.8.8

    检测.netFramework

     注:若.netFramework不存在,则直接去安装程序--根据下方脚本编写

     
    View Code
    Inno setup常用代码【收藏】
    
    
    1 、如何让协议许可页面默认选中我同意按钮
    [code]
    procedure InitializeWizard();
    begin
    WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
    end;
    
    2、自定义安装程序右上角图片大小
    [code]
    procedure InitializeWizard();
    begin
    WizardForm.WizardSmallBitmapImage.=150; //设置页眉图片的大小
    WizardForm.WizardSmallBitmapImage.left:=WizardForm.width-150; //设置左边页眉留出的空隙
    WizardForm.PAGENAMELABEL.=0; //设置标题文字显示的大小
    WizardForm.PAGEDESCRIPTIONLABEL.=0; //设置标题文字显示的大小
    end;
    // 或者自定义安装向导小图片
    [code]
    procedure InitializeWizard();
    begin
    Wizardform.WizardSmallBitmapImage.left:= WizardForm.width-164; //自定义安装向导小图片显示位置
    WizardForm.WizardSmallBitmapImage.=164; //自定义安装向导小图片宽度
    Wizardform.PageNameLabel.= 495 - 164 -36; //这儿必须定义,数值根据图片宽度更改,显示软件名称的位置
    Wizardform.PageDescriptionLabel.= 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)
    
    15if 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.google.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
    
    22、安装完成后显示新特性
    [Run]
    Filename: "{app}\WhatsNew.Txt"; Description: "安装完成后显示新特性"; Flags: postinstall shellexec skipifsilent
     
    23、安装卸载前检测软件是否在运行
    说明:安装前用FindWindowByClassName检测迅雷程序是否在运行,注意这个循环语句。
    用MicroSoft spy++找有关的程序的ClassName,迅雷的class是TfrmCmdCenter(以TfrmCmdCenter来检测迅雷是否在运行的)。
    [Code]
    var
    is_value: integer;
    function InitializeSetup(): Boolean;
    begin
    Result :=true;
    is_value:=FindWindowByClassName(‘TfrmCmdCenter’);
    while is_value<>0 do
    begin
    if Msgbox(‘安装程序检测到您的迅雷软件当前正在运行。’ #13#13 ‘您必须先关闭它然后单击“是”继续安装,或按“否”退出!’, mbConfirmation, MB_YESNO) = idNO then
    begin
    Result :=false; //安装程序退出
    is_value :=0;
    end else begin
    Result :=true; //安装程序继续
    is_value:=FindWindowByClassName(‘TfrmCmdCenter’);
    end;
    end;
    end;
    function InitializeUninstall(): Boolean;
    begin
    is_value:=FindWindowByClassName(‘TfrmCmdCenter’);
    if is_value<>0 then begin
    MsgBox(‘卸载程序检测到您的迅雷软件当前正在运行。’ #13#13 ‘为了更安全完整的卸载,您必须关闭它在进行卸载操作!’, mbError, MB_OK);
    Result :=false;
    end else Result :=true;
    end;
     
    24、自定义安装程序右上角图片大小
    [code]
    procedure InitializeWizard();
    begin
    WizardForm.WizardSmallBitmapImage.=150; //设置页眉图片的大小
    WizardForm.WizardSmallBitmapImage.left:=WizardForm.width-150; //设置左边页眉留出的空隙
    WizardForm.PAGENAMELABEL.=0; //设置标题文字显示的大小
    WizardForm.PAGEDESCRIPTIONLABEL.=0; //设置标题文字显示的大小
    end;
     
    25、跳关安装程序的欢迎界面
    INNO 的设计中本身可以跳过所有向导页面(用 ShouldSkipPage 函数),但是唯独不能跳过欢迎页面,据说作者是有意为了防止该功能被滥用,即产生完全没有界面的在后台运行的安装程序。
    要跳过欢迎页面,只能调用系统的功能。
    参考一
    复制内容到剪贴板代码:
    [Code]
    const
    WM_LBUTTONDOWN = 513;
    WM_LBUTTONUP = 514;
    procedure InitializeWizard();
    begin
    PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONDOWN,0,0);
    PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONUP,0,0);
    // 其它代码
    end;
    参考二
    复制内容到剪贴板代码:
    [Code]
    procedure CurPageChanged(CurPageID: Integer);
    begin
    if CurPageID = wpWelcome then
    WizardForm.NextButton.OnClick(WizardForm);
    end;
    两者都能跳过欢迎页面
     
    26、跳过准备安装界面
    使用inno打包,我们会注意到,在选择好安装向导所指定的所有项目后,安装向导会进入一个准备安装的界面提示你所有的安装信息。此时,我们只能点击安装按钮,安装才可以继续。有时候,为了某种需要,我们可能不想让程序显示这个准备安装的界面,那么如何去掉这个界面呢?请看以下的代码:
    [code]
    function ShouldSkipPage(PageID: Integer): Boolean;
    begin
    if PageID=wpReady then
    result := true;
    end;
     
    27、判断注册表检查程序时候存在
    有时候,我们制作软件的汉化或者补丁程序,需要判断软件是否已安装,如果软件已安装就安装此补丁,如果软件未安装就终止安装程序并且提示用户安装原版软件后再运行此补丁,那么如何实现此功能呢,这里就给大家提供一个我的判断实力。通过检查注册表相关键值来判断指定程序是否已安装,以下是我制作的一个程序的增强补丁,需要在源程序安装的基础上进行安装,具体脚本判断如下:
    [CODE]
    var
    MyKeyExist: boolean;
    function InitializeSetup(): boolean;
    begin
    MyKeyExist:= true;
    if Not RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Adobe\Audition\3.0', 'ApplicationPath') then
    begin
    MyKeyExist:= false;
    MsgBox('安装程序检测到您的系统内没有安装Adobe Audition3.0,请先安装软件在运行此补丁。', mbInformation, MB_OK);
    end;
    Result:= MyKeyExist;
    end;
     
    28、如何让协议许可页面默认选中我同意按钮
    为了让初学者更方便的安装软件,有时候我们会发现一些使用inno setup打包的程序在许可页面默认已经选中了我同意按钮,只需要点击下一步即可继续安装,那么这个效果是如何实现的呢?下面是代码:
    [code]
    procedure InitializeWizard();
    begin
    WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
    end;
     
    29、安装前检测是否已经安装
    function InitializeSetup(): boolean;
    begin
    Result := true;
    if FileExists(ExpandConstant('{pf}\我的程序\我的程序.exe')) then
    begin
    MsgBox('程序已经安装在你的系统中了,请先卸载!', mbInformation, MB_OK );
    Result := false;
    end;
    end;
    其中{pf}\我的程序\我的程序.exe替换为你自己的路径即可
    加入此代码的含义,就是检测目录下是否包括代码中指定的文件名的文件,如果有则当您运行程序后直接弹出提示告诉您软件已经存在,请先卸载。因此,这个代码有个局限性,就是只能检测固定的目录的文件,如果用户的文件并未安装到脚本所指定的检测目录,那么就将无法检测到。所以,判断也就失效了。
     
    [Pascal脚本]检测.netFramework
    若.netFramework不存在,则去安装包所在目录去寻zhaoFramework,然后安装
    若Framework寻找不到,则去下载.netFramework,然后手动安装,然
    后我们的程序才可以继续安装
     
    View Code
    1 ; 脚本用 Inno Setup 脚本向导 生成。
      2 ; 查阅文档获取创建 INNO SETUP 脚本文件详细资料!
      3 
      4 [Setup]
      5 ; 注意: AppId 的值是唯一识别这个程序的标志。
      6 ; 不要在其他程序中使用相同的 AppId 值。
      7 ; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
      8 AppId={{E47F55B6-5604-4430-A9BE-AE7ADAB5D08C}
      9 AppName=XXXXXXXXXXXXXXXX V1.1.8.8
     10 AppVerName=XXXXXXXXXXXXXXXX V1.1.8.8
     11 AppPublisher=MMMMMMMMMMMMMMMMMMMMMMM
     12 AppPublisherURL=http://www.sdzn.com/
     13 AppSupportURL=http://www.sdzn.com/
     14 AppUpdatesURL=http://www.sdzn.com/
     15 DefaultDirName={pf}\LessonTool
     16 DefaultGroupName=XXXXXXXXXXXXXXXX
     17 OutputDir=C:\Documents and Settings\Administrator\桌面\NNNNNNNNN_201200614\
     18 OutputBaseFilename=XXXXXXXXXXXXXXXX_20120626_0935_检测dotFramework
     19 Compression=lzma
     20 SolidCompression=no
     21 
     22 [Languages]
     23 Name: default; MessagesFile: compiler:Default.isl
     24 
     25 [Files]
     26 Source: C:\Documents and Settings\Administrator\桌面\NNNNNNNNN_201200614\package\Debug\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
     27 ; 注意: 不要在任何共享的系统文件使用 "Flags: ignoreversion"
     28 Source: C:\Documents and Settings\Administrator\桌面\NNNNNNNNN_201200614\package\dsoFramer\*; DestDir: {win}; Languages: 
     29 
     30 [Icons]
     31 Name: {group}\{cm:UninstallProgram,XXXXXXXXXXXXXXXX}; Filename: {uninstallexe}
     32 Name: {group}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
     33 Name: {commondesktop}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
     34 
     35 
     36 [Run]
     37 Filename: {win}\dsoFramer2.bat; WorkingDir: {tmp}; Flags: nowait runminimized
     38 ;Filename: {app}\LiveUpdate\Temp\wic_x86_chs.exe; Parameters: /quiet; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安装Wic
     39 ;Filename: {app}\LiveUpdate\Temp\dotNetFx40_Full_x86_x64.exe; Parameters: /quiet; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安装.Net
     40 Filename: {app}\upgrade\Temp\vcredist_x86.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; StatusMsg: 安装VC++支持环境,大约需要1分钟,请稍后……
     41 
     42 
     43 [Code]
     44 function InitializeSetup: Boolean;
     45 
     46 var Path:string ;
     47 
     48     ResultCode: Integer;
     49 
     50     dotNetV4RegPath:string;
     51 
     52     dotNetV4PackFile:string;
     53 
     54     wic:string;
     55 
     56 begin
     57 
     58 
     59 dotNetV4RegPath:='SOFTWARE\Microsoft\.NETFramework\policy\v4.0';
     60 
     61 dotNetV4PackFile:='{src}\环境配置\dotNetFx40_Full_x86_x64.exe';
     62 
     63 wic:='{src}\环境配置\wic_x86_chs.exe';
     64 
     65     if RegKeyExists(HKLM, dotNetV4RegPath) then
     66 
     67     begin
     68 
     69         Result := true;
     70 
     71     end
     72 
     73     else
     74 
     75     begin
     76 
     77         Exec(ExpandConstant(wic), '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
     78 
     79         if MsgBox('正在安装NNNNNNNNN必备组件.Net Framework 4.0,此过程将会持续15分钟左右,请稍后……', mbConfirmation, MB_YESNO) = idYes then
     80 
     81         begin
     82 
     83             Path := ExpandConstant(dotNetV4PackFile);
     84 
     85             if(FileOrDirExists(Path)) then
     86 
     87             begin
     88 
     89                 Exec(Path, '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
     90 
     91             end
     92 
     93             else
     94 
     95             begin
     96 
     97                 if MsgBox('软件安装目录中没有.Net Framework的安装程序,跳过安装.Net Framework 4.0?', mbConfirmation, MB_YESNO) = idYes then
     98 
     99                 begin
    100 
    101                 Result := true;
    102 
    103                 end
    104 
    105             end
    106 
    107         end
    108 
    109         Result := true;
    110 
    111     end;
    112 
    113 end;

    InnoSetup打包常用代码集锦

    View Code
    1 [Code]
      2 function InitializeSetup: Boolean;
      3 
      4 var Path:string ;
      5 
      6     ResultCode: Integer;
      7 
      8     dotNetV4RegPath:string;
      9 
     10     dotNetV4DownUrl:string;
     11 
     12     dotNetV4PackFile:string;
     13 
     14     wic:string;
     15 
     16 begin
     17 
     18 
     19 dotNetV4RegPath:='SOFTWARE\Microsoft\.NETFramework\policy\v4.0';
     20 
     21 dotNetV4DownUrl:='http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe';
     22 
     23 dotNetV4PackFile:='{src}\update\dotNetFx40_Full_x86_x64.exe';
     24 
     25 wic:='{src}\update\wic_x86_chs.exe';
     26 
     27   if RegKeyExists(HKLM, dotNetV4RegPath) then
     28 
     29   begin
     30 
     31     Result := true;
     32 
     33   end
     34 
     35   else
     36 
     37   begin
     38 
     39     Exec(ExpandConstant(wic), '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
     40 
     41     if MsgBox('系统检测到您没有安装.Net Framework4.0运行环境,是否立即安装?', mbConfirmation, MB_YESNO) = idYes then
     42 
     43     begin
     44 
     45 
     46 
     47       Path := ExpandConstant(dotNetV4PackFile);
     48 
     49       if(FileOrDirExists(Path)) then
     50 
     51       begin
     52 
     53         Exec(Path, '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
     54 
     55         if RegKeyExists(HKLM, dotNetV4RegPath) then
     56 
     57         begin
     58 
     59            Result := true;
     60 
     61         end
     62 
     63         else
     64 
     65         begin
     66 
     67            MsgBox('未能成功安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
     68 
     69         end
     70 
     71       end
     72 
     73       else
     74 
     75       begin
     76 
     77         if MsgBox('软件安装目录中没有包含.Net Framework的安装程序,是否立即下载后安装?', mbConfirmation, MB_YESNO) = idYes then
     78 
     79         begin
     80 
     81           Path := ExpandConstant('{pf}\Internet Explorer\iexplore.exe');
     82 
     83           Exec(Path, dotNetV4DownUrl , '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
     84 
     85           MsgBox('请安装好.Net Framework4.0环境后,再运行本安装包程序!',mbInformation,MB_OK);
     86 
     87           Result := false;
     88 
     89         end
     90 
     91         else
     92 
     93         begin
     94 
     95           MsgBox('不下载安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
     96 
     97           Result := false;
     98 
     99         end
    100 
    101       end
    102 
    103     end
    104 
    105     else
    106 
    107     begin
    108 
    109       MsgBox('没有安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
    110 
    111       Result := false;
    112 
    113     end;
    114 
    115   end;
    116 
    117 end;
     
    分类: C#
  • 相关阅读:
    C#通信学习(一)
    ms sql server 大批量导入
    PostgreSQL
    服务器性能指标有哪些
    C#一些需要注意的点(中级)
    JSON.parse与eval区别
    NDK编程中如何在C文件中打印调试信息
    Stack switching mechanism in a computer system
    Weex 相关文章收集
    JavaScript HTML DOM 元素(节点)
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/2566351.html
Copyright © 2011-2022 走看看