用inno setup制作安装程序

来源:互联网 发布:哪些属于大数据项目 编辑:程序博客网 时间:2024/05/16 13:02

用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/ArenaDefaultGroupName={#MyAppName}DisableProgramGroupPage=yesLicenseFile=C:\Users\MyPC\Desktop\gameSetup\cn.gloud.arena-20150706-gloud\README.txtOutputBaseFilename=我的应用SetupIconFile=C:\Users\MyPC\Desktop\gameSetup\install.icoCompression=lzmaSolidCompression=yes;以管理员权限开启PrivilegesRequired=adminChangesAssociations=yesUninstallable=yesUninstallDisplayName=卸载 {#MyAppName} UninstallDisplayIcon={app}\install.ico WizardImageFile=WizModernImage.bmpWizardSmallImageFile=WizModernSmallImage.bmpVersionInfoVersion={#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: ignoreversionSource: "C:\Users\MyPC\Desktop\gameSetup\cn.gloud.arena-20150706-gloud\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirsSource: "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;//进程IDvar 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 0
原创粉丝点击