自解压的方式创建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 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.

时间: 2024-11-06 21:42:44

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

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

原文:DevExpress XtraReports 入门六 控件以程序方式创建一个 交叉表 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这样浪费时间才写的这篇文章,高手不想的看请路过 本文内容来DevExpress XtraReports帮助文档,如看过类似的请略过. 废话少说 开始正事 在继续本示例之前,要把所有 必需的程序集 添加到项目的 引用 列表中,并且把一个按钮拖放到窗体上. 然后,以下列方式接管此按钮的

Android基础入门教程——1.9 Android程序签名打包

Android基础入门教程--1.9 Android程序签名打包 标签(空格分隔): Android基础入门教程 本节引言: 第一章的倒数第二节,本节给大家介绍的是如何将我们的程序打包成Apk文件,并且为我们的Apk签名! 上一节中已经说了,我们后续的教程使用的IDE是Android Studio,所以本节讲解的也是AS(后面都这样 简称吧)下对项目进行打包签名! 1.什么是签名,有什么用: Android APP都需要我们用一个证书对应用进行数字签名,不然的话是无法安装到Android手机上的

Android环境搭建与通过命令行方式创建Android应用

  实验 通过命令行方式创建Android应用 本文主要是先搭建Android环境,再通过命令行方式创建一个Android应用:使用Ant进行编译和打包:使用adb进行部署. (本文主要是为了防止以后再次搭建Android环境的时候忘记步骤...) 实验步骤: 建立实验环境 ①下载ANT 首先从 http://ant.apache.org/bindownload.cgi 下载Apache Ant 如下图进入该页面 访问http://ant.apache.org/bindownload.cgi,选

Java中基本数据类型的存储方式和相关内存的处理方式(java程序员必读经典)

1.java是如何管理内存的 java的内存管理就是对象的分配和释放问题.(其中包括两部分) 分配:内存的分配是由程序完成的,程序员需要通过关键字new为每个对象申请内存空间(基本类型除外),所有的对象都在堆(Heap)中分配空间. 释放:对象的释放是由垃圾回收机制决定和执行的,这样做确实简化了程序员的工作.但同时,它也加重了JVM的工作.因为,GC为了能够正确释放对象,GC必须监控每一个对象的运行状态,包括对象的申请.引用.被引用.赋值等,GC都需要进行监控. 2.什么叫java的内存泄露 在

创建Python程序2

在Milang的IDE里编辑好之后,然后按F5运行一下,就会在下面的Output窗口输出"Hello, World!"字符串,如下图: 恭喜你,你编写最简单的Python程序已经完成,已经成为一个Python的程序员了,对于一门语言的入门,就是这么简单的. 通过上面这个简单的程序,就可看到Python程序是不需要编译,就可以直接运行.在这个程序基础之上,你可以修改它的输出,比如把Hello, World!改为Hello, CSDN,或者其它,你感觉有意义的句子.又或者你把"H

VB 在Visio 2010 以编程方式创建子进程图

在2010年Visio以编程方式创建子进程图 Office 2010  https://msdn.microsoft.com/en-us/library/gg650651.aspx 简介: 学习如何创建子流程图表以编程方式在Microsoft Visio 2010. 最后修改: 2011年4月07日 适用于: Office 2010 | SharePoint Server 2010 | 2010 | Visio Visio溢价2010 在这篇文章中 概述创建一个流程图创建子流程页面移动一个形状子

如何创建C++程序

下载Microsoft Visual C++ 6.0请点击这里:VC 6.0下载(包括中文版英文版)(支持Win7和XP) 首先,我们要进入Microsoft Visual C++集成开发环境(Integrated Develop Environment,简称 IDE),双击图标即可.进入以后,我们可以看到如下界面. 图 1-1  VC 6.0 启动界面 单击左上角的File菜单,选择New,会跳出如下对话框. 图 1-2  创建工程 图1-2所在的是Project(工程)选项卡.设计程序就好像

我的Android 4 学习系列之创建应用程序和Activity:Manifest、Application、Activity

目录 介绍Android应用程序组件,以及使用这些组件构建的各种Android应用程序 Android应用程序的生命周期 如何创建应用程序Manifest 如何使用外部资源提供对位置.语言和硬件配置的支持 如何实现和使用自己的Application类 如何创建新的Activity 理解Activity的状态转换和生命周期 Android应用程序的组成部分 Android应用程序是由松散耦合的组件构成的,并使用应用程序Manifest绑定到一起. Manifest描述了每一个组件以及他们之间的交互

java用Thread方式创建多线程

进程:一个正在执行的程序,每一个进程都有一个执行顺序,该顺序是一个执行路径,或者叫一个控制单元.线程:进程中一个独立的控制单元.线程控制着进程的执行.一个进程中至少有一个线程. java VM中至少有一个线程负责java程序的执行.而且这个线程运行的代码存在于main方法中.该线程为主线程. 扩展,jvm启动了两个线程,一个主线程,一个垃圾回收机制的线程. 1.怎样创建一个多线程?第一种方法:通过继承Thread类的方法 1.继承Thread类 2.重写Thread类的run()方法 目的:将自