Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MicrosoftDocs/cpp-docs/llms.txt

Use this file to discover all available pages before exploring further.

Shipping a Windows desktop application built with Visual C++ requires more than just compiling the binary — you must also ensure that all runtime dependencies (the Visual C++ Redistributable, UCRT, and any third-party DLLs) are available on the target machine. Visual Studio provides three deployment strategies: central deployment (installing the Redistributable system-wide), local deployment (placing DLLs alongside your executable), and static linking (embedding the CRT into your binary). Choosing the right strategy impacts security, update agility, and installer size.

Deployment Strategies Overview

Central Deployment

Install the Visual C++ Redistributable into Windows\System32. Libraries are shared, Windows Update can patch them automatically. Recommended for most applications.

Local Deployment

Place the required DLLs in the same directory as your .exe. Simple but requires you to update bundled DLLs manually when security patches are released.

Static Linking

Embed CRT code directly into your binary with /MT. No DLL dependency, but the binary is larger and CRT updates require recompilation and redistribution.

The Visual C++ Redistributable

The Visual C++ Redistributable package (VC_redist.x64.exe, VC_redist.x86.exe) installs msvcp140.dll, vcruntime140.dll, concrt140.dll, and related files into the Windows system directory. All versions from Visual Studio 2015 through 2026 share the same major version number (14.x), making them binary-compatible. Installing the latest package satisfies all 2015–2026 applications.
# Central deployment: silently install the VC++ Redistributable
VC_redist.x64.exe /install /quiet /norestart

# Check exit code:
# 0   = success
# 1638 = newer version already installed (not an error)
# 3010 = reboot required
If your installer receives exit code 0x80070666 (“Another version of this product is already installed”), a newer version is already present. This is expected and safe — treat it as success.
Key Redistributable details:
PropertyDetails
Download sourceLatest supported VC++ Redistributable
Binary compatibilityVS 2015 through VS 2026 (v140v145)
Install location%SystemRoot%\System32 (x64) / %SystemRoot%\SysWOW64 (x86 on x64 OS)
Update mechanismWindows Update can service it independently

Installer Technologies

MSIX is the modern Windows packaging format for desktop apps. It provides sandboxed installation, automatic updates, clean uninstallation, and support for Microsoft Store distribution.
<!-- AppxManifest.xml excerpt -->
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
         xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10">
  <Identity Name="Contoso.MyApp"
            Publisher="CN=Contoso"
            Version="1.0.0.0"
            ProcessorArchitecture="x64" />
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Desktop"
                        MinVersion="10.0.17763.0"
                        MaxVersionTested="10.0.22621.0" />
    <!-- Declare the VC++ runtime framework dependency -->
    <PackageDependency Name="Microsoft.VCLibs.140.00"
                       MinVersion="14.0.0.0"
                       Publisher="CN=Microsoft Corporation, ..." />
  </Dependencies>
  <Applications>
    <Application Id="MyApp" Executable="MyApp.exe"
                 EntryPoint="Windows.FullTrustApplication">
      <uap:VisualElements DisplayName="My App"
                          Description="My desktop app"
                          BackgroundColor="transparent"
                          Square150x150Logo="assets\Logo.png"
                          Square44x44Logo="assets\SmallLogo.png" />
    </Application>
  </Applications>
</Package>
Visual Studio 2019 and later include the Windows Application Packaging Project (.wapproj) to generate MSIX packages directly from your solution. Right-click your solution → AddNew Project → search “Windows Application Packaging Project”.

Application Manifests

An application manifest is an XML file (embedded in the binary or placed alongside it as MyApp.exe.manifest) that tells Windows about your application’s requirements: requested execution level, DPI awareness, Common Controls version, and compatibility GUIDs.
<!-- app.manifest -->
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
          xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <assemblyIdentity
    name="Contoso.MyApp"
    processorArchitecture="amd64"
    version="1.0.0.0"
    type="win32"/>

  <!-- Use Common Controls 6.0 (visual styles) -->
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="*"
        publicKeyToken="6595b64144ccf1df"
        language="*"/>
    </dependentAssembly>
  </dependency>

  <!-- DPI awareness: Per-Monitor V2 (recommended for modern HiDPI) -->
  <asmv3:application>
    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
        true/PM
      </dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
        PerMonitorV2, PerMonitor
      </dpiAwareness>
    </asmv3:windowsSettings>
  </asmv3:application>

  <!-- Compatibility GUIDs: declare OS versions you've tested on -->
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/><!-- Win10/11 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/><!-- Win8.1 -->
    </application>
  </compatibility>

  <!-- Execution level: asInvoker runs without elevation -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

DLL Deployment and Side-by-Side Assemblies

When deploying DLLs locally, place them in the same directory as the executable. Windows searches for DLLs in the application directory before looking in System32.
MyApp\
├── MyApp.exe
├── MyApp.exe.manifest
├── msvcp140.dll          ← VC++ runtime (local deployment)
├── vcruntime140.dll      ← VC++ runtime
├── vcruntime140_1.dll    ← Dot library (VS 2017.6+)
├── ucrtbase.dll          ← Universal CRT (if targeting Win7/8.1)
└── MyHelper.dll          ← Your own DLL
Side-by-side assemblies allow multiple versions of the same DLL to coexist on a machine, each application loading the specific version it was built against. SxS is used by the Visual C++ Redistributable itself.
<!-- MyHelper.dll.manifest — declares MyHelper as an SxS assembly -->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    name="Contoso.MyHelper"
    version="2.0.0.0"
    processorArchitecture="amd64"
    type="win32" />
  <file name="MyHelper.dll" />
</assembly>
<!-- MyApp.exe.manifest — references the specific version of MyHelper -->
<dependency>
  <dependentAssembly>
    <assemblyIdentity
      name="Contoso.MyHelper"
      version="2.0.0.0"
      processorArchitecture="amd64"
      type="win32" />
  </dependentAssembly>
</dependency>

Windows Runtime (WinRT) and C++/WinRT

For modern Windows applications targeting Windows 10/11 APIs, use C++/WinRT — a standard C++17 projection of the Windows Runtime. C++/WinRT is header-only and ships with the Windows SDK.
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Storage.Streams.h>

using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Storage;

IAsyncAction ReadFileAsync(hstring filePath) {
    StorageFile file = co_await StorageFile::GetFileFromPathAsync(filePath);
    hstring content = co_await FileIO::ReadTextAsync(file);
    wprintf(L"File contents: %s\n", content.c_str());
}

int main() {
    winrt::init_apartment();  // Initialize WinRT apartment
    ReadFileAsync(L"C:\\Users\\Public\\test.txt").get();
    return 0;
}
Enable C++/WinRT in your MSVC project by installing the C++/WinRT NuGet package or Visual Studio extension, then set C++ Language Standard to C++17 or later. The /await compiler flag enables coroutine support for co_await.

Build docs developers (and LLMs) love