zoukankan      html  css  js  c++  java
  • 自解压的方式创建VC++程序的打包

    Walkthrough: Deploying a Visual C++ Application By Using the Visual C++ Redistributable Package

    Visual Studio 2015
     
     
     

    This step-by-step article describes how to use the Visual C++ Redistributable Package to deploy a Visual C++ application.

    Prerequisites

    You must have these components to complete this walkthrough:

    • A computer that has Visual Studio installed.

    • An additional computer that does not have the Visual C++ libraries.

    To use the Visual C++ Redistributable Package to deploy an application

    1. Create and build an MFC application by following the first three steps in Walkthrough: Deploying a Visual C++ Application By Using a Setup Project.

    2. Create a file, name it setup.bat, and add the following commands to it. Change MyMFCApplication to the name of your project.

       
       
                  @echo off
      vcredist_x86.exe
      mkdir "C:Program FilesMyMFCApplication"
      copy MyMFCApplication.exe "C:Program FilesMyMFCApplication"
      
    3. Create a self-extracting setup file:

      1. At a command prompt or in the Run window, run iexpress.exe.

      2. Select Create new Self Extraction Directive file and then choose the Next button.

      3. Select Extract files and run an installation command and then choose Next.

      4. In the text box, enter the name of your MFC application and then choose Next.

      5. On the Confirmation prompt page, select No Prompt and then choose Next.

      6. On the License agreement page, select Do not display a license and then choose Next.

      7. On the Packaged files page, add the following files and then choose Next.

        • Your MFC application (.exe file).

        • vcredist_x86.exe. This file is located in Program FilesMicrosoft SDKsWindowsv7.0ABootstrapperPackagesvcredist_x86.

        • The setup.bat file that you created in the earlier step.

      8. On the Install Program to Launch page, in the Install Program text box, enter the following command line and then choose Next.

        cmd.exe /c "setup.bat"

      9. On the Show window page, select Default and then choose Next.

      10. On the Finished message page, select No message and then choose Next.

      11. On the Package Name and Options page, enter a name for your self-extracting setup file, select the Store files using Long File Name inside Package option, and then choose Next. The end of the file name must be Setup.exe—for example, MyMFCApplicationSetup.exe.

      12. On the Configure restart page, select No restart and then choose Next.

      13. On the Save Self Extraction Directive page, select Save Self Extraction Directive (SED) file and then choose Next.

      14. On the Create package page, choose Next.

    4. Test the self-extracting setup file on the other computer, which does not have the Visual C++ libraries:

      1. On the other computer, download a copy of the setup file, and then install it by running it and following the steps that it provides.

      2. Run the MFC application.

        The self-extracting setup file installs the MFC application that is in the folder that you specified in step 2. The application runs successfully because the Visual C++ Redistributable Package installer is included in the self-extracting setup file.

        System_CAPS_importantImportant

        To determine which version of the runtime is installed, the installer checks the registry key HKLMSOFTWAREMicrosoftVisualStudio11.0VCRuntimes[platform]. If the currently installed version is newer than the version that the installer is attempting to install, the installer returns success without installing the older version and leaves an additional entry on the installed programs page in the Control Panel.

        Redistributing Visual C++ Files

        Visual Studio 2015
         
        Other Versions
         
         

        When you deploy an application, you must also deploy the files that are required to support it. If any of these files are provided by Microsoft, check whether you are permitted to redistribute them. To review the Microsoft Software License Terms, see License.htm in the directory where Visual Studio is installed, or on the Visual Studio installation media. To view the "REDIST list" that is referenced in the "Distributable Code" section of the Microsoft Software License Terms for certain editions of Visual Studio, see Distributable Code for Microsoft Visual Studio 2015 and Microsoft Visual Studio 2015 SDK on the Microsoft website. For more information about redistributable files, see Determining Which DLLs to Redistribute and Deployment Examples.

        To deploy redistributable Visual C++ files, you can use the Visual C++ Redistributable Packages (VCRedist_x86.exe, VCRedist_x64.exe, or VCRedist_arm.exe) that are included in Visual Studio. These files can be found under your Visual Studio installation directory in Program Files [(x86)]Microsoft Visual Studio versionVC edistlocale. Another option is to use redistributable merge modules (.msm files), which can be found in Program Files [(x86)]Common FilesMerge Modules. It's also possible to directly install redistributable Visual C++ DLLs in the application local folder, which is the folder that contains your executable application file. For servicing reasons, we do not recommend that you use this installation location.

        The Visual C++ Redistributable Packages install and register all Visual C++ libraries. If you use one, you must set it to run on the target system as a prerequisite to the installation of your application. We recommend that you use these packages for your deployments because they enable automatic updating of the Visual C++ libraries. For an example about how to use these packages, see Walkthrough: Deploying a Visual C++ Application By Using the Visual C++ Redistributable Package.

        Each Visual C++ Redistributable Package checks for the existence of a more recent version on the machine. If a more recent version is found, the package is not installed. Starting in Visual Studio 2015, redistributable packages display an error message stating that setup failed. If a package is run by using the /quiet flag, no error message is displayed. In either case, an error is logged by the Microsoft installer, and an error result is returned to the caller. Starting in Visual Studio 2015 packages, you can check a registry value to find out if a more recent version is installed. The currently installed version is stored as a REG_SZ value in the Version key in HKEY_LOCAL_MACHINESOFTWARE[Wow6432Node]MicrosoftDevDivvcServicing14.0RuntimeMinimum. You don't need to install your redistributable package if the currently installed version is more recent.

        If you use a merge module that contains a Visual C++ DLL, you must include it in the Windows Installer package (or similar installation package) that you are using to deploy the application. For more information, see Redistributing Components By Using Merge Modules. For an example, see Walkthrough: Deploying a Visual C++ Application By Using a Setup Project, which also shows how to use InstallShield Limited Edition to create an installation package.

        Potential Run-Time Errors

         

        If a Visual C++ library DLL is not reachable and Windows cannot load it for your application, this message may be displayed: This application has failed to start because MSVCR<version number>.dll was not found. Re-installing the application may fix this problem.

        To resolve this kind of error, make sure that your application builds correctly and that Visual C++ libraries are correctly deployed on the target system. For more information, see Understanding the Dependencies of a Visual C++ Application.

        Related Topics

         

        Title

        Description

        Redistributing Components By Using Merge Modules

        Describes how to use Visual C++ redistributable merge modules to install the Visual C++ runtime libraries as shared DLLs in the %windir%system32 folder.

        Redistributing Visual C++ ActiveX Controls

        Describes how to redistribute an application that uses ActiveX Controls.

        Redistributing Database Support Files

        Discusses how to redistribute support files for Data Access Objects (DAO) and the database technologies in the Microsoft Data Access SDK.

        Redistributing the MFC Library

        Describes how to redistribute an application that uses MFC.

        Redistributing an ATL application

        Describes how to redistribute an application that uses ATL. Starting in Visual Studio 2012, no redistributable library for ATL is required.

        Deployment Examples

        Links to examples that demonstrate how to deploy Visual C++ applications.

        Deploying Native Desktop Applications (Visual C++)

        Introduces Visual C++ deployment concepts and technologies.

  • 相关阅读:
    【NOIp模拟赛】种花
    【NOIP模拟赛】质数序列
    【NOIp模拟赛】兔子
    【NOIp模拟赛】圆桌游戏
    【NOIp模拟赛】花
    【洛谷P2345】奶牛集会
    【洛谷P1774】最接近神的人_NOI导刊2010提高(02)
    【洛谷P1495】 曹冲养猪
    【洛谷P1287】 盒子与球
    NOIP2009 Hankson 的趣味题
  • 原文地址:https://www.cnblogs.com/micro-chen/p/5953315.html
Copyright © 2011-2022 走看看