將傳統型應用程式與 Windows 10 和 UWP 整合Integrate your desktop app with Windows 10 and UWP

如果您的桌面應用程式具有 套件身分識別,您可以使用 套件資訊清單中預先定義的延伸模組,利用擴充功能將應用程式與 Windows 10 整合。If your desktop app has package identity, you can use extensions to integrate your app with Windows 10 by using predefined extensions in the package manifest.

例如:使用延伸模組建立防火牆例外,讓您的應用程式成為某一種檔案類型的預設應用程式,或將開始畫面磚指向您的應用程式。For example, use an extension to create a firewall exception, make your app the default application for a file type, or point start tiles to your app. 若要使用延伸模組,您只需要將一些 XML 加入應用程式的封裝資訊清單檔案。To use an extension, just add some XML to your app's package manifest file. 不需要程式碼。No code is required.

本文會描述這些延伸模組,以及您可以使用這些延伸模組執行的工作。This article describes these extensions and the tasks that you can perform by using them.

注意

傳統型應用程式需要具備套件識別資料,才能使用本文所述的功能。可選擇將傳統型應用程式封裝在 MSIX 套件中,或是使用剖析套件授與應用程式識別資料The features described in this article require that your desktop app has package identity, either by packaging your desktop app in an MSIX package or by granting your app identity by using a sparse package.

將使用者轉換至您的應用程式Transition users to your app

協助使用者轉換至您已封裝的應用程式。Help users transition to your packaged app.

將現有的開始畫面磚和工作列按鈕指向您已封裝的應用程式Point existing Start tiles and taskbar buttons to your packaged app

您的使用者可能會將您的傳統型應用程式釘選至工作列或 [開始] 功能表。Your users might have pinned your desktop application to the taskbar or the Start menu. 您可以將這些捷徑指向新的已封裝應用程式。You can point those shortcuts to your new packaged app.

XML 命名空間XML namespace

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 說明Description
類別Category 一律為 windows.desktopAppMigrationAlways windows.desktopAppMigration.
AumIDAumID 封裝應用程式的應用程式使用者模型識別碼。The Application User Model ID of your packaged app.
ShortcutPathShortcutPath 啟動您傳統型版本應用程式之 .lnk 檔案的路徑。The path to .lnk files that start the desktop version of your app.

範例Example

<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 圖片檢視器WPF picture viewer with transition/migration/uninstallation

使用您已封裝的應用程式開啟檔案,而非使用您的傳統型應用程式Make your packaged application open files instead of your desktop app

您可以確保使用者預設使用您新的已封裝應用程式開啟特定類型的檔案,而非使用您傳統型版本的應用程式開啟。You can make sure that users open your new packaged application by default for specific types of files instead of opening the desktop version of your app.

若要完成這項工作,您可以針對想要繼承檔案關聯的每個應用程式,為其指定程式設計識別碼 (ProgID)To do that, you'll specify the programmatic identifier (ProgID) of each application from which you want to inherit file associations.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 說明Description
類別Category 一律為 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
MigrationProgIdMigrationProgId 程式設計識別碼 (ProgID) 針對您想要繼承檔案關聯的傳統型應用程式,描述其應用程式、元件,以及版本。The programmatic identifier (ProgID) that describes the application, component, and version of the desktop application from which you want to inherit file associations.

範例Example

<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 圖片檢視器WPF picture viewer with transition/migration/uninstallation

將已封裝的應用程式和一組檔案類型建立關聯Associate your packaged application with a set of file types

您可以將封裝的應用程式與檔案類型副檔名產生關聯。You can associate your packaged application with file type extensions. 如果使用者以滑鼠右鍵按一下檔案總管中的檔案,然後選取 [ 開啟檔案 ] 選項,則您的應用程式會出現在建議清單中。If a user right-clicks a file in File Explorer and then selects the Open with option, your application appears in the list of suggestions. 如需使用此延伸模組的詳細資訊,請參閱 將封裝的桌面應用程式與檔案總管整合For more information about using this extension, see Integrate a packaged desktop app with File Explorer.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
FileTypeFileType 您的應用程式支援的副檔名。The file extension supported by your app.

範例Example

<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 圖片檢視器WPF picture viewer with transition/migration/uninstallation

將選項新增至具有特定檔案類型的檔案操作功能表Add options to the context menus of files that have a certain file type

此延伸模組可讓您將選項新增至使用者以滑鼠右鍵按一下檔案總管中的檔案時所顯示的內容功能表。這些選項可讓使用者以其他方式與您的檔案互動,例如列印、編輯或預覽檔案。This extension enables you to add options to the context menu that displays when users right-click a file in File Explorer.These options give users other ways to interact with your file such as print, edit, or preview the file. 如需使用此延伸模組的詳細資訊,請參閱 將封裝的桌面應用程式與檔案總管整合For more information about using this extension, see Integrate a packaged desktop app with File Explorer.

