[Other]Inno Setupは心徳を使用しています.一つの完全な項目は、NETを含む.


最近はプログラムのパッケージ作業を手配して、Inno Setupパッケージに触れさせてください.
正直に言うと、初めてです.何も分かりません.ずっとBaiduです.もちろん多くはないです.文書を見るしかないです.
前のパッケージプログラムの部分は全部大丈夫です.全部完成しましたが、後で縛られて組み立てると言いました.これは私を困らせました.最初はセットを追加して、プログラムをインストールしてからインストールを開始します.このような欠陥は数え切れないほど多いです.
その後、組み立てをtmpに縛ってインストールしますが、問題があります.ユーザーがインストール中にキャンセルしたら、自分のプログラムも走れなくなります.
その後、セットアップのインストールテストを追加しました.最後のステップで正しくインストールされているかどうかを検出します.成功すれば完了します.成功しなければ、プログラム削除を起動します.
このように基本的に解決しましたが、面倒くさいと思います.
そして、なぜ最初からテストをしないのかと思いました.もしインストールしなかったら、インストールに失敗したら、プログラム全体のインストールを終了します.
それから私のほんの少しの変化を始めて、完成します.
最後のコードは以下の通りです.
[Files]
Source: "NET2.exe"; DestDir: "{tmp}"; Flags: ignoreversion
[code]
function NeedInstallDotNet(): Boolean;
var
    success: boolean;
    install: cardinal;
begin
    success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727', 'Install', install);
    Result := not(success and (install = 1));
end;
   
