使用打包扩展将桌面应用与 Windows 集成

如果桌面应用已打包(在运行时具有程序包标识符),则可以通过程序包清单中的预定义扩展,使用扩展将应用与 Windows 进行集成。 另请参阅需要程序包标识符的功能

例如,使用扩展创建一个防火墙例外;使应用成为某一文件类型的默认应用程序;或将“开始”磁贴指向你的应用。 若要使用扩展,只需将某些 XML 添加到应用的程序包清单文件。 不需要任何代码。

本主题介绍这些扩展以及使用它们可执行的任务。

注意

本主题中所述的功能要求将应用打包(在运行时具有程序包标识符)。 这包括打包的应用(请参阅为打包的 WinUI 3 桌面应用创建新项目)和使用外部位置打包的应用(请参阅通过使用外部位置进行打包来授予程序包标识符)。 另请参阅需要程序包标识符的功能

将用户切换到应用

帮助用户切换到打包后的应用。

将现有桌面应用重定向到打包的应用

当用户启动现有未打包桌面应用时,可以将打包的应用配置为打开。

注意

Windows Insider Preview 版本 21313 及更高版本支持此功能。

若要启用此行为:

  1. 添加注册表项以将未打包桌面应用可执行文件重定向到打包的应用。
  2. 注册在启动未打包桌面应用可执行文件时要启动的打包的应用。

添加注册表项以重定向未打包桌面应用可执行文件

  1. 在注册表中,在 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options 键下使用桌面应用可执行文件的名称创建一个子项。
  2. 在此子项下,添加以下值:
    • AppExecutionAliasRedirect (DWORD):如果设置为 1,系统将检查与可执行文件同名的 AppExecutionAlias 包扩展。 如果已启用 AppExecutionAlias 扩展,则将使用该值激活打包的应用。
    • AppExecutionAliasRedirectPackages (REG_SZ):系统将仅重定向到列出的包。 包按其包系列名称列出,并用分号隔开。 如果使用了特殊值 *,系统将从任何包重定向到 AppExecutionAlias。

例如:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\contosoapp.exe 
    AppExecutionAliasRedirect = 1
    AppExecutionAliasRedirectPackages = "Microsoft.WindowsNotepad_8weky8webbe" 

注册要启动的打包应用

在程序包清单中,添加 AppExecutionAlias 扩展,用于注册未打包桌面应用可执行文件的名称。 例如:

<Package
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  IgnorableNamespaces="uap3">
  <Applications>
    <Application>
      <Extensions>
        <uap3:Extension Category="windows.appExecutionAlias" EntryPoint="Windows.FullTrustApplication">
          <uap3:AppExecutionAlias>
            <desktop:ExecutionAlias Alias="contosoapp.exe" />
          </uap3:AppExecutionAlias>
        </uap3:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

禁用重定向

用户可以通过以下选项关闭重定向并启动未打包应用可执行文件:

  • 他们可以卸载应用的打包版本。
  • 用户可以在“设置”中的“应用执行别名”页上禁用打包应用的 AppExecutionAlias 条目。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3
  • http://schemas.microsoft.com/appx/manifest/desktop/windows10

该扩展的元素和特性

<uap3:Extension
    Category="windows.appExecutionAlias"
    EntryPoint="Windows.FullTrustApplication">
    <uap3:AppExecutionAlias>
        <desktop:ExecutionAlias Alias="[AliasName]" />
    </uap3:AppExecutionAlias>
</uap3:Extension>
名称 说明
类别 总是为 windows.appExecutionAlias
可执行文件 调用别名时要启动的可执行文件的相对路径。
Alias 应用的简称。 它必须始终以“.exe”扩展名结尾。

将现有“开始”磁贴和任务栏按钮指向打包后的应用

用户可能已将桌面应用程序固定到任务栏或“开始”菜单。 可将这些快捷方式指向打包后的新应用。

XML 命名空间

http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3

该扩展的元素和特性

<Extension Category="windows.desktopAppMigration">
    <DesktopAppMigration>
        <DesktopApp AumId="[your_app_aumid]" />
        <DesktopApp ShortcutPath="[path]" />
    </DesktopAppMigration>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 始终为 windows.desktopAppMigration
AumID 打包后的应用的应用程序用户模型 ID。
ShortcutPath 启动桌面版应用的 .lnk 文件的路径。

示例

<Package
  xmlns:rescap3="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3"
  IgnorableNamespaces="rescap3">
  <Applications>
    <Application>
      <Extensions>
        <rescap3:Extension Category="windows.desktopAppMigration">
          <rescap3:DesktopAppMigration>
            <rescap3:DesktopApp AumId="[your_app_aumid]" />
            <rescap3:DesktopApp ShortcutPath="%USERPROFILE%\Desktop\[my_app].lnk" />
            <rescap3:DesktopApp ShortcutPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\[my_app].lnk" />
            <rescap3:DesktopApp ShortcutPath="%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\[my_app_folder]\[my_app].lnk"/>
         </rescap3:DesktopAppMigration>
        </rescap3:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使用转换/迁移/卸载的 WPF 图片查看器

使打包后的应用程序打开文件(而非桌面应用)

可确保用户默认对特定的文件类型打开新打包的应用程序,而不是打开桌面版应用。

