在WinRT中的默认Web浏览器中打开一个URL(Open an URL in the Defaul

2019-06-28 01:19发布

这个问题说明了一切。 基本上,我只是想知道在WinRT中这样做的选择:

Process.Start("http://www.google.com/");

Answer 1:

In WinRT, you can use Windows.System.Launcher.LaunchUriAsync to launch the default app associated with the specified URI. For a web link, the default browser would be used.

MSDN: Launcher.LaunchUriAsync(Uri) | launchUriAsync(Uri) method



Answer 2:

您可以使用Windows.System.Launcher启动文件和URL的...

  • Windows.System.Launcher.LaunchUriAsync(Uri)将推出一个给定的URI与默认应用程序。 如果它是一个链接它会与默认的Web浏览器中打开。 您可以使用file:///方案到本地文件系统上打开一个网络资源,而不是资源。

  • Windows.System.Launcher.LaunchFileAsync(IStorageFile)将推出针对给定文件的默认应用程序。

这两种方法都有类型的第二个可选参数Windows.System.LauncherOptions用来定制推出。



文章来源: Open an URL in the Default Web Browser in WinRT