用inno setup制作安装程序

用inno setup 5.5.5汉化版制作“我的应用”
代码如下:

补丁日志:
20150724:

1).修复:在卸载面板中,显示卸载图标.(2015-07-21下载地址的代码上是bug,请留意)
解决方法:
[Setup]
UninstallDisplayIcon={app}\install.ico
[Files]
Source: “install.ico”; DestDir: “{app}”; Flags: ignoreversion

2).修复:unins000.exe 显示乱码
解决方法:安装inno setup 5.5.5时,选择unicode格式进行安装

; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "我的应用"
#define MyAppVersion "1.1.2"
#define MyAppPublisher "google公司"
#define MyAppURL "http://www.google.com/"
#define MyAppExeName "gloudarena.exe"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{B82CFEB7-9B37-4CCE-A253-580F33E982F0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}/Gloud/Arena
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=C:\Users\MyPC\Desktop\gameSetup\cn.gloud.arena-20150706-gloud\README.txt
OutputBaseFilename=我的应用
SetupIconFile=C:\Users\MyPC\Desktop\gameSetup\install.ico
Compression=lzma
SolidCompression=yes
;以管理员权限开启
PrivilegesRequired=admin
ChangesAssociations=yes
Uninstallable=yes
UninstallDisplayName=卸载 {#MyAppName} 
UninstallDisplayIcon={app}\install.ico 
WizardImageFile=WizModernImage.bmp
WizardSmallImageFile=WizModernSmallImage.bmp
VersionInfoVersion={#MyAppVersion} 


[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

;创建桌面图标
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; 

[Files]
Source: "C:\Users\MyPC\Desktop\gameSetup\cn.gloud.arena-20150706-gloud\gloudarena.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\MyPC\Desktop\gameSetup\cn.gloud.arena-20150706-gloud\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "install.ico"; DestDir: "{app}"; Flags: ignoreversion 
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

;//桌面图标快捷方式读取.exe
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; WorkingDir: "{app}";     

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




;//注意!代码必须使用[code]段才能够正常运行 
[code] 
//删除所有配置文件以达到干净卸载的目的 
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);

begin

  if CurUninstallStep = usUninstall then

  //if MsgBox('您是否要删除用户配置信息?', mbConfirmation, MB_YESNO) = IDYES then

  //删除 {app} 文件夹及其中所有文件

  DelTree(ExpandConstant('{app}'), True, True, True);

end;

//把安装位置在安装的时候写进注册表中,更新安装的时候你读取注册表中已保存的路径
procedure InitializeWizard();
var ResultStr: String;
    ResultCode: Integer;
begin
  if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion', 'UninstallString', ResultStr) then
  begin
    ResultStr := RemoveQuotes(ResultStr);
    Exec(ResultStr, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  end;
end;


//检查版本号
function GetInstalledVersion(): String;
  var
  InstalledVersion: String;
  begin
  InstalledVersion :='';
  RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion', 'Installed version', InstalledVersion);
  Result := InstalledVersion;
end

;//安装、卸载前检查关闭**进程  
var 
HasRun:HWND;

function InitializeSetup():Boolean;
begin


  //检测运行应用程序
  Result := true;
  HasRun := FindWindowByWindowName('我的应用');
  while HasRun<>0 do
  begin
    if MsgBox('安装程序检测到你的应用程序正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
    begin
      Result := false;
      HasRun := 0;
    end
    else
    begin
      Result := true;
      HasRun := FindWindowByWindowName('Gloud Arena');
    end;
  end;


end;

function InitializeUninstall(): Boolean;
begin
  HasRun := FindWindowByWindowName('我的应用');
  if HasRun<>0 then
  begin
    MsgBox('卸载程序检测到你的应用程序正在运行。' #13#13 '请先退出你的应用程序,然后再进行卸载!', mbError, MB_OK);
    Result := false;
  end
  else
    Result := true;
end;


[/code]

—————————————代码结束———————————————-

安装前关闭程序代码:

function InitializeSetup():Boolean;
//进程ID
var appWnd: HWND;
begin

  Result := true;
  //Log('Checking If Running...');
  //根据窗体名字获取进程ID
  appWnd := FindWindowByWindowName('我的应用');
  if (appWnd <> 0) then
     //进程存在,关闭
     begin
        //Log('Is Runing...');
        //给进程发送关闭消息
        PostMessage(appWnd, 18, 0, 0);       // quit
     end else
     //进程不存在 
     begin 
        //Log('Not Runing...');
     end;


end;

2015-07-21上传360签名的安装包和程序:
下载地址

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值