打开一个URL在默认浏览器在Windows 8桌面应用程序 [英] Opening a URL in the default browser in a Windows 8 desktop application

查看:274
本文介绍了打开一个URL在默认浏览器在Windows 8桌面应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 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"));

看看<一href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.launcher.aspx">here.

这篇关于打开一个URL在默认浏览器在Windows 8桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