Launcher.LaunchUriAsync メソッド

定義

オーバーロード

LaunchUriAsync(Uri, LauncherOptions, ValueSet)

指定したオプションと入力データを使用して、指定した URI の URI スキーム名に関連付けられている既定のアプリを起動します。

LaunchUriAsync(Uri, LauncherOptions)

指定したオプションを使用して、URI スキーム名に関連付けられている既定のアプリ、または指定した URI の ContentType で指定されたアプリを起動します。

LaunchUriAsync(Uri)

指定した URI の URI スキーム名に関連付けられている既定のアプリを起動します。

LaunchUriAsync(Uri, LauncherOptions, ValueSet)

指定したオプションと入力データを使用して、指定した URI の URI スキーム名に関連付けられている既定のアプリを起動します。

public:
 static IAsyncOperation<bool> ^ LaunchUriAsync(Uri ^ uri, LauncherOptions ^ options, ValueSet ^ inputData);
/// [Windows.Foundation.Metadata.Overload("LaunchUriWithDataAsync")]
 static IAsyncOperation<bool> LaunchUriAsync(Uri const& uri, LauncherOptions const& options, ValueSet const& inputData);
[Windows.Foundation.Metadata.Overload("LaunchUriWithDataAsync")]
public static IAsyncOperation<bool> LaunchUriAsync(System.Uri uri, LauncherOptions options, ValueSet inputData);
function launchUriAsync(uri, options, inputData)
Public Shared Function LaunchUriAsync (uri As Uri, options As LauncherOptions, inputData As ValueSet) As IAsyncOperation(Of Boolean)

パラメーター

uri
Uri Uri

URI。

options
LauncherOptions

アプリの起動オプション。

大事な

LaunchUriAsync メソッドのこのオーバーロードには、オプション パラメーターの TargetApplicationPackageFamilyName プロパティが必要な場合があります。

inputData
ValueSet

アプリの入力データ。

大事な

転送できるデータの量は、100 KB を超えてはなりません。

戻り値

URI スキーム 既定のアプリが起動された場合に true を返します。それ以外の場合は false

属性

注釈

Windows デスクトップ アプリケーションからこの API を呼び出す場合を除き、この API は ASTA スレッド (UI スレッドとも呼ばれます) 内から呼び出す必要があります。

この API は、Windows デスクトップ アプリケーションから呼び出すこともできます。

この API は、ユニバーサル Windows プラットフォーム (UWP) アプリでも Windows デスクトップ アプリケーションでも、スキームの既定のアプリを起動します。

こちらもご覧ください

適用対象

LaunchUriAsync(Uri, LauncherOptions)

指定したオプションを使用して、URI スキーム名に関連付けられている既定のアプリ、または指定した URI の ContentType で指定されたアプリを起動します。

public:
 static IAsyncOperation<bool> ^ LaunchUriAsync(Uri ^ uri, LauncherOptions ^ options);
/// [Windows.Foundation.Metadata.Overload("LaunchUriWithOptionsAsync")]
 static IAsyncOperation<bool> LaunchUriAsync(Uri const& uri, LauncherOptions const& options);
[Windows.Foundation.Metadata.Overload("LaunchUriWithOptionsAsync")]
public static IAsyncOperation<bool> LaunchUriAsync(System.Uri uri, LauncherOptions options);
function launchUriAsync(uri, options)
Public Shared Function LaunchUriAsync (uri As Uri, options As LauncherOptions) As IAsyncOperation(Of Boolean)

パラメーター

uri
Uri Uri

URI。

options
LauncherOptions

アプリの起動オプション。

戻り値

URI スキーム 既定のアプリが起動された場合に true を返します。それ以外の場合は false

属性

