inno安装

#define MyAppName "HoldChipEngin"
#define MyAppVersion "1.0"
#define MyAppPublisher "Hold Chip, Inc."
#define MyAppURL "http://www.holdchip.com/"
#define MyAppExeName "HoldChipEngin.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={{21B45DFF-B864-480F-81E3-2430C6DCAC0D}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
OutputDir=D:\inno\holdchipengin
OutputBaseFilename=HoldChipEngin
SetupIconFile=D:\HoldChip\logo.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "arabic"; MessagesFile: "compiler:Languages\Arabic.isl"
Name: "bosnian"; MessagesFile: "compiler:Languages\Bosnian.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "bulgarian"; MessagesFile: "compiler:Languages\Bulgarian.isl"
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
Name: "chinesetraditional"; MessagesFile: "compiler:Languages\ChineseTraditional.isl"
Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
Name: "croatian"; MessagesFile: "compiler:Languages\Croatian.isl"
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
Name: "korean"; MessagesFile: "compiler:Languages\Korean.isl"
Name: "latvian"; MessagesFile: "compiler:Languages\Latvian.isl"
Name: "lithuanian"; MessagesFile: "compiler:Languages\Lithuanian.isl"
Name: "malaysian"; MessagesFile: "compiler:Languages\Malaysian.isl"
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "romanian"; MessagesFile: "compiler:Languages\Romanian.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl"
Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
Name: "swedish"; MessagesFile: "compiler:Languages\Swedish.isl"
Name: "thai"; MessagesFile: "compiler:Languages\Thai.isl"
Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
Name: "vietnamese"; MessagesFile: "compiler:Languages\Vietnamese.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; OnlyBelowVersion: 0,6.1

[Files]
Source: "D:\HoldChip\HoldChipEngin.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\HoldChip\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
   
[Code]

function InitializeSetup():boolean;
var
  MykeynotExist:boolean;
  ResultCode: Integer;
  uicmd: String;
begin
  MykeynotExist:= true;
  if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B7F653CF-1BE5-4F40-BA4A-E3BBC6869116}', 'UninstallString', uicmd) then
  begin
  MyKeynotExist:= false;
  MsgBox('安装程序检测到您的系统中已经安装了官方的 {#AppName} '#10#10'你最好先卸载此 {#AppName} 再安装本 {#AppName}',mbInformation,MB_OK)
  Exec(ExpandConstant('{pf}\InstallShield Installation Information\{{B7F653CF-1BE5-4F40-BA4A-E3BBC6869116}\Setup.exe'), '', '', SW_Show, ewNoWait, ResultCode);
  end;
  Result:= MykeynotExist
  if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{49D79F54-D485-4011-83FE-FFC938F3DB86}_is1', 'UninstallString', uicmd) then
  begin
  MyKeynotExist:= false;
  Exec(RemoveQuotes(uicmd), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  end;
  Result:= MykeynotExist
end;  

   
   
    
[Code]
function InitializeUninstall(): Boolean;
var MainRun: HWND;
var MVRun:HWND;
begin
// FindWindowByWindowName函数参数为窗口名,即窗口标题,而非进程名。
MainRun := FindWindowByWindowName('HoldChipEngin');
MVRun := FindWindowByWindowName('HoldChipEngin');
if (MainRun<>0) or (MVRun<>0) then
  begin
    if Msgbox('安装程序检测到客户端正在运行。' #13#13 '单击“是”关闭进程,继续卸载,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
      begin
       Result :=false;                                      // 安装程序退出
      end else
      begin // 如果两个以上的判断条件,在执行时需要分别再进行判断
        if MainRun<>0 then
          begin
            PostMessage(MainRun, 18, 0, 0);                 // 退出主进程
          end;
        if MVRun<>0 then
          begin
            PostMessage(MVRun, 18, 0, 0);                   // 退出Connector进程
          end;
        DelTree(ExpandConstant('{app}'), True, True, True); // 退出进程后删除安装位置所有文件夹
        Result :=true;                                      // 安装程序继续
      end;
  end else
      begin
       Result :=true;                                       // 若未检测到进程,则继续安装程序 
      end;
end;


[Code]

var
ResultStr: String;
Names: TArrayOfString;
B: Boolean;
I: Integer;
S: String;
ErrorCode: Integer;
const AppName ='HoldChipEngin';
function InitializeSetup(): Boolean;
begin
  Result := True;
  if RegGetSubkeyNames(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', Names) then
  begin
    for I := 0 to GetArrayLength(Names)-1 do
      begin
        S := Names[i];
        SetLength(Names[I], 28);
        if AppName=Names[I] then
        begin
          //注册表中找到了此键
          B := RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'+S, 'UninstallString', ResultStr)
          ResultStr := RemoveQuotes(ResultStr);
          if B then
          begin
            MsgBox('您曾安装过本软件,即将卸载!', mbInformation, MB_OK);
            Exec(ResultStr, '/VERYSILENT', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode);
            Result := False;
          end
        break;
        end
      end;
  end;
end;

  
[Code]
procedure InitializeWizard();
var ResultStr:String;
    ResultCode:Integer;
begin
  if RegQueryStringValue(HKLM,'SOFTWARE\Microsoft\Windows\CurrentVersion\Unistall\HoldChipEngin',
     'UninstallString',ResultStr) then
     begin
     ResultStr :=RemoveQuotes(ResultStr);
     Exec(ResultStr,'','',SW_SHOWNORMAL, ewWaitUntilTerminated,ResultCode);
     end;
   end;
   

转载于:https://my.oschina.net/xuxinxin/blog/1834287

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值