为达到该目的,需指定每个要从中继承文件关联的应用程序的编程标识符 (ProgID)

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3
  • http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]">
         <MigrationProgIds>
            <MigrationProgId>"[ProgID]"</MigrationProgId>
        </MigrationProgIds>
    </FileTypeAssociation>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
MigrationProgId 编程标识符 (ProgID),描述要从中继承文件关联的应用程序、组件和桌面应用程序版本。

示例

<Package
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  xmlns:rescap3="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3"
  IgnorableNamespaces="uap3, rescap3">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap3:FileTypeAssociation Name="myfiletypes">
            <rescap3:MigrationProgIds>
              <rescap3:MigrationProgId>Foo.Bar.1</rescap3:MigrationProgId>
              <rescap3:MigrationProgId>Foo.Bar.2</rescap3:MigrationProgId>
            </rescap3:MigrationProgIds>
          </uap3:FileTypeAssociation>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使用转换/迁移/卸载的 WPF 图片查看器

将打包的应用程序与一组文件类型相关联

可将打包后的应用程序与文件类型扩展相关联。 如果用户在文件资源管理器中右键单击某个文件,然后选择“打开方式”选项,应用程序将出现在建议列表中。 有关使用此扩展的详细信息,请参阅 将打包的桌面应用与文件资源管理器集成

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]">
        <SupportedFileTypes>
            <FileType>"[file extension]"</FileType>
        </SupportedFileTypes>
    </FileTypeAssociation>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
FileType 应用支持的文件扩展名。

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  IgnorableNamespaces="uap, uap3">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap3:FileTypeAssociation Name="mediafiles">
            <uap:SupportedFileTypes>
            <uap:FileType>.avi</uap:FileType>
            </uap:SupportedFileTypes>
          </uap3:FileTypeAssociation>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使用转换/迁移/卸载的 WPF 图片查看器

向具有特定文件类型的文件的上下文菜单添加选项

通过此扩展,你可以在当用户在文件资源管理器中右键单击某个文件时显示的上下文菜单中添加选项。这些选项为用户提供了与文件进行交互的其他方式,如打印、编辑或预览文件。 有关使用此扩展的详细信息,请参阅 将打包的桌面应用与文件资源管理器集成

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/2
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]">
        <SupportedVerbs>
           <Verb Id="[ID]" Extended="[Extended]" Parameters="[parameters]">"[verb label]"</Verb>
        </SupportedVerbs>
    </FileTypeAssociation>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
Verb 文件资源管理器上下文菜单中显示的名称。 此字符串可使用 ms-resource 进行本地化。
ID 谓词的唯一 ID。 如果你的应用程序为 UWP 应用,则会将该谓词作为应用的激活事件参数的一部分向其传递,以便应用可以相应地处理用户的选择。 如果应用程序是完全信任的已打包应用,它将改为接收参数(请参阅下一项)。
参数 与谓词关联的实参参数和值的列表。 如果应用程序是完全信任的已打包应用,激活应用程序时会将这些参数作为事件参数传递给应用程序。 可以根据不同的激活谓词自定义应用程序的行为。 如果变量可包含文件路径,请用引号将参数值括起来。 这将避免路径包含空格的情况下出现的任何问题。 如果应用程序为 UWP 应用,则无法传递参数。 应用转而接收 ID(请参阅上一项)。
扩展 指定谓词仅在用户右键单击文件之前按住 Shift 键显示上下文菜单时才显示。 如果未列出该特性,则该特性可选,并且默认为值 False (例如,始终显示谓词)。 为每个动词命令逐个指定此行为(“打开”除外,它始终为 False)。

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"

  IgnorableNamespaces="uap, uap2, uap3">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap3:FileTypeAssociation Name="myfiletypes">
            <uap2:SupportedVerbs>
              <uap3:Verb Id="Edit" Parameters="/e &quot;%1&quot;">Edit</uap3:Verb>
              <uap3:Verb Id="Print" Extended="true" Parameters="/p &quot;%1&quot;">Print</uap3:Verb>
            </uap2:SupportedVerbs>
          </uap3:FileTypeAssociation>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使用转换/迁移/卸载的 WPF 图片查看器

直接使用 URL 打开某些类型的文件

可确保用户默认对特定的文件类型打开新打包的应用程序,而不是打开桌面版应用。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]" UseUrl="true" Parameters="%1">
        <SupportedFileTypes>
            <FileType>"[FileExtension]"</FileType>
        </SupportedFileTypes>
    </FileTypeAssociation>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
UseUrl 指示是否直接从 URL 目标打开文件。 如果未设置此值,应用程序尝试使用 URL 打开文件的操作将导致系统先在本地下载文件。
参数 可选参数。
FileType 相关的文件扩展名。

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  IgnorableNamespaces="uap, uap3">
  <Applications>
      <Application>
        <Extensions>
          <uap:Extension Category="windows.fileTypeAssociation">
            <uap3:FileTypeAssociation Name="myfiletypes" UseUrl="true" Parameters="%1">
              <uap:SupportedFileTypes>
                <uap:FileType>.txt</uap:FileType>
                <uap:FileType>.doc</uap:FileType>
              </uap:SupportedFileTypes>
            </uap3:FileTypeAssociation>
          </uap:Extension>
        </Extensions>
      </Application>
    </Applications>
</Package>

