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 Files\MyMFCApplication"
    copy MyMFCApplication.exe "C:\Program Files\MyMFCApplication"
  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 Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\vcredist_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.

      Important

      To determine which version of the runtime is installed, the installer checks the registry key \HKLM\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\[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 version\VC\redist\locale\. Another option is to use redistributable merge modules (.msm files), which can be found in Program Files [(x86)]\Common Files\Merge 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_MACHINE\SOFTWARE[\Wow6432Node]\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum. 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.

自解压的方式创建VC++程序的打包的更多相关文章

  1. DevExpress XtraReports 入门六 控件以程序方式创建一个 交叉表 报表

    原文:DevExpress XtraReports 入门六 控件以程序方式创建一个 交叉表 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助 ...

  2. Thread类的常用方法_sleep和创建多线程程序的第二种方式_实现Runnable接口

    sleep方法是在Thread类中的一个静态方法,当一个线程调用了sleep方法,被调用的那个线程就会暂时的让出指定时间的CPU执行权,在这段时间也不会参与CPU的调度,当时间到了之后,就会重新回到就 ...

  3. 创建多线程程序的第一种方式_创建Thread类的子类

    创建多线程程序的第一种方式:创建Thread类的子类java.lang.Thread类:是描述线程的类,我们想要实现多线程程序,就必须继承Thread类 实现步骤: 1.创建一个Thread类的子类 ...

  4. 主线程和创建多线程程序的第一种方式_创建Thread类的子类

    /** * 主线程:执行主方法的线程(main) * 单线程程序:在java程序中只有一个线程 * 执行从main方法开始,从上倒下依次执行 */ public class Demo01MainThr ...

  5. C# winform程序怎么打包成安装项目(VS2010图解)

    作为研发人员,在本机上开发的winform.wpf或者控制台程序需要发给其他人测试时候,一般需要对其进行打包生成setup安装文件,根据网上查找的资料并结合自己打包成功,记录如下: 注:本程序是一个利 ...

  6. 用node-webkit(NW.js)创建桌面程序

    以往写windows桌面程序需要用MFC.C#之类的技术,那么如果你只会web开发技术呢?或者说你有一个网站,但是你想把你的网站打包成一个桌面应用程序,该如何做呢? 答案就是用node-webkit这 ...

  7. Java应用程序的打包和发布

    Java应用程序的打包和发布 简化Java应用程序的打包和发布 发布Java应用程序时Java提供了一系列打包和发布工具,可以显著的简化发布过程 该文章提供了打包Java code的几种方法,探讨Ja ...

  8. 使用WiX Toolset创建.NET程序发布Bootstrapper(安装策略管理)(二)——自定义安装

    原文:使用WiX Toolset创建.NET程序发布Bootstrapper(安装策略管理)(二)--自定义安装 自定义产品卸载方式 继续从上一次的基础上前进,现在我们已经知道了最简单的bootstr ...

  9. 使用WiX Toolset创建.NET程序发布Bootstrapper(安装策略管理)(一)——初识WiX

    原文:使用WiX Toolset创建.NET程序发布Bootstrapper(安装策略管理)(一)--初识WiX Visual Studio 打包安装七宗罪 开发.NET的人,肯定会使用Visual ...

随机推荐

  1. html+javascript实现可拖动弹出层、对话框、可提交

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org ...

  2. html5 教程

    http://www.tutorialspoint.com/html5/index.htm

  3. [Javascript ] Array methods in depth - sort

    Sort can automatically arrange items in an array. In this lesson we look at the basics including how ...

  4. 【解决】WordPress FTP连接服务器时出错,请检查设置,WordPress需要访问您网页服务器的权限

    刚装好wordpress,发现后台预装了两个插件,想删掉,结果要登录FTP,死活登不上去,提示"连接服务器时出错,请检查设置,WordPress需要访问您网页服务器的权限",网上也 ...

  5. 30款jQuery常用网页焦点图banner图片切换 下载 (转)

    1.jquery 图片滚动特效制作 slide 图片类似窗帘式图片滚动 查看演示 2.jquery幻灯片插件带滚动条的圆形立体图片旋转滚动 查看演示 3.jQuery图片层叠旋转类似洗牌翻转图片幻灯片 ...

  6. OD: Vulnerability Detection

    终于看完第二篇漏洞利用原理高级篇,内容虽然看懂了,但深入理解不够,这部分内容以后还要不断强化. 第三篇是漏洞挖掘技术,篇首的话中,提到程序的不可计算性(图灵机的停机问题).希伯尔数学纲领的失败,结尾说 ...

  7. python单元测试之unittest

    unittest是python标准库,从2.1开始就有. 标准的使用流程: 1:实现一个unittest.TestCase的子类 2:在其中定义以_test开头的实例函数 3:用unittest.ma ...

  8. vs2012加载EntityFrameWork框架,连接Oracel

    近日公司用到.net MVC框架做接口,需连接到Oracel数据库,从网上查阅了一些资料,当然,从咱们博客园获益匪浅.然后结合自己所做,把使用过程中遇到的一些问题,及如何解决的整理如下,方便查阅,也有 ...

  9. 遍历页面上所有TextBox,并赋值为String.Empty

    //不含母板页 foreach (System.Web.UI.Control txtobj in this.Page.Controls)   {     if (txtobj.GetType().Na ...

  10. 策略模式Strategy(对象行为型)

    原文地址:http://blog.csdn.net/hguisu/article/details/75582491.策略模式:定义一系列的算法,把每一个算法封装起来, 并且使它们可相互替换.本模式使得 ...