Microsoft windows based applications

Build desktop apps for Windows PCs

This article provides the info you need to get started building desktop apps for Windows or updating existing desktop apps to adopt the latest experiences in Windows 10.

Platforms for desktop apps

There are four main platforms for building desktop apps for Windows PCs. Each platform provides an app model that defines the lifecycle of the app, a complete UI framework and set of UI controls that let you create desktop apps like Word, Excel, and Photoshop, and access to a comprehensive set of managed or native APIs for using Windows features.

For an in-depth comparison of these platforms along with additional resources for each platform, see Choose your app platform.

The leading-edge platform for Windows 10 apps and games. You can build UWP apps that exclusively use UWP controls and APIs, or you can use UWP controls and APIs in desktop apps that are built using one of the other platforms.

The platform of choice for native Windows apps that require direct access to Windows and hardware.

The established .NET-based platform for graphically-rich managed Windows apps with a XAML UI model. These apps can target .NET Core 3 or the full .NET Framework.

A .NET-based platform that is designed for managed line-of-business apps with a lightweight UI model. These apps can target .NET Core 3 or the full .NET Framework.

Future roadmap

Looking forward, we are evolving the Windows app development platforms with the Windows UI Library (WinUI) and Project Reunion.

WinUI is a native user experience (UX) framework for Windows 10 apps. WinUI started as a toolkit that provides new and updated versions of WinRT controls for UWP apps that target down-level versions of Windows 10. As of WinUI 3, WinUI is growing in scope to become the premier native user interface (UI) framework for Windows 10 apps across UWP, .NET, and Win32 app platforms.

Project Reunion is the code name for a broad set of new developer components and tools that represents the next evolution in the Windows app development platform. Project Reunion provides a unified set of APIs and tools that can be used in a consistent way by any app on a broad set of target Windows 10 OS versions. Project Reunion complements existing Windows app platforms and frameworks such as UWP and native Win32, and .NET with a common set of APIs and tools that developers can rely on across these platforms.

For more information, see Project Reunion.

Update existing desktop apps for Windows 10

If you have an existing WPF, Windows Forms, or native Win32 desktop app, Windows 10 and the Universal Windows Platform (UWP) offer many features you can use to deliver a modern experience in your app. Most of these features are available as modular components that you can adopt in your app at your own pace without having to rewrite your app for a different platform.

Here are just a few of the features available to enhance your existing desktop apps:

  • Use MSIX to package and deploy your desktop apps. MSIX is a modern Windows app package format that provides a universal packaging experience for all Windows apps. MSIX brings together the best aspects of MSI, .appx, App-V and ClickOnce installation technologies and is built to be safe, secure, and reliable.
  • Integrate your desktop app with Windows 10 experiences by using package extensions. For example, point Start tiles to your app, make your app a share target, or send toast notifications from your app.
  • Use XAML Islands to host UWP XAML controls in your desktop app. Many of the latest Windows 10 UI features are only available to UWP XAML controls.

For more information, see these articles.

Platform Description Docs and resources
Universal Windows Platform (UWP)
Article Description
Modernize desktop apps Describes the latest Windows 10 and UWP development features you can use in any desktop app, including WPF, Windows Forms, and C++ Win32 apps.
Tutorial: Modernize a WPF app Follow step-by-step instructions to modernize an existing WPF line-of-business sample app by adding UWP Ink and calendar controls to the app and packaging it in an MSIX package.

Create new desktop apps

If you are creating a new desktop app for Windows, here are some resources to help get you started.

Примеры приложений для Windows Get Windows app samples

Многие официальные примеры кода Windows доступны в различных репозиториях GitHub, включая примеры приложений универсальной платформы Windows (UWP), примеры классических приложений для Windows и коллекцию примеров, рассматриваемых в документации для разработчиков Windows. Many official Windows code samples are available in various GitHub repositories, including Universal Windows Platform (UWP) app samples, Windows classic samples, along with a collection of Windows developer documentation samples. В этих примерах демонстрируется, как применяются большинство функций Windows и их API. These samples demonstrate most Windows features and their API use patterns.

Чтобы немного упростить поиск конкретных примеров, используйте упорядоченную коллекцию, доступную в обозревателе примеров кода. В ней вы сможете просмотреть и найти различные технологии и средства для разработчиков Майкрософт. To make finding specific samples a little bit easier, you can browse and search a categorized collection of code samples for various Microsoft developer tools and technologies through the sample browser.