执行安装任务

为应用创建防火墙例外

如果应用程序需要通过端口进行通信,可向防火墙例外列表中添加应用程序。

注意

要使用“windows.firewallRules”扩展类别(请参见下方),包需要“完全信任权限级别”受限功能。 请参阅受限功能列表

XML 命名空间

http://schemas.microsoft.com/appx/manifest/desktop/windows10/2

该扩展的元素和特性

<Extension Category="windows.firewallRules">
  <FirewallRules Executable="[executable file name]">
    <Rule
      Direction="[Direction]"
      IPProtocol="[Protocol]"
      LocalPortMin="[LocalPortMin]"
      LocalPortMax="LocalPortMax"
      RemotePortMin="RemotePortMin"
      RemotePortMax="RemotePortMax"
      Profile="[Profile]"/>
  </FirewallRules>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 始终为 windows.firewallRules
可执行文件 要添加到防火墙例外列表的可执行文件名称
方向 指示规则是入站规则还是出站规则
IPProtocol 通信协议
LocalPortMin 本地端口号范围内较小的端口号。
LocalPortMax 本地端口号范围内最大的端口号。
RemotePortMax 远程端口号范围内较小的端口号。
RemotePortMax 远程端口号范围内最大的端口号。
配置文件 网络类型

示例

<Package
  xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
  IgnorableNamespaces="desktop2">
  <Extensions>
    <desktop2:Extension Category="windows.firewallRules">
      <desktop2:FirewallRules Executable="Contoso.exe">
          <desktop2:Rule Direction="in" IPProtocol="TCP" Profile="all"/>
          <desktop2:Rule Direction="in" IPProtocol="UDP" LocalPortMin="1337" LocalPortMax="1338" Profile="domain"/>
          <desktop2:Rule Direction="in" IPProtocol="UDP" LocalPortMin="1337" LocalPortMax="1338" Profile="public"/>
          <desktop2:Rule Direction="out" IPProtocol="UDP" LocalPortMin="1339" LocalPortMax="1340" RemotePortMin="15"
                         RemotePortMax="19" Profile="domainAndPrivate"/>
          <desktop2:Rule Direction="out" IPProtocol="GRE" Profile="private"/>
      </desktop2:FirewallRules>
  </desktop2:Extension>
</Extensions>
</Package>

将你的 DLL 文件放到程序包的任意文件夹中

使用 uap6:LoaderSearchPathOverride 扩展在应用包中声明最多五个相对于应用包根路径的文件夹路径,它们将在应用进程的加载程序搜索路径中使用。

Windows 应用的 DLL 搜索顺序包含程序包依赖关系图中的包,前提是这些包具有执行权限。 默认情况下,这包括主包、可选包和框架包,但这可以被程序包清单中的 uap6:AllowExecution 元素所覆盖。

默认情况下,包含在 DLL 搜索顺序中的包将包括其有效路径。 关于有效路径的详细信息,请参阅 EffectivePath 属性 (WinRT) 和 PackagePathType 枚举 (Win32)。

如果包指定了 uap6:LoaderSearchPathOverride,则使用此信息而不是包的有效路径。

每个包只能包含一个 uap6:LoaderSearchPathOverride 扩展。 也就是说,你可以将其中一个扩展添加到主程序包,然后向你的每个可选包和相关的集添加一个扩展。

XML 命名空间

http://schemas.microsoft.com/appx/manifest/uap/windows10/6

该扩展的元素和特性

在应用清单的包级别声明该扩展。

<Extension Category="windows.loaderSearchPathOverride">
  <LoaderSearchPathOverride>
    <LoaderSearchPathEntry FolderPath="[path]"/>
  </LoaderSearchPathOverride>
</Extension>

名称 说明
类别 总是为 windows.loaderSearchPathOverride
FolderPath 包含 DLL 文件的文件夹路径。 指定相对于程序包根文件夹的路径。 你可以在一个扩展中最多指定五个路径。 如果你希望系统搜索程序包根文件夹中的文件,请为这些路径之一使用空字符串。 不要包含重复路径,确保路径的开头和结尾不包含斜杠或反斜杠。

系统不搜索子文件夹,因此请务必明确列出包含你希望系统加载的 DLL 文件的每个文件夹。

示例

<Package
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/6"
  IgnorableNamespaces="uap6">
  ...
    <Extensions>
      <uap6:Extension Category="windows.loaderSearchPathOverride">
        <uap6:LoaderSearchPathOverride>
          <uap6:LoaderSearchPathEntry FolderPath=""/>
          <uap6:LoaderSearchPathEntry FolderPath="folder1/subfolder1"/>
          <uap6:LoaderSearchPathEntry FolderPath="folder2/subfolder2"/>
        </uap6:LoaderSearchPathOverride>
      </uap6:Extension>
    </Extensions>
...
</Package>

与文件资源管理器集成

帮助用户整理文件并以熟悉的方式与之交互。

定义用户同时选择并打开多个文件时应用程序的行为方式

指定用户同时打开多个文件时应用程序的行为方式。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/2
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]" MultiSelectModel="[SelectionModel]">
        <SupportedVerbs>
            <Verb Id="Edit" MultiSelectModel="[SelectionModel]">Edit</Verb>
        </SupportedVerbs>
        <SupportedFileTypes>
            <FileType>"[FileExtension]"</FileType>
        </SupportedFileTypes>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
