C#使用默认浏览器打开网页的方法
程序员文章站
2023-08-17 19:44:06
本文实例讲述了c#使用默认浏览器打开网页的方法。分享给大家供大家参考。具体实现方法如下:
public static bool openbrowser(strin...
本文实例讲述了c#使用默认浏览器打开网页的方法。分享给大家供大家参考。具体实现方法如下:
public static bool openbrowser(string url) { registrykey key = registry.classesroot.opensubkey(@"http\shell\open\command\"); string s = key.getvalue("").tostring(); string browserpath = null; if (s.startswith("\"")) { browserpath = s.substring(1, s.indexof('\"', 1) - 1); } else { browserpath = s.substring(0, s.indexof(" ")); } return system.diagnostics.process.start(browserpath, url)!=null; }
希望本文所述对大家的c#程序设计有所帮助。
上一篇: MySQL数据表合并去重的简单实现方法
下一篇: 挑战最棒的留言本的源码(四)