Launcher.LaunchUriAsync Méthode

Définition

Surcharges

LaunchUriAsync(Uri, LauncherOptions, ValueSet)

Démarre l’application par défaut associée au nom du schéma d’URI pour l’URI spécifié, à l’aide des options et des données d’entrée spécifiées.

LaunchUriAsync(Uri, LauncherOptions)

Démarre l’application par défaut associée au nom du schéma d’URI ou à celui spécifié par le ContentType pour l’URI spécifié, à l’aide des options spécifiées.

LaunchUriAsync(Uri)

Démarre l’application par défaut associée au nom du schéma d’URI pour l’URI spécifié.

LaunchUriAsync(Uri, LauncherOptions, ValueSet)

Démarre l’application par défaut associée au nom du schéma d’URI pour l’URI spécifié, à l’aide des options et des données d’entrée spécifiées.

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)

Paramètres

uri
Uri Uri

URI.

options
LauncherOptions

Options de lancement de l’application.

inputData
ValueSet

Données d’entrée pour l’application.

Important

La quantité de données pouvant être transférées ne doit pas dépasser 100 Ko.

Retours

Retourne true si l’application par défaut pour le schéma d’URI a été lancée ; false dans le cas contraire.

Attributs

Remarques

Sauf si vous appelez cette API à partir d’une application de bureau Windows, cette API doit être appelée à partir d’un thread ASTA (également appelé thread d’interface utilisateur).

Cette API peut également être appelée à partir d’une application de bureau Windows.

Cette API lance l’application par défaut pour le schéma, qu’il s’agisse d’une application plateforme Windows universelle (UWP) ou d’une application de bureau Windows.

Voir aussi

S’applique à

LaunchUriAsync(Uri, LauncherOptions)

Démarre l’application par défaut associée au nom du schéma d’URI ou à celui spécifié par le ContentType pour l’URI spécifié, à l’aide des options spécifiées.

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)

Paramètres

uri
Uri Uri

URI.

options
LauncherOptions

Options de lancement de l’application.

Retours

Retourne true si l’application par défaut pour le schéma d’URI a été lancée ; false dans le cas contraire.

Attributs

Exemples

Cet exemple utilise [LaunchUriAsync(Uri, LauncherOptions) pour lancer un URI avec un avertissement. La propriété TreatAsUntrusted indique que le système doit afficher un avertissement.

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

Remarques

Sauf si vous appelez cette API à partir d’une application de bureau Windows, cette API doit être appelée à partir d’un thread ASTA (également appelé thread d’interface utilisateur).

Cette API peut également être appelée à partir d’une application de bureau Windows.

Cette API lance l’application par défaut pour le schéma, qu’il s’agisse d’une application plateforme Windows universelle (UWP) ou d’une application de bureau Windows.

L’application appelante doit être visible par l’utilisateur lorsque cette API est appelée.

Sauf si vous appelez cette API à partir d’une application de bureau Windows, cette API doit être appelée à partir d’un thread ASTA (également appelé thread d’interface utilisateur).

Vous devez spécifier la fonctionnalité privateNetworkClientServer dans le manifeste pour lancer des URI intranet, par exemple un URI file:/// pointant vers un emplacement réseau.

Vous ne pouvez pas utiliser cette méthode pour lancer un URI dans la zone locale. Par exemple, les applications ne peuvent pas utiliser le protocole file:/// pour accéder aux fichiers sur l’ordinateur local. Au lieu de cela, vous devez utiliser les API de stockage pour accéder aux fichiers.

Le type de contenu est utilisé pour calculer une extension de fichier. À partir de l’extension, l’application par défaut est choisie. Par exemple, une valeur de type de contenu « « application/vnd.ms-word.document.12 » est mappée à « .docx », puis l’application par défaut pour « .docx » est lancée. Par exemple :

// 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);

Lorsque le lancement échoue pour l’une des raisons ci-dessus, l’API réussit et retourne FALSE à partir de son opération asynchrone.

Pour permettre à l’utilisateur de choisir une application au lieu de lancer l’application par défaut, définissez la propriété LauncherOptions.DisplayApplicationPicker .

Pour afficher un avertissement indiquant que l’URI est potentiellement dangereux, définissez la propriété LauncherOptions.TreatAsUntrusted .

L’URI est passé à l’application associée. Si l’application associée est une application de bureau, l’URI est passé à l’aide des mécanismes d’exécution de l’interpréteur de commandes.

Voir aussi

S’applique à

LaunchUriAsync(Uri)

Démarre l’application par défaut associée au nom du schéma d’URI pour l’URI spécifié.

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)

Paramètres

uri
Uri Uri

URI.

Retours

Retourne true si l’application par défaut pour le schéma d’URI a été lancée ; false dans le cas contraire.

Attributs

Exemples

Cet exemple utilise LaunchUriAsync(Uri) pour lancer un 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

Remarques

Sauf si vous appelez cette API à partir d’une application de bureau Windows, cette API doit être appelée à partir d’un thread ASTA (également appelé thread d’interface utilisateur).

Cette API peut également être appelée à partir d’une application de bureau Windows.

Cette API lance l’application par défaut pour le schéma, qu’il s’agisse d’une application plateforme Windows universelle (UWP) ou d’une application de bureau Windows.

L’application appelante doit être visible par l’utilisateur lorsque l’API est appelée.

Vous devez spécifier la fonctionnalité privateNetworkClientServer dans le manifeste pour lancer des URI intranet, par exemple un URI file:/// pointant vers un emplacement réseau.

Vous ne pouvez pas utiliser cette méthode pour lancer un URI dans la zone locale. Par exemple, les applications ne peuvent pas utiliser le protocole file:/// pour accéder aux fichiers sur l’ordinateur local. Au lieu de cela, vous devez utiliser les API de stockage pour accéder aux fichiers.

Lorsque le lancement échoue pour l’une des raisons ci-dessus, l’API réussit et retourne FALSE à partir de son opération asynchrone.

Pour permettre à l’utilisateur de choisir une application au lieu de lancer l’application par défaut, définissez la propriété LauncherOptions.DisplayApplicationPicker .

Pour afficher un avertissement indiquant que l’URI est potentiellement dangereux, définissez la propriété LauncherOptions.TreatAsUntrusted .

L’URI est passé à l’application associée. Si l’application associée est une application de bureau, l’URI est passé à l’aide des mécanismes d’exécution de l’interpréteur de commandes.

Voir aussi

S’applique à