MultiSelectModel 请参阅下文
FileType 相关的文件扩展名。

MultiSelectModel

已打包的桌面应用具有与常规桌面应用相同的三个选项。

  • Player:应用程序已激活一次。 将所有所选文件作为实参参数传递给应用程序。
  • Single:为第一个选定的文件激活一次应用程序。 忽略其他文件。
  • Document:针对每个选定的文件激活应用程序的一个新的单独实例。

可以为不同的文件类型和操作设置不同的首选项。 例如,你可能希望以“文档”模式打开文档,以“播放机”模式打开图像。

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  IgnorableNamespaces="uap, uap2, uap3">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap3:FileTypeAssociation Name="myfiletypes" MultiSelectModel="Document">
            <uap2:SupportedVerbs>
              <uap3:Verb Id="Edit" MultiSelectModel="Player">Edit</uap3:Verb>
              <uap3:Verb Id="Preview" MultiSelectModel="Document">Preview</uap3:Verb>
            </uap2:SupportedVerbs>
            <uap:SupportedFileTypes>
              <uap:FileType>.txt</uap:FileType>
            </uap:SupportedFileTypes>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

如果用户打开 15 个或更少的文件,MultiSelectModel 特性的默认选项为播放机。 否则,默认选项“文档”。 始终将 UWP 应用启动为播放机

在文件资源管理器内以缩略图显示文件内容

使用户可在文件图标以中、大或超大尺寸显示时查看文件内容的缩略图。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/2
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3
  • http://schemas.microsoft.com/appx/manifest/desktop/windows10/2

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]">
        <SupportedFileTypes>
            <FileType>"[FileExtension]"</FileType>
        </SupportedFileTypes>
        <ThumbnailHandler
            Clsid  ="[Clsid  ]" />
    </FileTypeAssociation>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
FileType 相关的文件扩展名。
Clsid 应用的类 ID。

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
  IgnorableNamespaces="uap, uap2, uap3, desktop2">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap3:FileTypeAssociation Name="myfiletypes">
            <uap2:SupportedFileTypes>
              <uap:FileType>.bar</uap:FileType>
            </uap2:SupportedFileTypes>
            <desktop2:ThumbnailHandler
              Clsid  ="20000000-0000-0000-0000-000000000001"  />
            </uap3:FileTypeAssociation>
         </uap::Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

在文件资源管理器的“预览”窗格中显示文件内容

使用户可以在文件资源管理器的“预览”窗格中预览文件的内容。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/2
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3
  • http://schemas.microsoft.com/appx/manifest/desktop/windows10/2

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]">
        <SupportedFileTypes>
            <FileType>"[FileExtension]"</FileType>
        </SupportedFileTypes>
        <DesktopPreviewHandler Clsid  ="[Clsid  ]" />
    </FileTypeAssociation>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
FileType 相关的文件扩展名。
Clsid 应用的类 ID。

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
  IgnorableNamespaces="uap, uap2, uap3, desktop2">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap3:FileTypeAssociation Name="myfiletypes">
            <uap2SupportedFileTypes>
              <uap:FileType>.bar</uap:FileType>
                </uap2SupportedFileTypes>
              <desktop2:DesktopPreviewHandler Clsid ="20000000-0000-0000-0000-000000000001" />
           </uap3:FileTypeAssociation>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使用户能够使用文件资源管理器中的“类型”列对文件进行分组

可以将文件类型的一个或多个预定义值与类型字段相关联。

在文件资源管理器中,用户可以使用该字段对这些文件进行分组。 系统组件也会将此字段用于不同的用途,例如建立索引。

若要详细了解类型字段以及可对此字段使用的值,请参阅使用类型名称

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3

该扩展的元素和特性

<Extension Category="windows.fileTypeAssociation">
    <FileTypeAssociation Name="[Name]">
        <SupportedFileTypes>
            <FileType>"[FileExtension]"</FileType>
        </SupportedFileTypes>
        <KindMap>
            <Kind value="[KindValue]">
        </KindMap>
    </FileTypeAssociation>
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
FileType 相关的文件扩展名。
value 有效的类型值

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3"
  IgnorableNamespaces="uap, rescap">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
           <uap:FileTypeAssociation Name="mediafiles">
             <uap:SupportedFileTypes>
               <uap:FileType>.m4a</uap:FileType>
               <uap:FileType>.mta</uap:FileType>
             </uap:SupportedFileTypes>
             <rescap:KindMap>
               <rescap:Kind value="Item">
               <rescap:Kind value="Communications">
               <rescap:Kind value="Task">
             </rescap:KindMap>
          </uap:FileTypeAssociation>
      </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使文件属性可用于搜索、索引、属性对话框和详细信息窗格

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10
  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3
  • http://schemas.microsoft.com/appx/manifest/desktop/windows10/2

该扩展的元素和特性

<uap:Extension Category="windows.fileTypeAssociation">
    <uap:FileTypeAssociation Name="[Name]">
        <SupportedFileTypes>
            <FileType>.bar</FileType>
        </SupportedFileTypes>
        <DesktopPropertyHandler Clsid ="[Clsid]"/>
    </uap:FileTypeAssociation>
