c/c++ 软件集成 安装和可卸载软件

  作为一个工程师应具备的一些能力:

1. 首先具备这款软件:  

  >inno  Setup      免费版还开源,良心货,妥妥的。

2. 这款软件上手也比较款,可自行参考使用文档

3.编译成功,生成代码之后,样子可能如下:

  1 ; Script generated by the Inno Setup Script Wizard.
  2 ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
  3 
  4 #define MyAppName "My Program"
  5 #define MyAppVersion "beta 1.0"
  6 #define MyAppPublisher "精灵球网络科技有限公司, Inc."
  7 #define MyAppURL "http://www.cnblogs.com/gongxijun/"
  8 #define MyAppExeName "startup.bat"
  9 
 10 [Setup]
 11 ; NOTE: The value of AppId uniquely identifies this application.
 12 ; Do not use the same AppId value in installers for other applications.
 13 ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
 14 AppId={{FA1B17D2-4CC5-465E-9A5F-DCA022B6EA1A}
 15 AppName={#MyAppName}
 16 AppVersion={#MyAppVersion}
 17 ;AppVerName={#MyAppName} {#MyAppVersion}
 18 AppPublisher={#MyAppPublisher}
 19 AppPublisherURL={#MyAppURL}
 20 AppSupportURL={#MyAppURL}
 21 AppUpdatesURL={#MyAppURL}
 22 DefaultDirName={pf}\{#MyAppName}
 23 DefaultGroupName={#MyAppName}
 24 AllowNoIcons=yes
 25 OutputDir=D:\Users\gxj\Desktop\TFriend
 26 OutputBaseFilename=setup
 27 Compression=lzma
 28 SolidCompression=yes
 29 
 30 [Languages]
 31 Name: "english"; MessagesFile: "compiler:Default.isl"
 32 Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
 33 Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
 34 Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
 35 Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
 36 Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
 37 Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
 38 Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
 39 Name: "french"; MessagesFile: "compiler:Languages\French.isl"
 40 Name: "german"; MessagesFile: "compiler:Languages\German.isl"
 41 Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
 42 Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
 43 Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
 44 Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
 45 Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
 46 Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
 47 Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
 48 Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
 49 Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
 50 Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
 51 Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
 52 Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
 53 Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
 54 Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
 55 Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
 56 Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
 57 
 58 [Tasks]
 59 Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
 60 Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
 61 
 62 [Files]
 63 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\startup.bat"; DestDir: "{app}"; Flags: ignoreversion
 64 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\2005_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
 65 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\2008_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
 66 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\2010_IA64.exe"; DestDir: "{app}"; Flags: ignoreversion
 67 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\2012_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
 68 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\2013_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
 69 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\2014_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
 70 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\cmd5.obj"; DestDir: "{app}"; Flags: ignoreversion
 71 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\explorer1.obj"; DestDir: "{app}"; Flags: ignoreversion
 72 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\GetSysInfo.obj"; DestDir: "{app}"; Flags: ignoreversion
 73 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\GoodInf.obj"; DestDir: "{app}"; Flags: ignoreversion
 74 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\jietu.obj"; DestDir: "{app}"; Flags: ignoreversion
 75 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\json_reader.asm"; DestDir: "{app}"; Flags: ignoreversion
 76 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\json_value.asm"; DestDir: "{app}"; Flags: ignoreversion
 77 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\json_writer.asm"; DestDir: "{app}"; Flags: ignoreversion
 78 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\Kehu.Build.CppClean.log"; DestDir: "{app}"; Flags: ignoreversion
 79 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\Kehu.exe"; DestDir: "{app}"; Flags: ignoreversion
 80 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\Kehu.log"; DestDir: "{app}"; Flags: ignoreversion
 81 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\Kehu.obj"; DestDir: "{app}"; Flags: ignoreversion
 82 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\Kehu.res"; DestDir: "{app}"; Flags: ignoreversion
 83 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\KehuDlg.obj"; DestDir: "{app}"; Flags: ignoreversion
 84 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\libmysql.dll"; DestDir: "{app}"; Flags: ignoreversion
 85 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\MainMenu.obj"; DestDir: "{app}"; Flags: ignoreversion
 86 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\MyTracker.obj"; DestDir: "{app}"; Flags: ignoreversion
 87 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\News.obj"; DestDir: "{app}"; Flags: ignoreversion
 88 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\ScreepJieTu.obj"; DestDir: "{app}"; Flags: ignoreversion
 89 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\startup.bat"; DestDir: "{app}"; Flags: ignoreversion
 90 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\stdafx.obj"; DestDir: "{app}"; Flags: ignoreversion
 91 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\vc120.pdb"; DestDir: "{app}"; Flags: ignoreversion
 92 Source: "C:\Data\TFriend\RT\Kehu\x64\Release\WMI_DeviceQuery.obj"; DestDir: "{app}"; Flags: ignoreversion
 93 ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
 94 
 95 [Icons]
 96 Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
 97 Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
 98 Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
 99 Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
100 Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
101 
102 [Run]
103 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: shellexec postinstall skipifsilent

3. 在集成的时候,有时,如果有特殊的条件需要集成运行库,那就得写下如下的批处理文件,并将要集成的运行库下载放到打包文件中,然后参考如下文件: 

 1 @echo off
 2 ::::::查询微软软件当前的注册表
 3 set "HKLMU=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
 4 reg query %HKLMU%\{6E8E85E8-CE4B-4FF5-91F7-04999C9FAE6A}>nul 2>nul&&set VC2005=Microsoft Visual C++ 2005 Redistributable X64
 5 reg query %HKLMU%\{071C9B48-7C32-4621-A0AC-3F809523288F}>nul 2>nul&&set VC2005=Microsoft Visual C++ 2005 SP1 Redistributable X64
 6 reg query %HKLMU%\{6CE5BAE9-D3CA-4B99-891A-1DC6C118A5FC}>nul 2>nul&&set VC2005=Microsoft Visual C++ 2005 SP1 Redistributable ATL Security Update X64
 7 reg query %HKLMU%\{03ED71EA-F531-4927-AABD-1C31BCE8E187}>nul 2>nul&&set VC2005=Microsoft Visual C++ 2005 Redistributable IA64
 8 reg query %HKLMU%\{0F8FB34E-675E-42ED-850B-29D98C2ECE08}>nul 2>nul&&set VC2005=Microsoft Visual C++ 2005 SP1 Redistributable IA64
 9 reg query %HKLMU%\{85025851-A784-46D8-950D-05CB3CA43A13}>nul 2>nul&&set VC2005=Microsoft Visual C++ 2005 SP1 Redistributable ATL Security Update IA64
10 
11 if defined VC2005 (echo %VC2005% 已安装!&ping -n 5 127.1>nul) else (goto VC2005)
12 
13 :VC2005Install
14 @echo on
15 @echo 安装运行中.....请耐心等待!
16 :::::将运行库放置打包到和需要支持的软件一起
17 @if exist 2005_x64.exe (echo 开始安装..... &start 2005_x64.exe &ping -n 10 127.1 >nul) else (echo 没有找到安装包!请自己下载VC2005并按照  &goto QVC2008)
18 
19 :QVC2008
20 set "HKLMU=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
21 reg query %HKLMU%\{350AA351-21FA-3270-8B7A-835434E766AD}>nul 2>nul&&set VC2008=Microsoft Visual C++ 2008 Redistributable X64
22 reg query %HKLMU%\{8220EEFE-38CD-377E-8595-13398D740ACE}>nul 2>nul&&set VC2008=Microsoft Visual C++ 2008 SP1 Redistributable X64
23 reg query %HKLMU%\{4B6C7001-C7D6-3710-913E-5BC23FCE91E6}>nul 2>nul&&set VC2008=Microsoft Visual C++ 2008 SP1 Redistributable ATL Security Update X64
24 reg query %HKLMU%\{2B547B43-DB50-3139-9EBE-37D419E0F5FA}>nul 2>nul&&set VC2008=Microsoft Visual C++ 2008 Redistributable IA64
25 reg query %HKLMU%\{5827ECE1-AEB0-328E-B813-6FC68622C1F9}>nul 2>nul&&set VC2008=Microsoft Visual C++ 2008 SP1 Redistributable IA64
26 reg query %HKLMU%\{977AD349-C2A8-39DD-9273-285C08987C7B}>nul 2>nul&&set VC2008=Microsoft Visual C++ 2008 SP1 Redistributable ATL Security Update IA64
27 
28 if defined VC2008 (echo %VC2008% 已安装!&ping -n 5 127.1>nul) else (goto VC2008)
29 @if exist 2008_x64.exe (echo 开始安装..... &start 2008_x64.exe &ping -n 10 127.1 >nul) else (echo 没有找到安装包!请自己下载VC2005并按照  &goto QVC2010)
30 
31 :QVC2010
32 @if exist 2010_IA64 (start 2010_IA64.exe) else goto CC
33 @echo 开始安装.....
34 @ping -n 10 127.1 >nul
35 :CC
36 @if exist 2012_x64.exe (start 2012_x64.exe) else goto DD
37 @echo 开始安装.....
38 @ping -n 10 127.1 >nul
39 :DD
40 @if exist 2013_x64.exe (start 2013_x64.exe) else goto EE
41 @echo 开始安装.....
42 @ping -n 10 127.1 >nul
43 
44 :EE
45 @if exist 2014_x64.exe (start 2014_x64.exe) else goto FF
46 @echo 开始安装.....
47 @ping -n 10 127.1 >nul
48 
49 :FF
50 @if exist Kehu.exe (start Kehu.exe) else echo 安装失败,请重新安装 
51 @echo 按任意键结束.........
52 pause
53 @echo off

这样之后,当你点击生成的软件之后,它就会像我们以前首先的软件一样,成为一款正规的软件,具备安转,卸载,注册,以及自动检测运行库是否安装,并自动安装的软件了!!!

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏程序员的SOD蜜

.NET DLR 上的IronScheme 语言互操作&&IronScheme控制台输入中文的问题

前言 一直以来对Lisp语言怀有很崇敬的心里,《黑客与画家》对Lisp更是推崇备至,虽然看了不少有关Lisp的介绍但都没有机会去写段程序试试,就像我对C++一样...

27560
来自专栏张善友的专栏

在Mono 2.8上部署ASP.NET MVC 2

Mono 2.8发布:C#4.0和更好的性能,我们知道Mono 2.8对ASP.NET MVC 2的完全支持,下面我们就来测试下在Mono 2.8上部署ASP....

21350
来自专栏张善友的专栏

ASP.NET MVC 1.0 RC 那些事

Scott Gu宣布了ASP.NET MVC 1.0 RC的发布, Scott Gu在blog上写了一篇ASP.NET MVC 1.0 Release Cand...

18990
来自专栏程序员与猫

.NET CORE——Console中使用依赖注入

20930
来自专栏自由而无用的灵魂的碎碎念

vs2008 Web 页面切换设计视图无反应问题的解决(Office 2010 与 Visual Studio 2008 兼容性问题的解决)

Office 2010正式发布后,我把笔记本上的 Office 2007 卸载掉,安装了Office 2010,安装好打开 VS2008 修改一个网站,使用 V...

10620
来自专栏张善友的专栏

Json.NET 3.0

Json.NET,提供相当完整的文档之外,还提供了 LINQ to JSON 的 LINQ Provider 可以更方便的读取JSON 对象,今后将可比以往用更...

20760
来自专栏bboysoul

Koadic的安装和使用

Koadic是DEFCON分型出来的一个后渗透工具,主要通过vbscript、jscript进行大部分操作 废话不多说开始演示

13650
来自专栏乐百川的学习频道

.NET Core 2.0发布了

.NET Core 2.0 长久以来,.NET框架一直因为只能在Windows系统上运行而被人黑。所以微软重写了一个跨平台的.NET,这就是.NET Core。...

270100
来自专栏施炯的IoT开发专栏

Visual Studio 2013 Update 2 RTM 发布

今天,微软再Visual Studio Blog发布了开放 Visual Studio 2013 Update 2 RTM 下载的文章。 原来安装RC版本的同志...

185100
来自专栏ASP.NETCore

ASP.NET Core中的ActionFilter与DI

  前几篇文章都是讲ASP.NET Core MVC中的依赖注入(DI)与扩展点的,也许大家都发现在ASP.NET CORE中所有的组件都是通过依赖注入来扩展的...

15150

扫码关注云+社区

领取腾讯云代金券