通用 Windows 应用 (C++)Universal Windows Apps (C++)

通用 Windows 平台(UWP)是适用于 Windows 的新式编程接口。The Universal Windows Platform (UWP) is the modern programming interface for Windows. 使用 UWP,你只需要编写一次应用程序或组件,然后将其部署到任何 Windows 10 设备上。With UWP you write an application or component once and deploy it on any Windows 10 device. 你可以在中C++编写一个组件,并且用任何其他 UWP 兼容的语言编写的应用程序都可以使用该组件。You can write a component in C++ and applications written in any other UWP-compatible language can use it.

大多数 UWP 文档都位于通用 Windows 平台文档的 Windows 内容树中。Most of the UWP documentation is in the Windows content tree at Universal Windows Platform documentation. 可在其中找到开始教程和参考文档。There you will find beginning tutorials as well as reference documentation.

对于新的 UWP 应用和组件,我们建议使用 C++/WinRT,这是一个新的标准 c + + 17 语言投影,适用于 Windows 运行时 api。For new UWP apps and components, we recommend that you use C++/WinRT, a new standard C++17 language projection for Windows Runtime APIs. C++/WinRT 从版本1803开始,在 Windows 10 SDK 中提供。C++/WinRT is available in the Windows 10 SDK from version 1803 onward. C++/WinRT 完全在标头文件中实现,旨在向您提供对新式 Windows API 的第一类访问。C++/WinRT is implemented entirely in header files, and is designed to provide you with first-class access to the modern Windows API. 与C++/cx 实现不同。Unlike the C++/CX implementation. C++/WinRT 不使用非标准语法或 Microsoft 语言扩展,它充分利用C++编译器来创建高度优化的输出。C++/WinRT doesn't use non-standard syntax or Microsoft language extensions, and it takes full advantage of the C++ compiler to create highly-optimized output. 有关详细信息,请参阅 C++/WinRT 简介For more information, see Introduction to C++/WinRT.

可以使用桌面桥应用转换器打包现有的桌面应用程序,以便通过 Microsoft Store 进行部署。You can use the Desktop Bridge app converter to package your existing desktop application for deployment through the Microsoft Store. 有关详细信息,请参阅 Using Visual C++ Runtime in Centennial project (在 Centennial 项目中使用 VC 运行时)和 Bring your desktop app to the Universal Windows Platform (UWP) with the Desktop Bridge(使用桌面桥将桌面应用引入通用 Windows 平台 (UWP))。For more information, see Using Visual C++ Runtime in Centennial project and Desktop Bridge.

使用C++/CX 的 UWP 应用UWP apps that use C++/CX

C++/CX 语言参考C++/CX language reference 描述一组扩展,这些扩展C++可简化 Windows 运行时 api 的消耗,并启用基于异常的错误处理。Describes the set of extensions that simplify C++ consumption of Windows Runtime APIs and enable error handling that's based on exceptions.
生成应用程序和库 (C++/CX)Building apps and libraries (C++/CX) 描述如何创建可从 C++/CX 应用或组件进行访问的 Dll 和静态库。Describes how to create DLLs and static libraries that can be accessed from a C++/CX app or component.
教程:在/Cx 中C++创建 UWP "Hello,World" 应用Tutorial: Create a UWP "Hello, World" app in C++/CX 本演练介绍了/Cx 中C++UWP 应用开发的基本概念A walkthrough that introduces the basic concepts of UWP app development in C++/CX.
在/Cx 中C++创建 Windows 运行时组件Creating Windows Runtime Components in C++/CX 介绍如何创建其他 UWP 应用和组件可以使用的 Dll。Describes how to create DLLs that other UWP apps and components can consume.
UWP 游戏编程UWP game programming 介绍如何使用 DirectX 和C++/cx 创建游戏。Describes how to use DirectX and C++/CX to create games.

使用 Windows 运行时C++模板库(WRL)的 UWP 应用UWP Apps that Use the Windows Runtime C++ Template Library (WRL)

Windows 运行时 C++ 模板库提供低级别的 COM 接口,让 ISO C++ 代码可以在无异常的环境中访问 Windows 运行时。The Windows Runtime C++ Template Library provides the low-level COM interfaces by which ISO C++ code can access the Windows Runtime in an exception-free environment. 在大多数情况下,建议使用 C++/CX 而不是Windows 运行时 C++ 模板库来开发通用 Windows 平台应用程序。In most cases, we recommend that you use C++/WinRT or C++/CX instead of the Windows Runtime C++ Template Library for UWP app development. 有关 Windows 运行时 C++ 模板库的信息,请参阅 Windows 运行时 C++ 模板库 (WRL)For information about the Windows Runtime C++ Template Library, see Windows Runtime C++ Template Library (WRL).

请参阅See also

Visual Studio 中的 C++C++ in Visual Studio
C++ 中 Windows 编程概述Overview of Windows Programming in C++