このサンプルでは、[LaunchUriAsync(Uri, LauncherOptions) を使用して、警告付きの URI を起動します。 TreatAsUntrusted プロパティは、システムが警告を表示する必要があることを示します。

// The URI to launch
string uriToLaunch = @"http://www.bing.com";
var uri = new Uri(uriToLaunch);

async void DefaultLaunch()
{
   // Set the option to show a warning
   var options = new Windows.System.LauncherOptions();
   options.TreatAsUntrusted = true;

   // Launch the URI with a warning prompt
   var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

   if (success)
   {
      // URI launched
   }
   else
   {
      // URI launch failed
   }
}
// The URI to launch.
Windows::Foundation::Uri m_uri{ L"http://www.bing.com" };

Windows::Foundation::IAsyncAction MainPage::DefaultLaunch()
{
    // Set the option to show a warning
    Windows::System::LauncherOptions launcherOptions;
    launcherOptions.TreatAsUntrusted(true);

    // Launch the URI.
    if (co_await Windows::System::Launcher::LaunchUriAsync(m_uri, launcherOptions))
    {
        // URI launched.
    }
    else
    {
        // URI launch failed.
    }
}
// The URI to launch
auto uri = ref new Windows::Foundation::Uri("http://www.bing.com");

void MainPage::DefaultLaunch()
{
   // Set the option to show a warning
   auto launchOptions = ref new Windows::System::LauncherOptions();
   launchOptions->TreatAsUntrusted = true;

   // Launch the URI with a warning prompt
   concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri, launchOptions));
   launchUriOperation.then([](bool success)
   {
      if (success)
      {
         // URI launched
      }
      else
      {
         // URI launch failed
      }
   });
}
' The URI to launch
Dim uri As New Uri("http://www.bing.com")

async Sub DefaultLaunch()

   ' Set the option to show a warning
   Dim options = Windows.System.LauncherOptions()
   options.TreatAsUntrusted = True

   ' Launch the URI with a warning prompt
   Dim success = await Windows.System.Launcher.LaunchUriAsync(uri, options)

   If success Then
      ' URI launched
   Else
      ' URI launch failed
   End If

End Sub

注釈

Windows デスクトップ アプリケーションからこの API を呼び出す場合を除き、この API は ASTA スレッド (UI スレッドとも呼ばれます) 内から呼び出す必要があります。

この API は、Windows デスクトップ アプリケーションから呼び出すこともできます。

この API は、ユニバーサル Windows プラットフォーム (UWP) アプリでも Windows デスクトップ アプリケーションでも、スキームの既定のアプリを起動します。

呼び出し元のアプリは、この API が呼び出されたときにユーザーに表示される必要があります。

Windows デスクトップ アプリケーションからこの API を呼び出す場合を除き、この API は ASTA スレッド (UI スレッドとも呼ばれます) 内から呼び出す必要があります。

