加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 没有Process.start打开网站

发布时间:2020-12-15 19:59:31 所属栏目:百科 来源:网络整理
导读:如何在没有Process.start(…)的情况下在浏览器中打开网站URL: System.Diagnostics.Process.Start(@"http://www.google.com"); 我无法在Windows服务中使用Process.Start(),我不知道为什么. 解决方法 请参阅问题“ How can a Windows service execute a GUI a
如何在没有Process.start(…)的情况下在浏览器中打开网站URL:

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

我无法在Windows服务中使用Process.Start(),我不知道为什么.

解决方法

请参阅问题“ How can a Windows service execute a GUI application?”的答案:

use WTSEnumerateSessions to find the right desktop,then CreateProcessAsUser to start the application on that desktop

还要注意你不应该这样做:)

如果你要做的只是启动一个URL,那么命令可能是

cmd.exe /c start http://example.com/

如果要禁止短暂显示的命令提示符窗口,可以将STARTUPINFO structure的wShowWindow字段设置为SW_HIDE,或者在.NET中将ProcessStartInfo.WindowStyle属性设置为ProcessWindowStyle.Hidden.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读