打开一个URL在默认浏览器在Windows 8桌面应用程序应用程序、浏览器、桌面、URL

2023-09-03 02:25:20 作者:潮轨迹 Tokyo

我使用 System.Diagnostics.Process.Start 从桌面应用程序启动默认的浏览器访问一个链接,如下图所示。这是一个用C#在.NET 4.0在Windows 8专业版RTM。

I am using System.Diagnostics.Process.Start from a desktop application to start the default browser to visit a link, as below. This is using C# with .NET 4.0 on Windows 8 Pro RTM.

System.Diagnostics.Process.Start(new ProcessStartInfo
{
    FileName = @"http://www.google.com",
    UseShellExecute = true
});

这在Windows 7下正常工作,但在Windows 8下的我越来越能在LINQPad再现异常。唯一的例外是:

This works fine under Windows 7, but under Windows 8 I am getting an exception that can be reproduced in LINQPad. The exceptions are:

UseShellExecute = TRUE 给Win32Exception:类没有注册。 UseShellExecute =假给Win32Exception:系统找不到指定的文件

UseShellExecute = true gives Win32Exception: Class not registered. UseShellExecute = false gives Win32Exception: The system cannot find the file specified.

如何在默认浏览器中打开一个网址?

How can open a URL in the default browser?

推荐答案

对于 WinRT的应用服务只能,它只是

Launcher.LaunchUriAsync(new Uri("http://www.google.com"));

看看here.