</uap:Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.fileTypeAssociation
名称 文件类型关联的名称。 此名称可用于组织和分组文件类型。 该名称必须是不带空格的小写字符。
FileType 相关的文件扩展名。
Clsid 应用的类 ID。

示例

<Package
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
  IgnorableNamespaces="uap, uap3, desktop2">
  <Applications>
    <Application>
      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap3:FileTypeAssociation Name="myfiletypes">
            <uap:SupportedFileTypes>
              <uap:FileType>.bar</uap:FileType>
            </uap:SupportedFileTypes>
            <desktop2:DesktopPropertyHandler Clsid ="20000000-0000-0000-0000-000000000001"/>
          </uap3:FileTypeAssociation>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

为文件类型指定上下文菜单处理程序

如果桌面应用程序定义上下文菜单处理程序,请使用此扩展插件来注册菜单处理程序。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/foundation/windows10
  • http://schemas.microsoft.com/appx/manifest/desktop/windows10/4

该扩展的元素和特性

<Extensions>
    <com:Extension Category="windows.comServer">
        <com:ComServer>
            <com:SurrogateServer AppId="[AppID]" DisplayName="[DisplayName]">
                <com:Class Id="[Clsid]" Path="[Path]" ThreadingModel="[Model]"/>
            </com:SurrogateServer>
        </com:ComServer>
    </com:Extension>
    <desktop4:Extension Category="windows.fileExplorerContextMenus">
        <desktop4:FileExplorerContextMenus>
            <desktop4:ItemType Type="[Type]">
                <desktop4:Verb Id="[ID]" Clsid="[Clsid]" />
            </desktop4:ItemType>
        </desktop4:FileExplorerContextMenus>
    </desktop4:Extension>
</Extensions>

在此处找到完整的架构参考:com:ComServerdesktop4:FileExplorerContextMenus

Instructions

若要注册上下文菜单处理程序,请遵循以下说明。

  1. 在桌面应用程序中,通过实现 IExplorerCommandIExplorerCommandState 接口来实现上下文菜单处理程序。 有关示例,请参阅 ExplorerCommandVerb 代码示例。 确保为每个实现对象定义类 GUID。 例如,以下代码定义 IExplorerCommand 实现的类 ID。

    class __declspec(uuid("d0c8bceb-28eb-49ae-bc68-454ae84d6264")) CExplorerCommandVerb;
    
  2. 在程序包清单中,指定 com:ComServer 应用程序扩展,该扩展使用上下文菜单处理程序实现的类 ID 注册 COM 代理服务器。

    <com:Extension Category="windows.comServer">
        <com:ComServer>
            <com:SurrogateServer AppId="d0c8bceb-28eb-49ae-bc68-454ae84d6264" DisplayName="ContosoHandler">
                <com:Class Id="d0c8bceb-28eb-49ae-bc68-454ae84d6264" Path="ExplorerCommandVerb.dll" ThreadingModel="STA"/>
            </com:SurrogateServer>
        </com:ComServer>
    </com:Extension>
    
  3. 在程序包清单中,指定注册上下文菜单处理程序实现的 desktop4:FileExplorerContextMenus 应用程序扩展。

    <desktop4:Extension Category="windows.fileExplorerContextMenus">
        <desktop4:FileExplorerContextMenus>
            <desktop4:ItemType Type=".rar">
                <desktop4:Verb Id="Command1" Clsid="d0c8bceb-28eb-49ae-bc68-454ae84d6264" />
            </desktop4:ItemType>
        </desktop4:FileExplorerContextMenus>
    </desktop4:Extension>
    

示例

<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
  xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
  IgnorableNamespaces="desktop4">
  <Applications>
    <Application>
      <Extensions>
        <com:Extension Category="windows.comServer">
          <com:ComServer>
            <com:SurrogateServer AppId="d0c8bceb-28eb-49ae-bc68-454ae84d6264" DisplayName="ContosoHandler">
              <com:Class Id="d0c8bceb-28eb-49ae-bc68-454ae84d6264" Path="ExplorerCommandVerb.dll" ThreadingModel="STA"/>
            </com:SurrogateServer>
          </com:ComServer>
        </com:Extension>
        <desktop4:Extension Category="windows.fileExplorerContextMenus">
          <desktop4:FileExplorerContextMenus>
            <desktop4:ItemType Type=".contoso">
              <desktop4:Verb Id="Command1" Clsid="d0c8bceb-28eb-49ae-bc68-454ae84d6264" />
            </desktop4:ItemType>
          </desktop4:FileExplorerContextMenus>
        </desktop4:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使你的云服务中的文件显示在文件资源管理器中

注册你在应用程序中实现的处理程序。 你还可以添加上下文菜单选项 - 当用户在文件资源管理器中右键单击你的基于云的文件时,将显示这些菜单选项。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/desktop/windows10

该扩展的元素和特性

<Extension Category="windows.cloudfiles" >
    <CloudFiles IconResource="[Icon]">
        <CustomStateHandler Clsid ="[Clsid]"/>
        <ThumbnailProviderHandler Clsid ="[Clsid]"/>
        <ExtendedPropertyhandler Clsid ="[Clsid]"/>
        <CloudFilesContextMenus>
            <Verb Id ="Command3" Clsid= "[GUID]">[Verb Label]</Verb>
        </CloudFilesContextMenus>
    </CloudFiles>
