C#如何获取当前电脑的IE浏览器与默认浏览器的完整路径
1个回答
展开全部
添加命名空间:
using Microsoft.Win32;
获取路径的代码
------------------------------------------------------
/// <summary>
/// 获取默认浏览器的路径
/// </summary>
/// <returns></returns>
static String DefaultWebBrowserFilePath()
{
RegistryKey key = Registry.ClassesRoot.OpenSubKey("http\\shell\\open\\command", false);
String path = key.GetValue("").ToString();
if (path.Contains("\""))
{
path = path.TrimStart('"');
path = path.Substring(0, path.IndexOf('"'));
}
key.Close();
return path;
}
/// <summary>
/// 获取IE浏览器的路径
/// </summary>
/// <returns></returns>
static String IEFilePath()
{
return System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Internet Explorer\\iexplore.exe");
}
using Microsoft.Win32;
获取路径的代码
------------------------------------------------------
/// <summary>
/// 获取默认浏览器的路径
/// </summary>
/// <returns></returns>
static String DefaultWebBrowserFilePath()
{
RegistryKey key = Registry.ClassesRoot.OpenSubKey("http\\shell\\open\\command", false);
String path = key.GetValue("").ToString();
if (path.Contains("\""))
{
path = path.TrimStart('"');
path = path.Substring(0, path.IndexOf('"'));
}
key.Close();
return path;
}
/// <summary>
/// 获取IE浏览器的路径
/// </summary>
/// <returns></returns>
static String IEFilePath()
{
return System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Internet Explorer\\iexplore.exe");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询