AppListEntry.LaunchForUserAsync(User) メソッド

定義

指定したユーザーのコンテキスト内で、この AppListEntry に関連付けられているアプリを起動します。

public:
 virtual IAsyncOperation<bool> ^ LaunchForUserAsync(User ^ user) = LaunchForUserAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<bool> LaunchForUserAsync(User const& user);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<bool> LaunchForUserAsync(User user);
function launchForUserAsync(user)
Public Function LaunchForUserAsync (user As User) As IAsyncOperation(Of Boolean)

パラメーター

user
User

アプリを起動する必要があるユーザー コンテキスト。

戻り値

起動が成功した場合は true を返します。それ以外の場合は false

属性

Windows の要件

デバイス ファミリ
Windows 10, version 1803 (10.0.17134.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v6.0 で導入)

public async void LaunchButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
    // The active User is retrieved from the initial activation args and validated against list of active users
    User user = this.GetAppActiveUser();
    PackageManager pm = new PackageManager();
    // The App Family Name is stored as part of the Product Display Page
    Package p = pm.FindPackage(this.GetFocusedAppFamilyName());
    IReadOnlyList<AppListEntry> entries = await p.GetAppListEntriesAsync();

    //This assumes the first app in the package should be launched, if there is one in the package
    if (entries.Count > 0)
    {
        await entries[0].LaunchForUserAsync(user);
    }
}

注釈

これはマルチユーザー対応 (MUA) API であり、MUA であることを宣言するアプリでのみ使用でき、MUA アプリをサポートするデバイスでのみ使用できます。 アプリは、指定したユーザーがアプリ一覧のエントリをクリックした場合と同じ方法で起動されます。 ユーザーは、イベント引数を使用して起動されたアプリに渡されます。 をusernullすと、例外が発生します。

MUA アプリは、既定のユーザー コンテキストで起動します。 イベント引数を使用してアクティブ化されたアプリケーションに渡される値は user 、アプリが代理でアクティブ化されているユーザーを示します。 シングル ユーザー対応アプリは、この API に渡される値の user コンテキストで起動します。

適用対象

こちらもご覧ください