</Extension>

名称 说明
类别 总是为 windows.cloudfiles
iconResource 代表你的云文件提供商服务的图标。 该图标显示在文件资源管理器的导航窗格中。 用户选择该图标可显示云服务中的文件。
CustomStateHandler Clsid 实现 CustomStateHandler 的应用程序的类 ID。 系统使用该类 ID 请求云文件的自定义状态和列。
ThumbnailProviderHandler Clsid 实现 ThumbnailProviderHandler 的应用程序的类 ID。 系统使用该类 ID 请求云文件的缩略图图像。
ExtendedPropertyHandler Clsid 实现 ExtendedPropertyHandler 的应用程序的类 ID。 系统使用该类 ID 请求云文件的扩展属性。
谓词 你的云服务提供的文件在文件资源管理器上下文菜单中显示的名称。
ID 动词命令的唯一 ID。

示例

<Package
    xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
    IgnorableNamespaces="desktop">
  <Applications>
    <Application>
      <Extensions>
        <Extension Category="windows.cloudfiles" >
            <CloudFiles IconResource="images\Wide310x150Logo.png">
                <CustomStateHandler Clsid ="20000000-0000-0000-0000-000000000001"/>
                <ThumbnailProviderHandler Clsid ="20000000-0000-0000-0000-000000000001"/>
                <ExtendedPropertyhandler Clsid ="20000000-0000-0000-0000-000000000001"/>
                <desktop:CloudFilesContextMenus>
                    <desktop:Verb Id ="keep" Clsid=
                       "20000000-0000-0000-0000-000000000001">
                       Always keep on this device</desktop:Verb>
                </desktop:CloudFilesContextMenus>
            </CloudFiles>
          </Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

以不同方式启动应用程序

使用协议启动应用程序

协议关联允许其他程序和系统组件与打包后的应用进行互操作。 使用某个协议启动打包后的应用程序时,可以指定要传递到其激活事件参数的特定参数,以使该应用做出相应行为。 仅打包后完全受信任的应用支持参数。 UWP 应用不能使用参数。

XML 命名空间

http://schemas.microsoft.com/appx/manifest/uap/windows10/3

该扩展的元素和特性

<Extension
    Category="windows.protocol">
  <Protocol
      Name="[Protocol name]"
      Parameters="[Parameters]" />
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.protocol
名称 协议的名称。
参数 应用程序激活时要向其传递用作事件参数的参数和值的列表。 如果变量可包含文件路径,请用引号将参数值括起来。 这将避免路径包含空格的情况下出现的任何问题。

示例

<Package
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
  IgnorableNamespaces="uap3, desktop">
  <Applications>
    <Application>
      <Extensions>
        <uap3:Extension
          Category="windows.protocol">
          <uap3:Protocol
            Name="myapp-cmd"
            Parameters="/p &quot;%1&quot;" />
        </uap3:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

使用别名启动应用程序

用户和其他进程可以使用别名启动应用程序,无需指定应用的完整路径。 可以指定该别名。

XML 命名空间

  • http://schemas.microsoft.com/appx/manifest/uap/windows10/3
  • http://schemas.microsoft.com/appx/manifest/desktop/windows10

该扩展的元素和特性

<uap3:Extension
    Category="windows.appExecutionAlias"
    Executable="[ExecutableName]"
    EntryPoint="Windows.FullTrustApplication">
    <uap3:AppExecutionAlias>
        <desktop:ExecutionAlias Alias="[AliasName]" />
    </uap3:AppExecutionAlias>
</uap3:Extension>
名称 说明
类别 总是为 windows.appExecutionAlias
可执行文件 调用别名时要启动的可执行文件的相对路径。
Alias 应用的简称。 它必须始终以“.exe”扩展名结尾。 只可以为程序包中每个应用程序指定一个应用执行别名。 如果多个应用都注册了同一个别名,系统会调用最后注册的一个应用,因此请确保选择其他应用不太可能覆盖的独特别名。

示例

<Package
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  IgnorableNamespaces="uap3">
  <Applications>
    <Application>
      <Extensions>
         <uap3:Extension
                Category="windows.appExecutionAlias"
                Executable="exes\launcher.exe"
                EntryPoint="Windows.FullTrustApplication">
            <uap3:AppExecutionAlias>
                <desktop:ExecutionAlias Alias="Contoso.exe" />
            </uap3:AppExecutionAlias>
        </uap3:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

此处查找完整的架构参考。

用户登录 Windows 时启动可执行文件

启动任务允许你的应用程序在用户登录时自动运行一个可执行文件。

注意

用户必须至少启动一次应用程序才可注册此启动任务。

应用程序可声明多个启动任务。 每个任务独立启动。 所有启动任务都将显示在任务管理器的启动选项卡下,其名称在应用的清单和应用的图标中指定。 任务管理器将自动分析任务的启动影响。

用户可以使用任务管理器手动禁用应用的启动任务。 如果用户禁用任务,则无法以编程方式重新启用它。

XML 命名空间

http://schemas.microsoft.com/appx/manifest/desktop/windows10

该扩展的元素和特性

<Extension
    Category="windows.startupTask"
    Executable="[ExecutableName]"
    EntryPoint="Windows.FullTrustApplication">
  <StartupTask
      TaskId="[TaskID]"
      Enabled="true"
      DisplayName="[DisplayName]" />
