欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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#程序设计有所帮助。