Примеры, рассматриваемые в документации для разработчиков Windows Windows developer documentation samples

Ниже приведен список примеров мини-приложений, созданных специально для поддержки документации для разработчиков Windows. Here’s a list of mini-app samples created specifically to support Windows developer documentation. Если не указано иное, все следующие примеры представляют собой приложения UWP, которые обновлены для использования элементов управления последней версии WinUI 2.4. Unless noted, the following samples are all Universal Windows Platform (UWP) apps that have been updated to use the latest WinUI 2.4 controls.

  • RSS Reader — получение сведений о RSS-каналах и просмотр статей. Rss Reader — Retrieve RSS feeds and view articles
  • Family Notes — изучение различных модальностей ввода и сценариев узнавания пользователей. Family Notes — Explore different input modalities and scenarios of user awareness
  • Customer Orders — демонстрация функций, полезных для корпоративных разработчиков, например аутентификации Azure Active Directory (AAD), элементов управления пользовательского интерфейса (включая сетку данных), интеграция Sqlite и Базы данных SQL Azure, Entity Framework и облачные службы API. Customer Orders — Features useful to enterprise developers, like Azure Active Directory (AAD) authentication, UI controls (including a data grid), Sqlite and SQL Azure database integration, Entity Framework, and cloud API services
  • Lunch Scheduler — планирование обедов с друзьями и коллегами. Lunch Scheduler — Schedule lunches with your friends and coworkers
  • Coloring Book — демонстрация работы Windows Ink (в том числе панели инструментов Windows Ink) и функций радиального контроллера (для устройств Wheel, например Surface Dial). Coloring Book — Windows Ink (including the Windows Ink Toolbar) and radial controller (for Wheel devices such as the Surface Dial) features
  • Network Helper (Quiz Game) — обнаружение сетей и реализация обмена данными. Network Helper (Quiz Game) — Network discovery and communication
  • HUE Lights Controller — интеллектуальная система домашней автоматики с использованием Кортаны и технологии Bluetooth Low Energy (Bluetooth LE). HUE Lights Controller — Intelligent home automation with Cortana and Bluetooth Low Energy (Bluetooth LE)
  • Marble Maze — простая трехмерная игра с использованием DirectX. Marble Maze — Basic 3D game using DirectX
  • PhotoLab — просмотр и изменение файлов изображений. PhotoLab — View and edit image files

Скачать код Download the code

Чтобы скачать примеры, перейдите в один из репозиториев Майкрософт, например репозиторий с примерами приложений универсальной платформы Windows (UWP). To download the samples, go to one of the Microsoft repos such as Universal Windows Platform (UWP) app samples. Выберите Clone or download (Клонировать или скачать), а затем — Download ZIP (Скачать ZIP-файл). Select Clone or download, and then select Download ZIP.

В ZIP-файле для скачивания всегда содержатся последние версии примеров. The samples download .zip file always has the latest samples. Для скачивания файла не требуется учетная запись GitHub. You don’t need a GitHub account to download the file. Если выпущено обновление SDK или необходимо получить только последние изменения и добавления, просто скачайте актуальный ZIP-файл. When an SDK update is released or if you want to pick up any recent changes and additions, just download the latest zip file.

Для открытия, создания и запуска примеров Windows требуется Visual Studio и пакет Windows SDK. To open, build, and run Windows samples, you must have Visual Studio and the Windows SDK. Вы можете получить бесплатную копию Visual Studio Community. You can get a free copy of Visual Studio Community.

Для правильной работы примеров нужно распаковать весь архив, а не только отдельные примеры. For the samples to work correctly, be sure to unzip the entire archive and not individual samples. Большинство примеров зависят от общих файлов из папки SharedContent и используют связанные файлы, включая файлы шаблонов примеров и ресурсы изображений, чтобы уменьшить дублирование общих файлов. Many of the samples depend on common files in the SharedContent folder and use linked files, including sample template files and image assets, to reduce duplication.

Открытие примеров Open the samples

Скачайте ZIP-файл и откройте примеры в Visual Studio. After you download the .zip file, open the samples in Visual Studio.

Прежде чем распаковывать архив, щелкните файл правой кнопкой мыши и выберите Свойства > Разблокировать > Применить. Before you unzip the archive, right-click the file, select Properties > Unblock > Apply. Затем распакуйте архив в локальную папку на компьютере. Then, unzip the archive in a local folder on your computer.