</Extension>
名称 说明
类别 总是为 windows.startupTask
可执行文件 要启动的可执行文件的相对路径。
TaskId 任务的唯一标识符。 应用程序可以使用此标识符调用 Windows.ApplicationModel.StartupTask 类中的 API,以便以编程方式启用或禁用启动任务。
已启用 指示是启用还是禁用任务的首次启动。 启用的任务将在用户下次登录时运行(除非用户禁用它)。
DisplayName 任务管理器中显示的任务名称。 可以使用 ms-resource 本地化此字符串。

示例

<Package
  xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
  IgnorableNamespaces="desktop">
  <Applications>
    <Application>
      <Extensions>
        <desktop:Extension
          Category="windows.startupTask"
          Executable="bin\MyStartupTask.exe"
          EntryPoint="Windows.FullTrustApplication">
        <desktop:StartupTask
          TaskId="MyStartupTask"
          Enabled="true"
          DisplayName="My App Service" />
        </desktop:Extension>
      </Extensions>
    </Application>
  </Applications>
 </Package>

在用户向电脑连接设备时启动你的应用程序

当用户向其电脑连接设备时,自动播放可以将你的应用程序作为一个选项提供。

XML 命名空间

http://schemas.microsoft.com/appx/manifest/desktop/windows10/3

该扩展的元素和特性

<Extension Category="windows.autoPlayHandler">
  <AutoPlayHandler>
    <InvokeAction ActionDisplayName="[action string]" ProviderDisplayName="[name of your app/service]">
      <Content ContentEvent="[Content event]" Verb="[any string]" DropTargetHandler="[Clsid]" />
      <Content ContentEvent="[Content event]" Verb="[any string]" Parameters="[Initialization parameter]"/>
      <Device DeviceEvent="[Device event]" HWEventHandler="[Clsid]" InitCmdLine="[Initialization parameter]"/>
    </InvokeAction>
  </AutoPlayHandler>
名称 说明
类别 总是为 windows.autoPlayHandler
ActionDisplayName 表示用户可以对其连接到电脑的设备执行的操作的字符串(例如:“导入文件”或“播放视频”)。
ProviderDisplayName 表示你的应用程序或服务的字符串(例如:“Contoso 视频播放器”)。
ContentEvent 导致向用户提示你的 ActionDisplayNameProviderDisplayName 的内容事件的名称。 当卷设备(如相机内存卡、U 盘或 DVD)插入到电脑时,会引发内容事件。 你可以在此处找到此类事件的完整列表。
谓词 “谓词”设置标识针对所选选项传递给你的应用程序的值。 你可以为自动播放事件指定多个启动操作并且可以使用谓词设置确定用户为你的应用选择的选项。 你可以通过检查传递给应用的启动事件参数的 verb 属性来标识用户选择的选项。 你可以为谓词设置使用任何值(但保留的 open 除外)。
DropTargetHandler 实现 IDropTarget 接口的应用程序的类 ID。 系统会将可移动媒体中的文件传递给你的 IDropTarget 实现的 Drop 方法。
参数 你不必为所有内容事件实现 IDropTarget 接口。 对于任意内容事件,你可以提供命令行参数,而不是实现 IDropTarget 接口。 对于此类事件,自动播放将使用这些命令行参数启动你的应用程序。 你可以在应用的初始化代码中解析这些参数,确定应用是否由自动播放启动,然后提供自定义实现。
DeviceEvent 导致向用户提示你的 ActionDisplayNameProviderDisplayName 的设备事件的名称。 当有设备连接到电脑时,将引发设备事件。 设备事件以字符串 WPD 开头,你可以在此处找到设备事件列表。
HWEventHandler 实现 IHWEventHandler 接口的应用程序的类 ID。
InitCmdLine 你要传递给 IHWEventHandler 接口的 Initialize 方法的字符串参数。

示例

<Package
  xmlns:desktop3="http://schemas.microsoft.com/appx/manifest/desktop/windows10/3"
  IgnorableNamespaces="desktop3">
  <Applications>
    <Application>
      <Extensions>
        <desktop3:Extension Category="windows.autoPlayHandler">
          <desktop3:AutoPlayHandler>
            <desktop3:InvokeAction ActionDisplayName="Import my files" ProviderDisplayName="ms-resource:AutoPlayDisplayName">
              <desktop3:Content ContentEvent="ShowPicturesOnArrival" Verb="show" DropTargetHandler="CD041BAE-0DEA-4472-9B7B-C98043D26EA8"/>
              <desktop3:Content ContentEvent="PlayVideoFilesOnArrival" Verb="play" Parameters="%1" />
              <desktop3:Device DeviceEvent="WPD\ImageSource" HWEventHandler="CD041BAE-0DEA-4472-9B7B-C98043D26EA8" InitCmdLine="/autoplay"/>
            </desktop3:InvokeAction>
          </desktop3:AutoPlayHandler>
      </Extensions>
    </Application>
  </Applications>
</Package>

在接收来自 Microsoft Store 的更新后自动重启

如果在用户安装应用程序更新时,你的应用程序已打开,则该应用程序将关闭。

如果你希望该应用程序在更新完成后重新启动,请在要重新启动的每个进程中调用 RegisterApplicationRestart 函数。