XML 命名空間XML namespaces

  • 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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
動詞Verb 在 [檔案總管] 操作功能表中出現的名稱。The name that appears in the File Explorer context menu. 此字串可使用 ms-resource 進行當地語系化。This string is localizable that uses ms-resource.
IdId 動詞的唯一識別碼。The unique Id of the verb. 若您的應用程式為 UWP 應用程式,則此識別碼會傳送至應用程式做為啟用事件引數的一部分,以便能夠適當處理使用者的選擇。If your application is a UWP app, this is passed to your app as part of its activation event args so it can handle the user’s selection appropriately. 如果您的應用程式是完全信任的封裝應用程式,則該應用程式會改為接收參數 (請參閱下一個項目符號)。If your application is a full-trust packaged app, it receives parameters instead (see the next bullet).
參數Parameters 與動詞關聯的引數參數和值清單。The list of argument parameters and values associated with the verb. 如果您的應用程式為完全信任的已封裝應用程式,這些參數會傳遞至應用程式做為啟動應用程式時的事件引數。If your application is a full-trust packaged app, these parameters are passed to the application as event args when the application is activated. 您可以根據不同的啟用動詞。自訂應用程式的行為。You can customize the behavior of your application based on different activation verbs. 如果變數包含檔案路徑,請使用引號括住參數。If a variable can contain a file path, wrap the parameter value in quotes. 這樣可避免路徑中包含空格時發生任何問題。That will avoid any issues that happen in cases where the path includes spaces. 如果您的應用程式是 UWP 應用程式,則無法傳遞參數。If your application is a UWP app, you can’t pass parameters. 應用程式會改為接收識別碼 (請參閱上一個項目符號)。The app receives the Id instead (see the previous bullet).
ExtendedExtended 指定僅在使用者以滑鼠右鍵按一下檔案之前,先按住 Shift 鍵以顯示操作功能表時,才會顯示動詞。Specifies that the verb appears only if the user shows the context menu by holding the Shift key before right-clicking the file. 此屬性為選擇性,而且預設值為 False (例如,一律顯示動詞)。This attribute is optional and defaults to a value of False (for example, always show the verb) if not listed. 您會針對每個動詞個別指定此行為 (不包括「開啟」,其一律設定為 False)。You specify this behavior individually for each verb (except for "Open," which is always False).

範例Example

<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 圖片檢視器WPF picture viewer with transition/migration/uninstallation

使用 URL 直接開啟特定類型的檔案Open certain types of files directly by using a URL

您可以確保使用者預設使用您新的已封裝應用程式開啟特定類型的檔案,而非使用您傳統型版本的應用程式開啟。You can make sure that users open your new packaged application by default for specific types of files instead of opening the desktop version of your app.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
UseUrlUseUrl 指出是否要直接從 URL 目標開啟檔案。Indicates whether to open files directly from a URL target. 如果您未設定這個值,每當您的應用程式嘗試使用 URL 開啟檔案時,都會讓系統先將檔案下載至本機電腦。If you do not set this value, attempts by your application to open a file by using a URL cause the system to first download the file locally.
參數Parameters 選用參數。Optional parameters.
FileTypeFileType 相關副檔名。The relevant file extensions.

範例Example

<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>

執行設定工作Perform setup tasks

為您的應用程式建立防火牆例外Create firewall exception for your app

如果您的應用程式需要透過連接埠進行通訊,您可以將應用程式新增至防火牆例外清單。If your application requires communication through a port, you can add your application to the list of firewall exceptions.

XML 命名空間XML namespace

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

此延伸模組的元素和屬性Elements and attributes of this extension

<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>

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一律為 windows.firewallRulesAlways windows.firewallRules
執行檔Executable 您想要新增到防火牆例外清單的可執行檔名稱The name of the executable file that you want to add to the list of firewall exceptions
方向Direction 指定規則為輸入或輸出規則Indicates whether the rule is an inbound or outbound rule
IPProtocolIPProtocol 通訊協定The communication protocol
LocalPortMinLocalPortMin 本機連接埠號碼範圍中較低的連接埠號碼。The lower port number in a range of local port numbers.
LocalPortMaxLocalPortMax 本機連接埠號碼範圍中最高的連接埠號碼。The highest port number of a range of local port numbers.
RemotePortMaxRemotePortMax 遠端連接埠號碼範圍中較低的連接埠號碼。The lower port number in a range of remote port numbers.
RemotePortMaxRemotePortMax 遠端連接埠數字範圍中最高的連接埠號碼。The highest port number of a range of remote port numbers.
設定檔Profile 網路類型The network type

