桌面应用程序中的 UWP 限制 [英] UWP limitations in desktop apps

查看:48
本文介绍了桌面应用程序中的 UWP 限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道与传统"Win32 应用程序相比,新的 UWP 应用程序模型有一些限制.

I know that the new UWP app model has some limitations when comparing to "traditional" Win32 apps.

让我们以 Visual Studio Code 作为桌面应用示例.

Let's take Visual Studio Code as an example of a desktop app.

如果是 UWP 应用,Visual Studio Code 的哪些功能缺失或必须与用户不同?

我已经完成了微软认证使用 C# 开发 Windows 商店应用程序的要点"和考试 70-355:通用 Windows 平台 - 应用程序数据、服务和编码模式的考试.所以我对win rt api有所了解.

I've done exams for microsoft certification "Essentials of Developing Windows Store Apps Using C#" and Exam 70-355: Universal Windows Platform – App Data, Services, and Coding Patterns. So I know something about win rt api.

请不要为诸如uwp 应用程序在沙盒中运行"之类的答案而烦恼.它们是无用的,因为它们从用户的角度没有提及限制.我特意拿了现实生活的例子,所以我们可以具体一些.

Please don't bother with answers like "uwp app runs in sandbox". They are useless, because they say nothing about the limitations from users' perspective. I intentionally took real life example, so we can go concrete.

限制可能是,您的应用程序无法支持 3rd 方插件,例如自定义语法高亮器或重构扩展程序(这是 Windows 商店应用程序的限制,不确定它是否仍然有效).

The limitation could be, that your app cannot support 3rd party plugins like custom syntax highlighter or refactorin extension(it was limitation of windows store apps, not sure if its still valid).

另一个限制可能是,您的应用无法截屏,因为 uwp 中没有用于它的 api(实际上不确定它是否正确)

Another limitation could be, that your app is not able to take screenshot, because there is no api in uwp for it (not sure it its true, actually)

推荐答案

短语Win32 桌面应用程序"由于 Win32 API 编程模型自 Windows NT 3.1 以来就已存在,因此定义不明确.它还可以涵盖过去 20 年间的数十种开发语言和 UI 框架.

The phrase "Win32 desktop app" is a ill-defined since the Win32 API programming model has been around since Windows NT 3.1. It can also cover dozens of development languages and UI frameworks over the intervening two decades.

以下是 UWP 主要差异的快速概览:

Here's a quick overview of the key UWP differences:

  • API 表面区域.UWP 平台支持许多但不是全部的 Win32 和 COM API,并引入了新的 API.如果您的Win32 桌面应用程序"主要使用可追溯到 Windows 95 的 ANSI API,那么您有很多更新要做.如果您主要使用 Windows Vista 时代的 UNICODE API,那么很多东西都可以".请参阅 Win32 和 COM适用于 Windows 运行时应用(系统)的 API.

  • API surface area. The UWP platform supports many but not all Win32 and COM APIs, and introduces new APIs. If your "Win32 desktop app" is using mostly ANSI APIs that date back to Windows 95, then you have a lot of updating to do. If you are using mostly Windows Vista era UNICODE APIs, then a lot of stuff "just works". See Win32 and COM API for Windows Runtime apps (System).

安全上下文. UWP 平台在 AppContainer 安全上下文中运行应用程序.Win32 桌面应用程序"在 Windows Vista 或更高版本上以标准用户"身份运行或作为管理员".UWP 应用的访问权限比标准用户"少并且永远不能以管理员"身份运行.UWP 应用可以请求额外的能力以获得获得用户许可的更多权限,但对系统和用户数据的访问权限有限.例如,您无法读取大部分文件系统,只能读取您的安装位置、隔离的应用程序数据文件夹和隔离的临时文件夹.请参阅文件访问和权限(Windows 运行时应用).这也意味着 UWP 应用对设备的访问受到限制.请参阅设备和传感器概述.

Security context. The UWP platform runs applications in an AppContainer security context. "Win32 desktop apps" on Windows Vista or later run as "Standard User" or as "Administrator". UWP apps have less access rights than "Standard User" and can never run as "Administrator". UWP apps can request additional capabilities to get a few more rights with permission from the user, but have limited access to the system and user data. For example, you cannot read most of the filesystem, only your installed location, an isolated application data folder, and an isolated temporary file folder. See File access and permissions (Windows Runtime apps). This also means UWP apps have limited access to devices. See Device and sensor overviews.

与旧的一切都是管理员"相比,引入标准用户的 Windows Vista 用户帐户控制侧重于保护系统和其他用户数据.模型,但几乎没有保护当前用户的数据文件,因为所有应用程序都可以访问甚至修改它.AppContainer 隔离同时保护系统和当前用户的数据和设置.Win32 桌面应用程序"鼓励安装到 C:\Program Files,它在运行时是只读的,并使用应用程序数据文件夹,但它们不是必需的.

Windows Vista User Account Control that introduced Standard User was focused on protecting the system and other users data compared to the older "everything is administrator" model, but did little to protect the current user's data files since all apps could access or even modify it. AppContainer isolation is protecting both the system and the current user's data and settings. "Win32 desktop apps" were encouraged to install to C:\Program Files which was read-only at runtime and to use application data folders, but they were not required to.

  • 通过 AppX 部署.Win32 桌面应用程序"使用多种部署方式,通常使用 MSI 技术并以管理员"身份运行.UWP 应用程序打包在 AppX 文件中,并且始终由系统部署.没有自定义安装步骤",因此 UWP 应用无法安装驱动程序或服务、更改 ACL 等.系统负责部署 C/C++ 运行时(必须是 Visual C++ 2015 或更高版本).

    • Deployment via AppX. "Win32 desktop apps" use any number of ways of deployment, often something using MSI technology and running as "Administrator". UWP apps are packaged in AppX files and are always deployed by the system. There is no "Custom Install Step", and therefore UWP apps cannot install drivers or services, change ACLs, etc. The system takes care of deploying the C/C++ Runtime (which must be Visual C++ 2015 or later).

      接口模型.有大量用于Win32 桌面应用程序"的界面框架.如 WinForms、MFC、WPF 等.其中绝大多数与 UWP 不兼容,因为 UWP 不支持经典的 Win32 窗口、WM_ 消息或 GDI/GDI+.对于 UWP 应用,您可以将 XAML 与 C++ 或 C# 代码隐藏、DirectX(Direct2D 和/或 Direct3D)与 C++(或通过 SharpDX 等第 3 方程序集的 C#)或 HTML5 与 JavaScript 结合使用.

      Interface model. There is a plethora of interface frameworks for "Win32 desktop apps" like WinForms, MFC, WPF, etc. The vast majority of these are not compatible with UWP because UWP does not support classic Win32 windowing, WM_ messages, or GDI/GDI+. For UWP apps, you can use XAML with C++ or C# code-behind, DirectX (Direct2D and/or Direct3D) with C++ (or C# via 3rd party assemblies like SharpDX), or HTML5 with JavaScript.

      通过 MSIX 部署.

      因此,如果不完全了解产品的代码库和依赖项,回答您的问题是极其困难的,甚至是不可能的.

      Answering your question is therefore extremely difficult, if not impossible, without a complete understanding of the product's code base and dependencies.

      请参阅开始使用 Windows 应用

      这篇关于桌面应用程序中的 UWP 限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