Open an URL in the Default Web Browser in WinRT

2019-01-25 05:50发布

The question says it all. Basically, I just want to know the alternative for this in WinRT:

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

2条回答
爷、活的狠高调
2楼-- · 2019-01-25 06:26

You can use Windows.System.Launcher to launch files and URL's...

  • Windows.System.Launcher.LaunchUriAsync(Uri) will launch a given Uri with the default application. If it's a link it will open with default web browser. You can use file:/// scheme to open an network resource, but not resources on the local file system.

  • Windows.System.Launcher.LaunchFileAsync(IStorageFile) will launch the default application for the given file.

Both that methods has an optional second parameter of type Windows.System.LauncherOptions that customizes the launch.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-25 06:45

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

查看更多
登录 后发表回答