範例Example

<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 檔案放置在套件的任何資料夾Place your DLL files into any folder of the package

使用 uap6:LoaderSearchPathOverride 擴充功能,在應用程式套件中宣告最多五個資料夾路徑 (相對於應用程式套件根路徑),以用於應用程式程序的載入器搜尋路徑。Use the uap6:LoaderSearchPathOverride extension to declare up to five folder paths in the app package, relative to the app package root path, to be used in the loader search path for the app's processes.

如果套件具有執行權限,Windows 應用程式的 DLL 搜尋順序會在套件相依性圖形中包含套件。The DLL search order for Windows apps includes packages in the package dependency graph if the packages have execution rights. 根據預設,這會包含主要、選擇性和架構套件,不過,封裝資訊清單中的 uap6:AllowExecution 元素可以覆寫此設定。By default, this includes main, optional and framework packages, although this can be overwritten by the uap6:AllowExecution element in the package manifest.

依預設,包含在 DLL 搜尋順序中的套件會包含其「有效路徑」。A package that is included in the DLL search order will, by default, include its effective path. 如需有效路徑的詳細資訊,請參閱 EffectivePath 屬性 (WinRT) 和 PackagePathType 列舉 (Win32)。For more information about effective paths, see the EffectivePath property (WinRT) and the PackagePathType enumeration (Win32).

如果套件指定 uap6:LoaderSearchPathOverride,則會使用這項資訊,而不是套件的有效路徑。If a package specifies uap6:LoaderSearchPathOverride, then this information is used instead of the package's effective path.

每個套件只能包含一個 uap6:LoaderSearchPathOverride 擴充功能。Each package can contain only one uap6:LoaderSearchPathOverride extension. 這表示您可以將其中一個新增到您的主要套件,並在每個選用套件及相關集合中新增一個。That means that you can add one of them to your main package, and then add one to each of your optional packages, and related sets.

XML 命名空間XML namespace

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

此延伸模組的元素和屬性Elements and attributes of this extension

在應用程式資訊清單的套件層級宣告此延伸模組。Declare this extension at the package-level of your app manifest.

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

名稱Name 描述Description
類別Category 一定是 windows.loaderSearchPathOverrideAlways windows.loaderSearchPathOverride.
FolderPathFolderPath 包含 DLL 檔案的資料夾路徑。The path of the folder that contains your DLL files. 指定相對於套件根資料夾的路徑。Specify a path that is relative to the root folder of the package. 您可以在一個延伸模組中指定最多 5 個路徑。You can specify up to five paths in one extension. 如果您想要系統在套件根資料夾中搜尋檔案,請使用空字串代表其中一個路徑。If you want the system to search for files in the root folder of the package, use an empty string for one of these paths. 不能包含重複路徑,並請確定路徑不包含前置和結尾斜線或反斜線。Don't include duplicate paths, and make sure that your paths don't contain leading and trailing slashes or backslashes.

系統不會搜尋子資料夾,因此請務必明確列出包含要系統載入的 DLL 檔案的每個資料夾。The system won't search subfolders, so make sure to explicitly list each folder that contains DLL files that you want the system to load.

範例Example

<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>

與檔案總管整合Integrate with File Explorer

協助使用者組織您的檔案,並以熟悉的方式與他們互動。Help users organize your files and interact with them in familiar ways.

定義使用者同時選取和開啟多個檔案時,您的應用程式將會如何反應Define how your application behaves when users select and open multiple files at the same time

指定當使用者同時開啟多個檔案時,您的應用程式將會如何反應。Specify how your application behaves when a user opens multiple files simultaneously.

XML 命名空間XML namespaces

  • 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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
MultiSelectModelMultiSelectModel 請參閱下方See below
FileTypeFileType 相關的檔案副檔名。The relevant file extensions.

MultiSelectModelMultiSelectModel

已封裝的傳統型應用程式具有與一般傳統型應用程式相同的三個選項。packaged desktop apps have the same three options as regular desktop apps.

  • Player:您的應用程式會啟動一次。Player: Your application is activated one time. 所有選取的檔案都會做為引數參數傳遞至您的應用程式。All of the selected files are passed to your application as argument parameters.
  • Single:您的應用程式會針對第一個選取的檔案啟動一次。Single: Your application is activated one time for the first selected file. 系統會忽略其他的檔案。Other files are ignored.
  • Document:針對每個所選檔案,個別啟動應用程式的新執行個體。Document: A new, separate instance of your application is activated for each selected file.

