zoukankan      html  css  js  c++  java
  • 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:UsersgxjDesktopTFriend
     26 OutputBaseFilename=setup
     27 Compression=lzma
     28 SolidCompression=yes
     29 
     30 [Languages]
     31 Name: "english"; MessagesFile: "compiler:Default.isl"
     32 Name: "brazilianportuguese"; MessagesFile: "compiler:LanguagesBrazilianPortuguese.isl"
     33 Name: "catalan"; MessagesFile: "compiler:LanguagesCatalan.isl"
     34 Name: "corsican"; MessagesFile: "compiler:LanguagesCorsican.isl"
     35 Name: "czech"; MessagesFile: "compiler:LanguagesCzech.isl"
     36 Name: "danish"; MessagesFile: "compiler:LanguagesDanish.isl"
     37 Name: "dutch"; MessagesFile: "compiler:LanguagesDutch.isl"
     38 Name: "finnish"; MessagesFile: "compiler:LanguagesFinnish.isl"
     39 Name: "french"; MessagesFile: "compiler:LanguagesFrench.isl"
     40 Name: "german"; MessagesFile: "compiler:LanguagesGerman.isl"
     41 Name: "greek"; MessagesFile: "compiler:LanguagesGreek.isl"
     42 Name: "hebrew"; MessagesFile: "compiler:LanguagesHebrew.isl"
     43 Name: "hungarian"; MessagesFile: "compiler:LanguagesHungarian.isl"
     44 Name: "italian"; MessagesFile: "compiler:LanguagesItalian.isl"
     45 Name: "japanese"; MessagesFile: "compiler:LanguagesJapanese.isl"
     46 Name: "norwegian"; MessagesFile: "compiler:LanguagesNorwegian.isl"
     47 Name: "polish"; MessagesFile: "compiler:LanguagesPolish.isl"
     48 Name: "portuguese"; MessagesFile: "compiler:LanguagesPortuguese.isl"
     49 Name: "russian"; MessagesFile: "compiler:LanguagesRussian.isl"
     50 Name: "scottishgaelic"; MessagesFile: "compiler:LanguagesScottishGaelic.isl"
     51 Name: "serbiancyrillic"; MessagesFile: "compiler:LanguagesSerbianCyrillic.isl"
     52 Name: "serbianlatin"; MessagesFile: "compiler:LanguagesSerbianLatin.isl"
     53 Name: "slovenian"; MessagesFile: "compiler:LanguagesSlovenian.isl"
     54 Name: "spanish"; MessagesFile: "compiler:LanguagesSpanish.isl"
     55 Name: "turkish"; MessagesFile: "compiler:LanguagesTurkish.isl"
     56 Name: "ukrainian"; MessagesFile: "compiler:LanguagesUkrainian.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:DataTFriendRTKehux64Releasestartup.bat"; DestDir: "{app}"; Flags: ignoreversion
     64 Source: "C:DataTFriendRTKehux64Release2005_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
     65 Source: "C:DataTFriendRTKehux64Release2008_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
     66 Source: "C:DataTFriendRTKehux64Release2010_IA64.exe"; DestDir: "{app}"; Flags: ignoreversion
     67 Source: "C:DataTFriendRTKehux64Release2012_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
     68 Source: "C:DataTFriendRTKehux64Release2013_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
     69 Source: "C:DataTFriendRTKehux64Release2014_x64.exe"; DestDir: "{app}"; Flags: ignoreversion
     70 Source: "C:DataTFriendRTKehux64Releasecmd5.obj"; DestDir: "{app}"; Flags: ignoreversion
     71 Source: "C:DataTFriendRTKehux64Releaseexplorer1.obj"; DestDir: "{app}"; Flags: ignoreversion
     72 Source: "C:DataTFriendRTKehux64ReleaseGetSysInfo.obj"; DestDir: "{app}"; Flags: ignoreversion
     73 Source: "C:DataTFriendRTKehux64ReleaseGoodInf.obj"; DestDir: "{app}"; Flags: ignoreversion
     74 Source: "C:DataTFriendRTKehux64Releasejietu.obj"; DestDir: "{app}"; Flags: ignoreversion
     75 Source: "C:DataTFriendRTKehux64Releasejson_reader.asm"; DestDir: "{app}"; Flags: ignoreversion
     76 Source: "C:DataTFriendRTKehux64Releasejson_value.asm"; DestDir: "{app}"; Flags: ignoreversion
     77 Source: "C:DataTFriendRTKehux64Releasejson_writer.asm"; DestDir: "{app}"; Flags: ignoreversion
     78 Source: "C:DataTFriendRTKehux64ReleaseKehu.Build.CppClean.log"; DestDir: "{app}"; Flags: ignoreversion
     79 Source: "C:DataTFriendRTKehux64ReleaseKehu.exe"; DestDir: "{app}"; Flags: ignoreversion
     80 Source: "C:DataTFriendRTKehux64ReleaseKehu.log"; DestDir: "{app}"; Flags: ignoreversion
     81 Source: "C:DataTFriendRTKehux64ReleaseKehu.obj"; DestDir: "{app}"; Flags: ignoreversion
     82 Source: "C:DataTFriendRTKehux64ReleaseKehu.res"; DestDir: "{app}"; Flags: ignoreversion
     83 Source: "C:DataTFriendRTKehux64ReleaseKehuDlg.obj"; DestDir: "{app}"; Flags: ignoreversion
     84 Source: "C:DataTFriendRTKehux64Releaselibmysql.dll"; DestDir: "{app}"; Flags: ignoreversion
     85 Source: "C:DataTFriendRTKehux64ReleaseMainMenu.obj"; DestDir: "{app}"; Flags: ignoreversion
     86 Source: "C:DataTFriendRTKehux64ReleaseMyTracker.obj"; DestDir: "{app}"; Flags: ignoreversion
     87 Source: "C:DataTFriendRTKehux64ReleaseNews.obj"; DestDir: "{app}"; Flags: ignoreversion
     88 Source: "C:DataTFriendRTKehux64ReleaseScreepJieTu.obj"; DestDir: "{app}"; Flags: ignoreversion
     89 Source: "C:DataTFriendRTKehux64Releasestartup.bat"; DestDir: "{app}"; Flags: ignoreversion
     90 Source: "C:DataTFriendRTKehux64Releasestdafx.obj"; DestDir: "{app}"; Flags: ignoreversion
     91 Source: "C:DataTFriendRTKehux64Releasevc120.pdb"; DestDir: "{app}"; Flags: ignoreversion
     92 Source: "C:DataTFriendRTKehux64ReleaseWMI_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}MicrosoftInternet ExplorerQuick 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=HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall"
     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=HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall"
    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

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

  • 相关阅读:
    【转】常见经济类名词解释
    Linux parted命令详解
    【转】Linux下从TCP状态机,三次握手判断DDOS攻击
    【转】Java学习---HashMap和HashSet的内部工作机制
    【转】Redis学习---阿里云Redis多线程性能增强版详解
    改变自己,改变世界
    对话任正非两万字实录:最重要的是要沉着
    qt手写输入法资料
    Qt框架及模块认识
    哲学必读10本经典著作
  • 原文地址:https://www.cnblogs.com/gongxijun/p/4789479.html
Copyright © 2011-2022 走看看