Каждая папка в папке Samples содержит пример функции Windows. Each folder in the Samples folder contains a Windows feature sample.

Выберите пример. Select a sample. Поддерживаемые языки обозначаются вложенной папкой для конкретного языка. Supported languages are indicated by a language-specific sub-folder.

Выберите папку для языка, который нужно использовать. Select the folder for the language you want to use. В содержимом папки вы увидите файл решения Visual Studio (с расширением .sln), который можно открыть в Visual Studio. In the folder contents, you’ll see a Visual Studio solution (.sln) file that you can open in Visual Studio.

Обратная связь, вопросы и сообщения о проблемах Give feedback, ask questions, and report issues

Если у вас возникают проблемы или вопросы, перейдите на вкладку Issues (Проблемы) репозитория, чтобы создать запрос. If you have problems or questions, use the Issues tab in the repository to create a new issue.

Choose your Windows app platform

When you want to create a new desktop application for Windows PCs, the first decision you make is which application platform to use. Windows provides four main application platforms, each with different strengths:

  • Universal Windows Platform (UWP): This platform provides a common type system, APIs, and application model for all devices that run Windows 10. UWP applications can be native or managed.
  • WPF and Windows Forms: These .NET-based platforms provide a common type system, APIs, and application model for managed applications.
  • Win32: This is the original platform for native C/C++ Windows applications that require direct access to Windows and hardware. This makes the Win32 API the platform of choice for applications that need the highest level of performance and direct access to system hardware.

Each of these platforms include a complete UI framework and set of UI controls that let you create desktop apps like Word, Excel, and Photoshop that run in the classic Windows desktop and take full advantage of that environment’s specific features. On Windows 10, each of these platforms also support using the Windows UI Library (WinUI) to create their user interfaces.

Some of these platforms share certain traits and are better suited for specific application types. For example, both UWP and .NET have deep integration with Visual Studio. This provides many benefits, especially in the areas of developer productivity, sophisticated and customizable UI, and application security. Because these frameworks support visual designers and UI markup for rapidly creating UI, they are particularly well-suited for line-of-business applications.

No matter which app platform you choose, you can use many Windows 10 features to deliver a modern experience in your app. For example, even if your desktop app is built using WPF, Windows Forms, or the Win32 API, you can still use MSIX package deployment. For more information about all the ways to modernize your desktop apps, see Modernize your desktop apps.

UWP is the leading-edge platform for Windows 10 applications and games. It’s a highly customizable platform that uses XAML markup to separate UI (presentation) from code (business logic). UWP is suitable for desktop applications that require a sophisticated UI, styles customization, and graphics-intensive scenarios. UWP also has built-in support for the Fluent Design System for the default UX experience and provides access to the Windows Runtime (WinRT) APIs. By adopting Fluent, UWP automatically supports common input methods such as ink, touch, gamepad, keyboard, and mouse.

Not only can you use UWP to create desktop applications for Windows PCs, but UWP is also the only supported platform for Xbox, HoloLens, and Surface Hub applications. UWP is our newest, leading-edge application platform.

For more information about UWP, see the following articles:

WPF is the established platform for managed Windows applications with access to .NET Core or the full .NET Framework, and it also uses XAML markup to separate UI from code. This platform is designed for desktop applications that require a sophisticated UI, styles customization, and graphics-intensive scenarios. WPF development skills are similar to UWP development skills, so migration from WPF to UWP apps is easier than migration from Windows Forms.

For more information about WPF, see the following articles:

Windows Forms

Windows Forms is the original platform for managed Windows applications with a lightweight UI model and access to .NET Core or the full .NET Framework. It excels at enabling developers to quickly get started building applications, even for developers new to the platform. This is a forms-based, rapid application development platform with a large built-in collection of visual and non-visual drag-and-drop controls. Windows Forms does not use XAML, so deciding later to extend your application to UWP entails a complete re-write of your UI.

For more information about Windows Forms, see the following articles:

Win32

Using the Win32 API with C++ makes it possible to achieve the highest levels of performance and efficiency by taking more control of the target platform with unmanaged code than is possible on a managed runtime environment like WinRT and .NET. However, exercising such a level of control over your application’s execution requires greater care and attention to get right, and trades development productivity for runtime performance.