您可針對不同的檔案類型和動作,設定不同的喜好設定。You can set different preferences for different file types and actions. 例如,您可以會想要在 Document 模式中開啟 文件,以及在 Player 模式中開啟 影像For example, you may wish to open Documents in Document mode and Images in Player mode.

範例Example

<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 屬性的預設選項將會設定為 PlayerIf the user opens 15 or fewer files, the default choice for the MultiSelectModel attribute is Player. 否則,預設值將會設定為 DocumentOtherwise, the default is Document. UWP app 一律會以 Player 模式啟動。UWP apps are always started as Player.

在檔案總管中以縮圖影像顯示檔案內容Show file contents in a thumbnail image within File Explorer

讓使用者在檔案圖示以中圖示、大圖示,或超大圖示顯示時,可透過縮圖影像檢視檔案內容。Enable users to view a thumbnail image of the file's contents when the icon of the file appears in the medium, large, or extra large size.

XML 命名空間XML namespace

  • 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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
FileTypeFileType 相關的檔案副檔名。The relevant file extensions.
ClsidClsid 您應用程式的類別識別碼。The class ID of your app.

範例Example

<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>

在檔案總管的預覽窗格中顯示檔案內容Show file contents in the Preview pane of File Explorer

讓使用者可在檔案總管中的預覽窗格預覽檔案內容。Enable users to preview a file's contents in the Preview pane of File Explorer.

XML 命名空間XML namespace

  • 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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
FileTypeFileType 相關的檔案副檔名。The relevant file extensions.
ClsidClsid 您應用程式的類別識別碼。The class ID of your app.

範例Example

<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>

讓使用者在檔案總管中使用種類欄位群組檔案Enable users to group files by using the Kind column in File Explorer

您可以透過 種類 欄位使您的檔案類型與一或多個預先定義的值產生關聯。You can associate one or more predefined values for your file types with the Kind field.

在檔案總管中,使用者可以使用該欄位群組這些檔案。In File Explorer, users can group those files by using that field. 系統元件也會根據不同用途使用此欄位,例如:編製索引。System components also use this field for various purposes such as indexing.

如需有關 種類 欄位以及您可以使用於此欄位中的詳細資訊,請參閱 使用種類名稱For more information about the Kind field and the values that you can use for this field, see Using Kind Names.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
FileTypeFileType 相關的檔案副檔名。The relevant file extensions.
valuevalue 一個有效的 Kind 值A valid Kind value

範例Example

<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>

讓檔案屬性可供搜尋、索引、屬性對話方塊,以及詳細資料窗格使用Make file properties available to search, index, property dialogs, and the details pane

XML 命名空間XML namespace

  • 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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.fileTypeAssociationAlways windows.fileTypeAssociation.
名稱Name 檔案類型關聯的名稱。The name of the file type association. 您可以使用此名稱來組織檔案類型,並將其分組。You can use this name to organize and group file types. 名稱必須全部是小寫,而且沒有任何空格。The name must be all lower case characters with no spaces.
FileTypeFileType 相關的檔案副檔名。The relevant file extensions.
ClsidClsid 您應用程式的類別識別碼。The class ID of your app.

範例Example

<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>

為檔案類型指定操作功能表處理常式Specify a context menu handler for a file type

如果您的傳統型應用程式定義操作功能表處理常式,請使用此延伸模組來登錄功能表處理常式。If your desktop application defines a context menu handler, use this extension to register the menu handler.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

<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:FileExplorerContextMenusFind the complete schema reference here: com:ComServer and desktop4:FileExplorerContextMenus.

InstructionsInstructions

若要登錄您的操作功能表處理常式,請遵循下列指示。To register your context menu handler, follow these instructions.

  1. 在您的傳統型應用程式中,藉由實作 IExplorerCommandIExplorerCommandState 介面,來實作操作功能表處理常式In your desktop application, implement a context menu handler by implementing the IExplorerCommand or IExplorerCommandState interface. 如需範例,請參閱 ExplorerCommandVerb 程式碼範例。For a sample, see the ExplorerCommandVerb code sample. 確保為每個實作物件定義類別 GUID。Make sure that you define a class GUID for each of your implementation objects. 例如,下列程式碼會定義類別識別碼以實作 IExplorerCommandFor example, the following code defines a class ID for an implementation of IExplorerCommand.

    class __declspec(uuid("d0c8bceb-28eb-49ae-bc68-454ae84d6264")) CExplorerCommandVerb;
    
  2. 在您的封裝資訊清單中,指定 com:ComServer 應用程式延伸模組,該延伸模組使用操作功能表處理常式實作的類別識別碼,登錄 COM 代理伺服器。In your package manifest, specify a com:ComServer application extension that registers a COM surrogate server with the class ID of your context menu handler implementation.

    <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 應用程式延伸模組,以登錄操作功能表處理常式實作。In your package manifest, specify a desktop4:FileExplorerContextMenus application extension that registers your context menu handler implementation.

    <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>
    