イントラネット URI (ネットワークの場所を指す file:/// URI など) を起動するには、マニフェストで privateNetworkClientServer 機能を指定する必要があります。

このメソッドを使用して、ローカル ゾーンで URI を起動することはできません。 たとえば、アプリでは、file:/// プロトコルを使用してローカル コンピューター上のファイルにアクセスすることはできません。 代わりに、Storage API を使用してファイルにアクセスする必要があります。

コンテンツ タイプは、既定のアプリが選択された拡張機能からファイル拡張子を計算するために使用されます。 たとえば、"application/vnd.ms-word.document.12" のコンテンツ タイプの値が ".docx" にマップされ、".docx" の既定のアプリケーションが起動されます。 例えば:

// this specifies the file type, which is used to bind to Word. 
launcherOptions.ContentType = "application/vnd.ms-word.document.12"; 
// and then this launches the file using the application
Launcher.LaunchUriAsync("http://www.cloud.com/file.docx", options);

上記のいずれかの理由で起動が失敗した場合、API は成功し、非同期操作から FALSE を返します。

ユーザーが既定のアプリを起動する代わりにアプリを選択できるようにするには、LauncherOptions.DisplayApplicationPicker プロパティを設定します。

URI が安全でない可能性があることを示す警告を表示するには、LauncherOptions.TreatAsUntrusted プロパティを設定します。

URI は、関連付けられているアプリに渡されます。 関連付けられているアプリがデスクトップ アプリの場合、URI はシェル実行メカニズムを使用して渡されます。

こちらもご覧ください

適用対象

LaunchUriAsync(Uri)

指定した URI の URI スキーム名に関連付けられている既定のアプリを起動します。

public:
 static IAsyncOperation<bool> ^ LaunchUriAsync(Uri ^ uri);
/// [Windows.Foundation.Metadata.Overload("LaunchUriAsync")]
 static IAsyncOperation<bool> LaunchUriAsync(Uri const& uri);
[Windows.Foundation.Metadata.Overload("LaunchUriAsync")]
public static IAsyncOperation<bool> LaunchUriAsync(System.Uri uri);
function launchUriAsync(uri)
Public Shared Function LaunchUriAsync (uri As Uri) As IAsyncOperation(Of Boolean)

パラメーター

uri
Uri Uri

URI。

戻り値

URI スキーム 既定のアプリが起動された場合に true を返します。それ以外の場合は false

属性

この例では、LaunchUriAsync(Uri) を使用して URI を起動します。

// The URI to launch
string uriToLaunch = @"http://www.bing.com";

// Create a Uri object from a URI string 
var uri = new Uri(uriToLaunch);

// Launch the URI
async void DefaultLaunch()
{
   // Launch the URI
   var success = await Windows.System.Launcher.LaunchUriAsync(uri);

   if (success)
   {
      // URI launched
   }
   else
   {
      // URI launch failed
   }
}
// The URI to launch.
Windows::Foundation::Uri m_uri{ L"http://www.bing.com" };
...
Windows::Foundation::IAsyncAction MainPage::DefaultLaunch()
{
    // Launch the URI.
    if (co_await Windows::System::Launcher::LaunchUriAsync(m_uri))
    {
        // URI launched.
    }
    else
    {
        // URI launch failed.
    }
}
// The URI to launch
auto uri = ref new Windows::Foundation::Uri("http://www.bing.com");

void MainPage::DefaultLaunch()
{
   // Launch the URI
   concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri));
   launchUriOperation.then([](bool success)
   {
      if (success)
      {
         // URI launched
      }
      else
      {
         // URI launch failed
      }
   });
}
' The URI to launch
Dim uri As New Uri("http://www.bing.com")

async Sub DefaultLaunch()

   ' Launch the URI
   Dim success = await Windows.System.Launcher.LaunchUriAsync(uri)

   If success Then
      ' URI launched
   Else
      ' URI launch failed
   End If

End Sub

注釈

Windows デスクトップ アプリケーションからこの API を呼び出す場合を除き、この API は ASTA スレッド (UI スレッドとも呼ばれます) 内から呼び出す必要があります。

この API は、Windows デスクトップ アプリケーションから呼び出すこともできます。

この API は、ユニバーサル Windows プラットフォーム (UWP) アプリでも Windows デスクトップ アプリケーションでも、スキームの既定のアプリを起動します。

呼び出し元アプリは、API が呼び出されたときにユーザーに表示される必要があります。

イントラネット URI (ネットワークの場所を指す file:/// URI など) を起動するには、マニフェストで privateNetworkClientServer 機能を指定する必要があります。

このメソッドを使用して、ローカル ゾーンで URI を起動することはできません。 たとえば、アプリでは、file:/// プロトコルを使用してローカル コンピューター上のファイルにアクセスすることはできません。 代わりに、Storage API を使用してファイルにアクセスする必要があります。

上記のいずれかの理由で起動が失敗した場合、API は成功し、非同期操作から FALSE を返します。

ユーザーが既定のアプリを起動する代わりにアプリを選択できるようにするには、LauncherOptions.DisplayApplicationPicker プロパティを設定します。

URI が安全でない可能性があることを示す警告を表示するには、LauncherOptions.TreatAsUntrusted プロパティを設定します。

URI は、関連付けられているアプリに渡されます。 関連付けられているアプリがデスクトップ アプリの場合、URI はシェル実行メカニズムを使用して渡されます。

こちらもご覧ください

適用対象