Here are a few highlights of what the Win32 API and C++ offers to enable you to build high-performance applications.

  • Hardware-level optimizations, including tight control over resource allocation, object lifetimes, data layout, alignment, byte packing, and more.
  • Access to performance-oriented instruction sets like SSE and AVX through intrinsic functions.
  • Efficient, type-safe generic programming by using templates.
  • Efficient and safe containers and algorithms.
  • DirectX, in particular Direct3D and DirectCompute (note that UWP also offers DirectX interop).

For more information, see the following articles:

Platform comparison: UWP, WPF, and Windows Forms

The following table compares various characteristics of Windows Forms, WPF, and UWP in detail.

Feature or scenario UWP WPF Windows Forms
Supported versions Windows 10 Windows 7 and later Windows 7 and later
Languages C#, C++/WinRT, C++/CX, VB, JavaScript C#, C++/CLI (Managed Extensions for C++), F#, VB C#, C++/CLI (Managed Extensions for C++), F#, VB
UI runtime Native (C++/WinRT and C++/CX) and managed (.NET Native) Managed (.NET Framework and .NET Core 3) Managed (.NET Framework and .NET Core 3)
Open source Yes (Windows UI Library only) Yes (.NET Core only) Yes (.NET Core only)
Supports XAML Yes Yes No
Strengths
  • XAML markup for UI
  • Rich and customizable UX
  • Your existing code bases are .NET Standard compliant
  • High DPI support
  • Support for multiple input types across Windows devices (including touch, pen, gamepad, mouse, and keyboard)
  • Support for Xbox, HoloLens, IoT or Surface Hub
  • Optional dense (compact) UI
  • Support for native C++
  • Optimized battery life
  • Modern accessibility support (such as screen readers)
  • Rich text data capabilities (such as built-in spell check)
  • Inking support
  • Secure execution via application containers (for example, untrusted content is sandboxed)
  • XAML markup for UI
  • Rich and customizable UX
  • Large collection of controls from Microsoft and partners
  • Dense UI
  • Support for Windows 7
  • Platform support for input validation
  • Rapid application development
  • WYSIWYG editor for building UI
  • Large collection of controls from Microsoft and partners
  • Dense UI
  • Support for Windows 7
  • Keyboard and mouse input
Scenarios that have limited support
  • Multiple window support 1
  • Platform support for input validation 1
  • Windows 7 is not supported
  • Some Windows Runtime APIs require specific minimum versions of Windows 10
  • Full platform support and shell integration (for example, UWP currently doesn’t support System Tray integration or full access to all devices)
  • Direct access to all files on disk
  • ADO.NET
  • Existing code-base class libraries that use non-.NET Standard or non-Windows App Certification Kit compliant APIs
  • Local network loopback support (that is, if your app needs to communicate with localhost without creating a loopback exemption on the target device)
  • Intensive file I/O
  • High DPI support 2
  • Touch input 2
  • High DPI support 2
  • Touch input 2
  • Customizable UI
  • Rich graphics and user experiences (such as touch and animations)
  • Rich abstraction of views and data models

1 We have publicly announced features that will address this scenario in a future release of Windows 10.

2 Although the platform lacks first-class API support for this scenario, developers can support this scenario with workarounds.

Use the Windows UI Library with Windows apps

To supplement the main Windows app platforms, you can also use the Windows UI Library (WinUI) in your apps. WinUI started as a toolkit that provides new and updated versions of WinRT controls for UWP apps that target down-level versions of Windows 10. As of WinUI 3, WinUI is growing in scope to become the premier native user interface (UI) framework for Windows 10 apps across UWP, .NET, and Win32 app platforms.

You can use WinUI in the following ways in Windows apps.

  • UWP apps can use WinUI 2.x controls in place of WinRT controls provided by the Windows SDK. These releases of WinUI include both all-new controls and updated versions of existing controls from the Windows SDK.
  • You can update existing WPF, Windows Forms, and C++/Win32 apps to host WinUI 2.x controls by using XAML Islands.
  • Starting with WinUI 3, you can create .NET and C++/Win32 apps and UWP apps that use an entirely WinUI-based UI. This release includes Visual Studio project templates that provide everything you need to create these apps.

Other app platforms

Progressive Web Apps (PWAs)

PWAs let developers package their website code so it can be installed and run like an application on Windows 10 PCs. For more information, see Progressive Web Apps.

Xamarin

Use Xamarin to build cross-platform applications for Windows 10 that can also run on iOS and Android. For more information, see Xamarin.

Читайте также:  Выберите параметры конфиденциальности для этого устройства windows 10 что делать
Оцените статью