範例Example

<Package
  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
  xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
  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>

讓雲端服務中的檔案出現在檔案總管Make files from your cloud service appear in File Explorer

登錄您的應用程式中實作的處理常式。Register the handlers that you implement in your application. 您也可以新增操作功能表選項,使用者在 [檔案總管] 中的雲端式檔案上按一下滑鼠右鍵時出現這些選項。You can also add context menu options that appear when you users right-click your cloud-based files in File Explorer.

XML 命名空間XML namespace

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

此延伸模組的元素和屬性Elements and attributes of this extension

<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>

名稱Name 描述Description
類別Category 一定是 windows.cloudfilesAlways windows.cloudfiles.
iconResourceiconResource 圖示,表示您的雲端檔案提供者服務。The icon that represents your cloud file provider service. 在 [檔案總管] 瀏覽窗格中,會顯示此圖示。This icon appears in the Navigation pane of File Explorer. 使用者選擇此圖示,以顯示您的雲端服務中的檔案。Users choose this icon to show files from your cloud service.
CustomStateHandler ClsidCustomStateHandler Clsid 實作 CustomStateHandler 的應用程式類別識別碼。The class ID of the application that implements the CustomStateHandler. 系統會使用這個類別 ID 要求雲端檔案的自訂狀態和欄。The system uses this Class ID to request custom states and columns for cloud files.
ThumbnailProviderHandler ClsidThumbnailProviderHandler Clsid 實作 ThumbnailProviderHandler 的應用程式類別識別碼。The class ID of the application that implements the ThumbnailProviderHandler. 系統會使用這個類別 ID 要求雲端檔案的縮圖影像。The system uses this Class ID to request thumbnail images for cloud files.
ExtendedPropertyHandler ClsidExtendedPropertyHandler Clsid 實作 ExtendedPropertyHandler 的應用程式類別識別碼。The class ID of the application that implements the ExtendedPropertyHandler. 系統會使用這個類別 ID 要求雲端檔案的擴充屬性。The system uses this Class ID to request extended properties for a cloud file.
動詞命令Verb 為您的雲端服務所提供的檔案,顯示在 [檔案總管] 操作功能表中的名稱。The name that appears in the File Explorer context menu for files provided by your cloud service.
IdId 指令動詞的唯一識別碼。The unique ID of the verb.

範例Example

<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>

以不同的方式啟動您的應用程式Start your application in different ways

使用通訊協定啟動您的應用程式Start your application by using a protocol

通訊協定關聯支援已封裝應用程式與其他程式或系統元件間的互相操作。Protocol associations can enable other programs and system components to interoperate with your packaged app. 若您使用通訊協定啟動已封裝的應用程式,則可指定特定參數傳送至該應用程式的啟用事件引數,讓其據以運作。When your packaged application is started by using a protocol, you can specify specific parameters to pass to its activation event arguments so it can behave accordingly. 參數僅支援已封裝、完全信任的應用程式。Parameters are supported only for packaged, full-trust apps. UWP app 無法使用參數。UWP apps can't use parameters.

XML 命名空間XML namespace

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.protocolAlways windows.protocol.
名稱Name 通訊協定的名稱。The name of the protocol.
參數Parameters 應用程式啟動時,做為事件引數傳遞至應用程式的參數與數值清單。The list of parameters and values to pass to your application as event arguments when the application is activated. 若變數包含了檔案路徑,請以引號包圍參數。If a variable can contain a file path, wrap the parameter value in quotes. 這將可避免路徑中包含空格時可能發生的任何問題。That will avoid any issues that happen in cases where the path includes spaces.

範例Example

<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>

使用別名啟動您的應用程式Start your application by using an alias

使用者和其他處理程序可以使用別名啟動您的應用程式,而不必指定您應用程式的完整路徑。Users and other processes can use an alias to start your application without having to specify the full path to your app. 您可以指定別名名稱。You can specify that alias name.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

<uap3:Extension
    Category="windows.appExecutionAlias"
    Executable="[ExecutableName]"
    EntryPoint="Windows.FullTrustApplication">
    <uap3:AppExecutionAlias>
        <desktop:ExecutionAlias Alias="[AliasName]" />
    </uap3:AppExecutionAlias>