function InitializeSetup(): Boolean;
var ResultCode: Integer; 
begin
  Result :=true;
  if (NeedInstallDotNet) then
  begin
    MsgBox('         Microsoft .NET Framework 2.0 SP2  .' + #13 + '                         .',mbError, MB_OK);
    ExtractTemporaryFile('NET2.exe'); 
    Exec(ExpandConstant('{tmp}\NET2.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); 
  end;
  if (NeedInstallDotNet) then
  begin
    MsgBox('        ,       .',mbError, MB_OK);
    Result :=false; //      
  end else begin
    Result :=true;  //      
  end;
end;
完全なプロジェクト:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!


#define MyCompany "Broadinter"
#define MyAppName "Prober"
#define MyAppVersion "3.0.0"
#define MyAppPublisher "Broadinter, Inc."
#define MyAppURL "http://www.broadinter.com/"
#define MyAppId "{55E402DD-B073-4CDF-8AA7-D52FDC5B348E}"
#define MyAppServeKiwi "kiwi.exe"
#define MyAppServeWatchdog "kiwi_watchdog.exe"
#define MyFormationDotNetName "NetFx20SP2_x86.exe"      


[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)


AppId={{#MyAppId}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
AppCopyright=Copyright (C) 2013 {#MyAppPublisher}
DefaultDirName={pf}\{#MyCompany}
DefaultGroupName={#MyCompany}
AllowNoIcons=yes
LicenseFile=eula.rtf
OutputDir=..\Setup
OutputBaseFilename=setup
SetupIconFile=setup.ico
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin
WizardImageFile=Image.bmp
WizardSmallImageFile=SmallImage.bmp 


[Languages]
Name: "chinesesimplified"; MessagesFile: "ChineseSimplified.isl"




[Files]
Source: "..\Source\Prober\*"; DestDir: "{app}\Prober"; Flags: ignoreversion recursesubdirs createallsubdirs;


Source: "..\Source\Selections
etwork.conf"; DestDir: "{app}\Prober"; Flags: ignoreversion onlyifdoesntexist uninsneveruninstall; Check: NeedInstallNetworkConfig; Source: "..\Source\Selections\probe.conf"; DestDir: "{app}\Prober"; Flags: ignoreversion onlyifdoesntexist uninsneveruninstall; Check: NeedInstallProbeConfig; AfterInstall: MyAfterInstall; Source: "..\Source\Prober_Update\*"; DestDir: "{app}\Prober_Update"; Flags: ignoreversion recursesubdirs createallsubdirs;  Source: "..\Source\Prober_Watchdog\*"; DestDir: "{app}\Prober_Watchdog"; Flags: ignoreversion recursesubdirs createallsubdirs;       Source: "..\Source\Selections\NetFx20SP2_x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion; Check: NeedInstallDotNet; Source: "..\Source\Selections\IE8-WindowsServer2003-x86-CHS.exe"; DestDir: "{tmp}"; Flags: ignoreversion; Check: NeedInstallIE; Source: "..\Source\Selections\Flashplayer11_7r700_202_winax.exe"; DestDir: "{tmp}"; Flags: ignoreversion; Check: NeedInstallFlash; [Run] Filename: "{app}\Prober\{#MyAppServeKiwi}"; Parameters: "-i Prober"; WorkingDir: "{app}\Prober"; StatusMsg: " Prober ..."; BeforeInstall: BeforeInstallDelete; Filename: "{app}\Prober\{#MyAppServeKiwi}"; Parameters: "-s Prober"; WorkingDir: "{app}\Prober"; StatusMsg: " Prober ..." Filename: "{app}\Prober_Watchdog\{#MyAppServeWatchdog}"; Parameters: "-i Prober_Watchdog"; WorkingDir: "{app}\Prober_Watchdog"; StatusMsg: " Prober_Watchdog ..." Filename: "{app}\Prober_Watchdog\{#MyAppServeWatchdog}"; Parameters: "-s Prober_Watchdog"; WorkingDir: "{app}\Prober_Watchdog"; StatusMsg: " Prober_Watchdog ..." Filename: "{tmp}\IE8-WindowsServer2003-x86-CHS.exe"; Parameters: " "; WorkingDir: "{tmp}"; StatusMsg: " IE8..."; Check: NeedInstallIE Filename: "{tmp}\Flashplayer11_7r700_202_winax.exe"; Parameters: "/install"; WorkingDir: "{tmp}"; StatusMsg: " Flashplayer11..."; Check: NeedInstallFlash [UninstallRun] Filename: "{app}\Prober\{#MyAppServeKiwi}"; Parameters: "-p Prober"; WorkingDir: "{app}\Prober"; StatusMsg: " Prober " Filename: "{app}\Prober\{#MyAppServeKiwi}"; Parameters: "-u Prober"; WorkingDir: "{app}\Prober"; StatusMsg: " Prober " Filename: "{app}\Prober_Watchdog\{#MyAppServeWatchdog}"; Parameters: "-p Prober_Watchdog"; WorkingDir: "{app}\Prober_Watchdog"; StatusMsg: " Prober_Watchdog " Filename: "{app}\Prober_Watchdog\{#MyAppServeWatchdog}"; Parameters: "-u Prober_Watchdog"; WorkingDir: "{app}\Prober_Watchdog"; StatusMsg: " Prober_Watchdog " [Code] var   //   UserPage: TInputQueryWizardPage;   //   IsUninstallRuned: Boolean;   //   IsSaveConfig: Boolean;   //   ConfigBool: Boolean;       //CheckBox   CB_IE: TNewCheckBox;   CB_Flash: TNewCheckBox; {-- --} function CheckHaveApp(): Boolean; var   ResultStr: String;   ResultCode: Integer; begin   if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1', 'UninstallString', ResultStr) then begin      if (MsgBox(' , ?', mbConfirmation, MB_YESNO) = IDYES) then begin         ResultStr := RemoveQuotes(ResultStr);         Exec(ResultStr, '/silent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);         //         if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1', 'UninstallString', ResultStr) then begin           result:=false;         end else begin           result:=true;         end;        end;   end else begin     result:=true;   end; end; {-- NET --} function NeedInstallDotNet(): Boolean; var     success: boolean;     install: cardinal; begin     success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727', 'Install', install);     Result := not(success and (install = 1)); end; {-- IE --} function NeedInstallIE(): Boolean; begin     Result := CB_IE.Checked; end; {-- Flash --} function NeedInstallFlash(): Boolean; begin     Result := CB_Flash.Checked; end; {-- Network --} function NeedInstallNetworkConfig(): Boolean; begin     if FileExists(ExpandConstant('{app}') + '\Prober
etwork.conf') then begin       Result := False;     end else begin       Result := True;      end; end; {-- Probe --} function NeedInstallProbeConfig(): Boolean; begin     if FileExists(ExpandConstant('{app}') + '\Prober\probe.conf') then begin       Result := False;     end else begin       Result := True;      end; end; {-- IE8--} function CheckHaveIE8(): Boolean; var   ResultStr: String;   ResultCode: Integer; begin   RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Internet Explorer', 'Version', ResultStr);   if ResultStr = '8.0.6001.18702' then begin      result := False;   end else begin     result := True;   end; end; {-- --} procedure BeforeInstallDelete(); var   whileLen: Integer; begin     whileLen := 0;     while  whileLen <> 5 do     begin       if(FileExists(ExpandConstant('{app}') + '\Prober\probe.db')) then begin        DeleteFile(ExpandConstant('{app}'+ '\Prober\probe.db'));        whileLen:= whileLen+1;       end else begin        whileLen := 5;       end;     end;     if(FileExists(ExpandConstant('{app}') + '\Prober\probe.db')) then begin       MsgBox(' “\Prober\probe.db” !',mbError, MB_OK);     end;     DelTree(ExpandConstant('{app}'+ '\Prober\log'), True, True, True);     DelTree(ExpandConstant('{app}'+ '\Prober\mq_ext'), True, True, True); end; {-- --} function InitializeSetup(): boolean; var   ResultStr: String;   ResultCode: Integer;   whileLen: Integer; begin   CheckHaveIE8;   //   whileLen := 0;   while  whileLen <> 3 do   begin     if(CheckHaveApp) then begin      result:=true;      whileLen := 3;     end else begin        result:=false;        whileLen:= whileLen+1;     end;   end;   //   if(result) then     begin       if (NeedInstallDotNet) then         begin           MsgBox(' Microsoft .NET Framework 2.0 SP2 .' + #13 + ' .',mbError, MB_OK);           ExtractTemporaryFile('{#MyFormationDotNetName}');            Exec(ExpandConstant('{tmp}\{#MyFormationDotNetName}'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);          end;       if (NeedInstallDotNet) then         begin           MsgBox(' , .',mbError, MB_OK);           Result :=false; //         end        else          begin           Result :=true;  //         end;     end; end; {-- --} procedure CreateTheWizardPages; var   Page: TWizardPage;   Button, FormButton: TNewButton;   Panel: TPanel;   HaveIE8Bool: Boolean; begin   Page := CreateCustomPage(wpWelcome, ' ', ' ');   HaveIE8Bool := CheckHaveIE8;   CB_IE := TNewCheckBox.Create(Page);   CB_IE.Top := ScaleY(35);   CB_IE.Left :=  ScaleY(40);   CB_IE.Width := Page.SurfaceWidth div 2;   CB_IE.Height := ScaleY(17);   CB_IE.Caption := ' IE8 ';   CB_IE.Checked := HaveIE8Bool;   CB_IE.Enabled := HaveIE8Bool;   CB_IE.Parent := Page.Surface;   CB_Flash := TNewCheckBox.Create(Page);   CB_Flash.Top := CB_IE.Top + CB_IE.Height + ScaleY(8);   CB_Flash.Left :=  ScaleY(40);   CB_Flash.Width := Page.SurfaceWidth div 2;   CB_Flash.Height := ScaleY(17);   CB_Flash.Caption := ' Flashplayer11 ';   CB_Flash.Checked := True;   CB_Flash.Parent := Page.Surface; end; {--- --} procedure InitializeWizard; begin   {-- --}   CreateTheWizardPages;   {-- --}   UserPage := CreateInputQueryPage(wpReady,     ' ', ' , ',     ' ');   UserPage.Add(' IP', False);   UserPage.Add(' ID', False);   ConfigBool := True; end; {-- --} function NextButtonClick(CurPageID: Integer): Boolean; begin   Result := True;   if CurPageID = UserPage.ID then begin     if UserPage.Values[0] = '' then begin       MsgBox(' IP', mbError, MB_OK);       Result := False;     end else       if UserPage.Values[1] = '' then begin       MsgBox(' ID', mbError, MB_OK);       Result := False;     end;   end;   if CurPageID = wpReady then begin     if FileExists(ExpandConstant('{app}') + '\Prober
etwork.conf') and FileExists(ExpandConstant('{app}') + '\Prober\probe.conf') then begin       ConfigBool := False;     end;   end; end; {-- --} function ShouldSkipPage(PageID: Integer): Boolean; begin   Result := False;   if PageID = UserPage.ID then begin     if ConfigBool = False then begin       Result := True;     end;    end; end; {-- --} function StringTrim(a: string): string; begin   Result := a;   while pos(' ',Result)<>0 do     delete(Result,pos(' ',Result),1); end; {-- : --} procedure MyAfterInstall(); var   XMLDoc0: Variant;   XMLDoc1: Variant;    s: string;   begin   if ConfigBool then begin     try       XMLDoc0 := CreateOleObject('MSXML2.DOMDocument');       XMLDoc0.async := False;       XMLDoc0.resolveExternals := False;       XMLDoc0.load(ExpandConstant('{app}') + '\Prober
etwork.conf');       XMLDoc0.selectSingleNode('//channel[@name=''balance'']').attributes.getNamedItem('peer_addr').text := StringTrim(UserPage.Values[0]);       XMLDoc0.save(ExpandConstant('{app}') + '\Prober
etwork.conf');     except       RaiseException(' IP, network.conf');     end;     try       XMLDoc1 := CreateOleObject('MSXML2.DOMDocument');       XMLDoc1.async := False;       XMLDoc1.resolveExternals := False;       XMLDoc1.load(ExpandConstant('{app}') + '\Prober\probe.conf');       XMLDoc1.selectSingleNode('//mid').text := StringTrim(UserPage.Values[1]);       XMLDoc1.save(ExpandConstant('{app}') + '\Prober\probe.conf');     except       RaiseException(' ID, probe.conf');     end;    end; end; {-- --} procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); var   XMLDoc0: Variant;   XMLDoc1: Variant;  begin   //   IsUninstallRuned := true;   if CurUninstallStep = usUninstall then begin     if MsgBox(' ?', mbConfirmation, MB_YESNO) = IDYES then begin       IsSaveConfig := True;                 try         XMLDoc0 := CreateOleObject('MSXML2.DOMDocument');         XMLDoc0.async := False;         XMLDoc0.resolveExternals := False;         XMLDoc0.load(ExpandConstant('{app}') + '\Prober
etwork.conf');         XMLDoc0.save(ExpandConstant('{app}') + '\Prober
etwork_tmp.conf');         XMLDoc1 := CreateOleObject('MSXML2.DOMDocument');         XMLDoc1.async := False;         XMLDoc1.resolveExternals := False;         XMLDoc1.load(ExpandConstant('{app}') + '\Prober\probe.conf');         XMLDoc1.save(ExpandConstant('{app}') + '\Prober\probe_tmp.conf');       except       end;     end else begin       IsSaveConfig := False;     end;        end; end; {-- --} procedure DeinitializeUninstall(); var   XMLDoc0: Variant;   XMLDoc1: Variant; begin   //   if IsUninstallRuned then begin     if IsSaveConfig then begin       try                   DeleteFile(ExpandConstant('{app}'+ '\Prober\probe.db'));         DelTree(ExpandConstant('{app}'+ '\Prober\log'), True, True, True);         DelTree(ExpandConstant('{app}'+ '\Prober\mq_ext'), True, True, True);         DelTree(ExpandConstant('{app}'+ '\Prober_Update'), True, True, True);         DelTree(ExpandConstant('{app}'+ '\Prober_Watchdog'), True, True, True);       except         MsgBox(' !', mbInformation, MB_OK);       end;              try         XMLDoc0 := CreateOleObject('MSXML2.DOMDocument');         XMLDoc0.async := False;         XMLDoc0.resolveExternals := False;         XMLDoc0.load(ExpandConstant('{app}') + '\Prober
etwork_tmp.conf');         XMLDoc0.save(ExpandConstant('{app}') + '\Prober
etwork.conf');         XMLDoc1 := CreateOleObject('MSXML2.DOMDocument');         XMLDoc1.async := False;         XMLDoc1.resolveExternals := False;         XMLDoc1.load(ExpandConstant('{app}') + '\Prober\probe_tmp.conf');         XMLDoc1.save(ExpandConstant('{app}') + '\Prober\probe.conf');       except         MsgBox(' !', mbInformation, MB_OK);       end;       try                   DeleteFile(ExpandConstant('{app}'+ '\Prober
etwork_tmp.conf'));         DeleteFile(ExpandConstant('{app}'+ '\Prober\probe_tmp.conf'));       except         MsgBox(' !', mbInformation, MB_OK);       end;              end else begin         DelTree(ExpandConstant('{app}'), True, True, True);     end;   end; end;