应用程序中的每个活动窗口都会收到 WM_QUERYENDSESSION 消息。 此时,你的应用程序可在必要时再次调用 RegisterApplicationRestart 函数以更新命令行。

当你的应用程序中的每个活动窗口都收到 WM_ENDSESSION 消息时,应用程序应保存数据并关闭。

注意

如果该应用程序未处理 WM_ENDSESSION 消息,你的活动窗口还会收到 WM_CLOSE 消息。

此时,你的应用程序有 30 秒时间来关闭自己的进程,或由平台强制终止这些进程。

更新完成后,你的应用程序将重新启动。

与其他应用程序配合使用

与其他应用集成,启动其他进程或共享信息。

使应用程序在支持打印的应用程序中显示为打印目标

用户想要从其他应用程序(如记事本)打印数据时,可使应用程序在可用打印目标的应用列表中显示为打印目标。

必须修改应用程序,使其接收 XML 纸张规范 (XPS) 格式的打印数据。

XML 命名空间

http://schemas.microsoft.com/appx/manifest/desktop/windows10/2

该扩展的元素和特性

<Extension Category="windows.appPrinter">
    <AppPrinter
        DisplayName="[DisplayName]"
        Parameters="[Parameters]" />
</Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.appPrinter
DisplayName 希望在应用的打印目标列表中显示的名称。
参数 应用程序正确处理请求所需的任何参数。

示例

<Package
  xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
  IgnorableNamespaces="desktop2">
  <Applications>
  <Application>
    <Extensions>
      <desktop2:Extension Category="windows.appPrinter">
        <desktop2:AppPrinter
          DisplayName="Send to Contoso"
          Parameters="/insertdoc %1" />
      </desktop2:Extension>
    </Extensions>
  </Application>
</Applications>
</Package>

此处查找使用此扩展的示例

与其他 Windows 应用程序共享字体

与其他 Windows 应用程序共享自定义字体。

注意

在将使用此扩展的应用提交到 Microsoft Store 之前,必须先获得 Microsoft Store 团队的批准。 要获得批准,请转到 https://aka.ms/storesupport,单击“联系我们”,然后选择与将应用提交到仪表板相关的选项。 此批准过程有助于我们确保应用安装的字体与操作系统安装的字体之间不会发生冲突。 如果没有获得批准,提交应用时,你会收到类似于以下的错误:“包接受验证错误:你无法将扩展 windows.sharedFonts 用于此帐户。 如果你想要请求使用此扩展的权限,请联系我们的支持团队。”

XML 命名空间

http://schemas.microsoft.com/appx/manifest/uap/windows10/4

该扩展的元素和特性

<Extension Category="windows.sharedFonts">
    <SharedFonts>
      <Font File="[FontFile]" />
    </SharedFonts>
  </Extension>

此处查找完整的架构参考。

名称 说明
类别 总是为 windows.sharedFonts
文件 包含想要共享的字体的文件。

示例

<Package
  xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
  IgnorableNamespaces="uap4">
  <Applications>
    <Application>
      <Extensions>
        <uap4:Extension Category="windows.sharedFonts">
          <uap4:SharedFonts>
            <uap4:Font File="Fonts\JustRealize.ttf" />
            <uap4:Font File="Fonts\JustRealizeBold.ttf" />
          </uap4:SharedFonts>
        </uap4:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

从通用 Windows 平台 (UWP) 应用启动 Win32 进程

启动以完全信任方式运行的 Win32 进程。

XML 命名空间

http://schemas.microsoft.com/appx/manifest/desktop/windows10

该扩展的元素和特性

<Extension Category="windows.fullTrustProcess" Executable="[executable file]">
  <FullTrustProcess>
    <ParameterGroup GroupId="[GroupID]" Parameters="[Parameters]"/>
  </FullTrustProcess>
</Extension>
名称 说明
类别 总是为 windows.fullTrustProcess
GroupID 标识想要传递给可执行文件的参数集的字符串。
参数 想要传递给可执行文件的参数。

示例

<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
         xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
         xmlns:rescap=
"http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
         xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10">
  ...
  <Capabilities>
      <rescap:Capability Name="runFullTrust"/>
  </Capabilities>
  <Applications>
    <Application>
      <Extensions>
          <desktop:Extension Category="windows.fullTrustProcess" Executable="fulltrustprocess.exe">
              <desktop:FullTrustProcess>
                  <desktop:ParameterGroup GroupId="SyncGroup" Parameters="/Sync"/>
                  <desktop:ParameterGroup GroupId="OtherGroup" Parameters="/Other"/>
              </desktop:FullTrustProcess>
           </desktop:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

如果要创建在所有设备上运行的通用 Windows 平台用户界面,但希望 Win32 应用程序的组件继续以完全信任方式运行,此扩展可能会很有用。

只需为 Win32 应用创建 Windows 应用包。 然后,将此扩展添加到 UWP 应用的程序包文件。 此扩展指示你要在 Windows 应用包中启动可执行文件。 如果想要在 UWP 应用和 Win32 应用之间进行通信,可以设置一个或多个应用服务来执行此操作。 可以在此处阅读关于此方案的详细信息。

后续步骤

有问题? 请在 Stack Overflow 上向我们提问。 我们的团队会监视这些标记。 你还可以在此处提问。