</uap3:Extension>
名稱Name 描述Description
類別Category 一定是 windows.appExecutionAliasAlways windows.appExecutionAlias.
可執行檔Executable 叫用別名時欲啟動之可執行檔的相對路徑。The relative path to the executable to start when the alias is invoked.
AliasAlias 適用於您應用程式的簡短名稱。The short name for your app. 其必須一律以副檔名「.exe」結尾。It must always end with the ".exe" extension. 針對套件中的每個應用程式,您僅可指定單一應用程式執行別名。You can only specify a single app execution alias for each application in the package. 若有多個應用程式註冊相同的別名,系統將會叫用最後一個註冊的別名,因此請務必選擇絕對不會遭其他應用程式覆寫的唯一別名。If multiple apps register for the same alias, the system will invoke the last one that was registered, so make sure to choose a unique alias other apps are unlikely to override.

範例Example

<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>

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

在使用者登入 Windows 時執行可執行檔Start an executable file when users log into Windows

啟動工作能讓您的應用程式在每次使用者登入時,自動執行可執行檔。Startup tasks allow your application to run an executable automatically whenever a user logs on.

注意

使用者必須至少啟動您的應用程式一次,才能使您的應用程式登錄啟動工作。The user has to start your application at least one time to register this startup task.

您的應用程式可以宣告多個啟動工作。Your application can declare multiple startup tasks. 每個工作都是獨立啟動的。Each task starts independently. 所有啟動工作皆會顯示在「工作管理員」中的 [啟動] 索引標籤下方,且具有您在應用程式的資訊清單中指定的名稱,以及應用程式的圖示。All startup tasks will appear in Task Manager under the Startup tab with the name that you specify in your app's manifest and your app's icon. 工作管理員會自動分析您工作的啟動影響。Task Manager will automatically analyze the startup impact of your tasks.

使用者可以使用工作管理員手動停用您應用程式的啟動工作。Users can manually disable your app's startup task by using Task Manager. 若使用者停用工作,您將無法以程式設計的方式重新啟用它。If a user disables a task, you can't programmatically re-enable it.

XML 命名空間XML namespace

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

此延伸模組的元素和屬性Elements and attributes of this extension

<Extension
    Category="windows.startupTask"
    Executable="[ExecutableName]"
    EntryPoint="Windows.FullTrustApplication">
  <StartupTask
      TaskId="[TaskID]"
      Enabled="true"
      DisplayName="[DisplayName]" />
</Extension>
名稱Name 描述Description
類別Category 一定是 windows.startupTaskAlways windows.startupTask.
可執行檔Executable 欲啟動之可執行檔檔案的相對路徑。The relative path to the executable file to start.
TaskIdTaskId 您工作的唯一識別碼。A unique identifier for your task. 應用程式可使用此識別碼呼叫 Windows.ApplicationModel.StartupTask 類別中的 API,運用程式設計方式,啟用或停用啟動工作。Using this identifier, your application can call the APIs in the Windows.ApplicationModel.StartupTask class to programmatically enable or disable a startup task.
已啟用Enabled 指出工作第一次啟動時會是啟用或停用。Indicates whether the task first starts enabled or disabled. 下次使用者登入時,將會執行已啟用的工作 (除非使用者將其停用)。Enabled tasks will run the next time the user logs on (unless the user disables it).
DisplayNameDisplayName 出現在工作管理員中工作的名稱。The name of the task that appears in Task Manager. 您可以透過使用 ms-resource 來當地語系化此字串。You can localize this string by using ms-resource.

範例Example

<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>

讓使用者在將裝置連接到電腦時,啟動您的應用程式Enable users to start your application when they connect a device to their PC

當使用者將裝置連接至電腦時,「自動播放」會將您的應用程式顯示為選項。AutoPlay can present your application as an option when a user connects a device to their PC.

XML 命名空間XML namespace

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

此延伸模組的元素和屬性Elements and attributes of this extension

