Launcher 類別

定義

啟動與指定檔案或 URI 相關聯的預設應用程式。

public ref class Launcher abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
class Launcher final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Launcher final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
public static class Launcher
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class Launcher
Public Class Launcher
繼承
Object Platform::Object IInspectable Launcher
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

啟動應用程式套件中包含的檔案

請參閱 LaunchFileAsync (IStorageFile) 主題中的程式碼範例。

啟動 URI

請參閱 LaunchUriAsync (Uri) 主題中的程式碼範例。

以警告對話方塊啟動

此範例會呼叫 launchUriAsync (Uri、LauncherOptions) 以警告啟動 URI。 使用 treatAsUntrusted 屬性來指出系統應該顯示警告。

注意

如果是使用 JavaScript 的 Windows 應用程式,如果已設定 treatAsUntrusted屬性,而且您使用錨點元素啟動 URI,請在事件處理常式中呼叫preventDefault

function linkClickHandler(eventInfo) {
    var link = eventInfo.target;
    if (eventInfo.srcElement && (
        (eventInfo.type === "click") ||
        (eventInfo.type === "keydown" && (
        eventInfo.keyCode === WinJS.Utilities.Key.enter ||
        eventInfo.keyCode === WinJS.Utilities.Key.space)))) {
        eventInfo.preventDefault();
        if (link.href.indexOf("ms-appx") > -1) {
            WinJS.Navigation.navigate(link.href);
        }
        else if (link.href.indexOf("http") > -1) {
            // Create a Uri object from a URI string 
            var uri = new Windows.Foundation.Uri(link.href);
            var options = new Windows.System.LauncherOptions();
            // Launch the URI with a warning prompt
            options.treatAsUntrusted = true;
            // Launch the URI
            Windows.System.Launcher.launchUriAsync(uri, options).then(
                function (success) {
                    if (success) {
                        // URI launched
                    } else {
                        // URI launch failed
                    }
                });
        }
    }
}

備註

注意

這個類別不是敏捷式的,這表示您需要考慮其執行緒模型和封送處理行為。 如需詳細資訊,請參閱執行緒和封送處理 (C++/CX) 在多執行緒環境中使用 Windows 執行階段 物件 (.NET)

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1607 14393 FindAppUriHandlersAsync
1607 14393 LaunchUriForResultsForUserAsync (User,Uri,LauncherOptions)
1607 14393 LaunchUriForResultsForUserAsync (User,Uri,LauncherOptions,ValueSet)
1607 14393 LaunchUriForUserAsync (User,Uri)
1607 14393 LaunchUriForUserAsync (User,Uri,LauncherOptions)
1607 14393 LaunchUriForUserAsync (User,Uri,LauncherOptions,ValueSet)
1607 14393 QueryAppUriSupportAsync (Uri)
1607 14393 QueryAppUriSupportAsync (Uri,String)
1809 17763 LaunchFolderPathAsync (String)
1809 17763 LaunchFolderPathAsync (String,FolderLauncherOptions)
1809 17763 LaunchFolderPathForUserAsync (User,String)
1809 17763 LaunchFolderPathForUserAsync (User,String,FolderLauncherOptions)

方法

FindAppUriHandlersAsync(Uri)

列舉裝置上的統一資源識別項 (URI) 處理常式。

FindFileHandlersAsync(String)

列舉裝置上的檔案處理常式。

FindUriSchemeHandlersAsync(String)

列舉裝置上的配置處理常式。

FindUriSchemeHandlersAsync(String, LaunchQuerySupportType)

列舉裝置上的配置處理常式。

LaunchFileAsync(IStorageFile)

啟動與指定檔案相關聯的預設應用程式。

LaunchFileAsync(IStorageFile, LauncherOptions)

使用指定的選項,啟動與指定檔案相關聯的預設應用程式。

LaunchFolderAsync(IStorageFolder)

啟動檔案總管並顯示指定資料夾的內容。

LaunchFolderAsync(IStorageFolder, FolderLauncherOptions)

使用指定的選項啟動檔案總管,並顯示指定資料夾的內容。

LaunchFolderPathAsync(String)

啟動檔案總管並顯示指定資料夾的內容。

LaunchFolderPathAsync(String, FolderLauncherOptions)

使用指定的選項啟動檔案總管,並顯示指定資料夾的內容。

LaunchFolderPathForUserAsync(User, String)

啟動檔案總管並顯示指定資料夾的內容。

LaunchFolderPathForUserAsync(User, String, FolderLauncherOptions)

使用指定的選項啟動檔案總管,並顯示指定資料夾的內容。

LaunchUriAsync(Uri)

啟動與指定 URI 之 URI 配置名稱相關聯的預設應用程式。

LaunchUriAsync(Uri, LauncherOptions)

使用指定的選項,啟動與 URI 配置名稱相關聯的預設應用程式,或由 ContentType 為指定 URI 所指定的應用程式。

LaunchUriAsync(Uri, LauncherOptions, ValueSet)

使用指定的選項和輸入資料,啟動與指定 URI 配置名稱相關聯的預設應用程式。

LaunchUriForResultsAsync(Uri, LauncherOptions)

使用指定的選項,以非同步方式啟動與指定 URI 配置名稱相關聯的預設應用程式。

LaunchUriForResultsAsync(Uri, LauncherOptions, ValueSet)

使用指定的選項和輸入資料,以非同步方式啟動與指定 URI 配置名稱相關聯的預設應用程式。

LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions)

使用指定的選項,以非同步方式啟動與指定 URI 配置名稱相關聯的預設應用程式,並提供特定的 User 作為內容。

LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions, ValueSet)

使用指定的選項和輸入資料,以非同步方式啟動與指定 URI 配置名稱相關聯的預設應用程式,並提供特定 使用者 做為內容。

LaunchUriForUserAsync(User, Uri)

啟動與指定 URI 之 URI 配置名稱相關聯的預設多使用者應用程式,並提供特定 使用者 做為內容。

LaunchUriForUserAsync(User, Uri, LauncherOptions)

使用指定的選項啟動與指定 URI 配置名稱相關聯的預設多使用者應用程式,並提供特定 使用者 做為內容。

LaunchUriForUserAsync(User, Uri, LauncherOptions, ValueSet)

使用指定的選項和輸入資料,啟動與指定 URI 配置名稱相關聯的預設多使用者應用程式,並提供特定 使用者 做為內容。

QueryAppUriSupportAsync(Uri)

以非同步方式查詢是否有應用程式可以處理指定的 URI。

QueryAppUriSupportAsync(Uri, String)

以非同步方式查詢指定的應用程式是否可以處理指定的 URI。

QueryFileSupportAsync(StorageFile)

以非同步方式查詢是否可以為指定的檔案啟用應用程式。

QueryFileSupportAsync(StorageFile, String)

以非同步方式查詢是否可針對指定的檔案啟用具有指定套件名稱的應用程式。

QueryUriSupportAsync(Uri, LaunchQuerySupportType)

以非同步方式查詢是否可以針對指定的 URI 和啟動類型啟用應用程式。

QueryUriSupportAsync(Uri, LaunchQuerySupportType, String)

以非同步方式查詢是否可以針對指定的 URI、啟動類型和套件名稱啟用應用程式。

適用於

另請參閱