<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>
名稱Name 描述Description
類別Category 一定是 windows.autoPlayHandlerAlways windows.autoPlayHandler.
ActionDisplayNameActionDisplayName 字串,表示使用者可以在連接到電腦的裝置上執行的動作 (例如:「匯入檔案」或「播放影片」)。A string that represents the action that users can take with a device that they connect to a PC (For example: "Import files", or "Play video").
ProviderDisplayNameProviderDisplayName 此字串表示您的應用程式或服務 (例如:「Contoso 影片播放程式」)。A string that represents your application or service (For example: "Contoso video player").
ContentEventContentEvent 內容事件的名稱,該事件導致向使用者提示您的ActionDisplayNameProviderDisplayNameThe name of a content event that causes users to be prompted with your ActionDisplayName and ProviderDisplayName. 將磁碟區裝置 (例如,相機記憶卡、隨身碟或 DVD) 插入電腦時,就會引發內容事件。A content event is raised when a volume device such as a camera memory card, thumb drive, or DVD is inserted into the PC. 您可以在這裡找到那些事件的完整清單。You can find the full list of those events here.
動詞命令Verb [動詞] 設定會識別針對選取的選項而傳遞至應用程式的值。The Verb setting identifies a value that is passed to your application for the selected option. 您可以為自動播放事件指定多個啟動動作,並使用 [動詞] 設定判斷使用者為您 app 選取的選項。You can specify multiple launch actions for an AutoPlay event and use the Verb setting to determine which option a user has selected for your app. 您可以檢查傳遞至 app 啟動事件引數的 verb 屬性,以判斷使用者選取的選項。You can tell which option the user selected by checking the verb property of the startup event arguments passed to your app. 您可以在 [動詞] 設定使用保留字 open 以外的任何值。You can use any value for the Verb setting except, open, which is reserved.
DropTargetHandlerDropTargetHandler 實作 IDropTarget 介面的應用程式類別識別碼。The class ID of the application that implements the IDropTarget interface. 抽取式媒體中的檔案將會傳遞至IDropTarget實作的Drop方法。Files from the removable media are passed to the Drop method of your IDropTarget implementation.
參數Parameters 您不需要為所有內容事件實作IDropTarget介面。You don't have to implement the IDropTarget interface for all content events. 對於任何內容事件,您可以提供命令列參數,而不實作IDropTarget介面。For any of the content events, you could provide command line parameters instead of implementing the IDropTarget interface. 對於這些事件,自動播放會使用這些命令列參數啟動您的應用程式。For those events, AutoPlay will start your application by using those command line parameters. 您可以在應用程式的初始化程式碼中剖析這些參數,以判斷自動播放是否啟動應用程式,然後提供您的自訂實作。You can parse those parameters in your app's initialization code to determine if it was started by AutoPlay and then provide your custom implementation.
DeviceEventDeviceEvent 裝置事件的名稱,該事件導致向使用者提示您的ActionDisplayNameProviderDisplayNameThe name of a device event that causes users to be prompted with your ActionDisplayName and ProviderDisplayName. 將裝置連接到電腦時,就會引發裝置事件。A device event is raised when a device is connected to the PC. 裝置事件以字串WPD開頭,這裡列出這些裝置事件。Device events begin with the string WPD and you can find them listed here.
HWEventHandlerHWEventHandler 實作 IHWEventHandler 介面的應用程式類別識別碼。The Class ID of the application that implements the IHWEventHandler interface.
InitCmdLineInitCmdLine 您想要傳遞到IHWEventHandler介面的Initialize方法的字串參數。The string parameter that you want to pass into the Initialize method of the IHWEventHandler interface.

範例Example

<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 接收更新後自動重新開機Restart automatically after receiving an update from the Microsoft Store

如果您的應用程式在使用者安裝更新時已開啟,則會關閉應用程式。If your application is open when users install an update to it, the application closes.

如果您希望完成更新後該應用程式重新啟動,請在每個您想要重新啟動的處理程序中呼叫 RegisterApplicationRestart 函式。If you want that application to restart after the update completes, call the RegisterApplicationRestart function in every process that you want to restart.

應用程式中的每個使用中視窗都會收到 WM_QUERYENDSESSION 訊息。Each active window in your application receives a WM_QUERYENDSESSION message. 此時,如有需要,您的應用程式可以再次呼叫 RegisterApplicationRestart 函式,以更新命令列。At this point, your application can call the RegisterApplicationRestart function again to update the command line if necessary.

當應用程式中的每個使用中視窗收到 WM_ENDSESSION 訊息時,您的應用程式應該會儲存資料並關閉。When each active window in your application receives the WM_ENDSESSION message, your application should save data and shut down.

注意

使用中視窗也會收到 WM_CLOSE 訊息,以防應用程式未處理 WM_ENDSESSION 訊息。Your active windows also receive the WM_CLOSE message in case the application doesn't handle the WM_ENDSESSION message.

此時,您的應用程式有 30 秒的時間可以關閉本身的處理程序,否則平台會強制終止。At this point, your application has 30 seconds to close it's own processes or the platform terminates them forcefully.

更新完成後,您的應用程式會重新啟動。After the update is complete, your application restarts.

與其他應用程式合作Work with other applications

與其他應用程式整合,啟動其他處理程序,或共用資訊。Integrate with other apps, start other processes or share information.

在支援列印的應用程式中,將您的應用程式作為列印目標顯示Make your application appear as the print target in applications that support printing

當使用者想要從其他應用程式 (例如,記事本) 列印資料時,您可以讓您的應用程式做為列印目標,顯示在該應用程式的可用列印目標清單中。When users want to print data from another application such as Notepad, you can make your application appear as a print target in the app's list of available print targets.

您必須修改您的應用程式,使其能接收以 XML 文件規格 (XPS) 格式儲存的列印資料。You'll have to modify your application so that it receives print data in XML Paper Specification (XPS) format.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.appPrinterAlways windows.appPrinter.
DisplayNameDisplayName 您想要出現在另外一個應用程式的列印目標清單中的顯示名稱。The name that you want to appear in the list of print targets for an app.
參數Parameters 應用程式正確處理要求所需的任何參數。Any parameters that your application requires to properly handle the request.

範例Example

<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>

您可以在這裡尋找使用此延伸模組的範例Find a sample that uses this extension Here

與其他 Windows 應用程式共用字型Share fonts with other Windows applications

與其他 Windows 應用程式共用您的自訂字型。Share your custom fonts with other Windows applications.

注意

您必須先取得 Microsoft Store 小組的核准,才能向 Store 提交使用此延伸模組的應用程式。Before you can submit an app that uses this extension to the Store, you must first obtain approval from the Store team. 若要取得核准,請移至https://aka.ms/storesupport,按一下 [與我們連絡],然後選擇將應用程式提交到儀表板的相關選項。To obtain approval, go to https://aka.ms/storesupport, click Contact us, and choose options relevant to submitting apps to the dashboard. 此核准程序有助於確保應用程式安裝的字型與作業系統所安裝的字型之間沒有衝突。This approval process helps to ensure that there are no conflicts between fonts installed by your app and fonts that are installed with the OS. 如果未取得核准,則提交應用程式時,將會收到類似下列的錯誤:「套件接受度驗證錯誤:您無法搭配使用此帳戶與延伸模組 windows.sharedFonts。If you do not obtain approval, you will receive an error similar to the following when you submit your app: "Package acceptance validation error: You can't use extension windows.sharedFonts with this account. 如果要取得此延伸模組的使用權限,請連絡支援團隊。」Contact our support team if you'd like to request permissions to use this extension."

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

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

您可以在這裡找到完整的結構描述參考。Find the complete schema reference here.

名稱Name 描述Description
類別Category 一定是 windows.sharedFontsAlways windows.sharedFonts.
檔案File 包含您想要共用之字型的檔案。The file that contains the fonts that you want to share.

範例Example

<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 處理程序Start a Win32 process from a Universal Windows Platform (UWP) app

啟動完全信任的 Win32 處理程序。Start a Win32 process that runs in full-trust.

XML 命名空間XML namespaces

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

此延伸模組的元素和屬性Elements and attributes of this extension

<Extension Category="windows.fullTrustProcess" Executable="[executable file]">
  <FullTrustProcess>
    <ParameterGroup GroupId="[GroupID]" Parameters="[Parameters]"/>
  </FullTrustProcess>
</Extension>
名稱Name 描述Description
類別Category 一定是 windows.fullTrustProcessAlways windows.fullTrustProcess.
GroupIDGroupID 您要傳遞給可執行檔的一個可識別一組參數的字串。A string that identifies a set of parameters that you want to pass to the executable.
參數Parameters 您想要傳遞給可執行檔的參數。Parameters that you want to pass to the executable.

範例Example

<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 應用程式的元件能繼續在完全信任的情況下執行,此延伸模組非常有用。This extension might be useful if you want to create a Universal Windows Platform User interface that runs on all devices, but you want components of your Win32 application to continue running in full-trust.

您只需要為 Win32 應用程式建立 Windows 應用程式套件。Just create a Windows app package for your Win32 app. 然後,將此延伸模組新增至您 UWP app 的套件檔案。Then, add this extension to the package file of your UWP app. 此延伸模組表示您想要在 Windows 應用程式套件中啟動可執行檔。This extensions indicates that you want to start an executable file in the Windows app package. 若您想要讓您的 UWP app 和 Win32 應用程式互相通訊,您可以設定一或多個應用程式服務If you want to communicate between your UWP app and your Win32 app, you can set up one or more app services to do that. 您可以在這裡閱讀更多關於此案例的資訊。You can read more about this scenario here.

接下來的步驟Next steps

有任何問題嗎?Have questions? 請在 Stack Overflow 上發問。Ask us on Stack Overflow. 我們的團隊會監視這些標籤Our team monitors these tags. 您也可以在這裡發問。You can also ask us here.