c# 通过查看注册表的方式来判断电脑安装office的版本
2017-05-28 10:56
656 查看
private void button3_Click(object sender, EventArgs e)
{
if (panduan())//自定义方法
{
MessageBox.Show("本机已安装office2010");
}
else
{
MessageBox.Show("请先安装wps 2012", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
public bool panduan()
{
bool ifused = false;
RegistryKey rk = Registry.LocalMachine;
RegistryKey office2010 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\14.0\\Word\\InstallRoot\\");
//office 2003
RegistryKey office2003 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\11.0\\Word\\InstallRoot\\");
//office2007
RegistryKey office2007 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\12.0\\Word\\InstallRoot\\");
//office 97
RegistryKey office97 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\8.0\\Word\\InstallRoot\\");
//office 2000
RegistryKey office2000 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\9.0\\Word\\InstallRoot\\");
//office xp
RegistryKey officexp = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\10.0\\Word\\InstallRoot\\");
//检查本机是否安装Office2010
if (office2010 != null)
{
string file03 = office2010.GetValue("Path").ToString();
if (File.Exists(file03 + "Excel.exe"))
{
istrue= true;
}
}
if (officexp != null)
{
string filexp = officexp.GetValue("Path").ToString();
if (File.Exists(filexp + "Excel.exe"))
{
istrue= false;
}
}
if (office2000 != null)
{
string file2000 = officexp.GetValue("Path").ToString();
if (File.Exists(file2000 + "Excel.exe"))
{
istrue= false;
}
}
if (office97 != null)
{
string file97 = officexp.GetValue("Path").ToString();
if (File.Exists(file97 + "Excel.exe"))
{
istrue= false;
}
}
if (office2007 != null)
{
string file2007 = officexp.GetValue("Path").ToString();
if (File.Exists(file2007 + "Excel.exe"))
{
istrue= false;
}
}
return istrue;
}
private void button3_Click(object sender, EventArgs e)
{
if (panduan())//自定义方法
{
MessageBox.Show("本机已安装office2010");
}
else
{
MessageBox.Show("请先安装wps 2012", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
public bool panduan()
{
bool ifused = false;
RegistryKey rk = Registry.LocalMachine;
RegistryKey office2010 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\14.0\\Word\\InstallRoot\\");
//office 2003
RegistryKey office2003 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\11.0\\Word\\InstallRoot\\");
//office2007
RegistryKey office2007 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\12.0\\Word\\InstallRoot\\");
//office 97
RegistryKey office97 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\8.0\\Word\\InstallRoot\\");
//office 2000
RegistryKey office2000 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\9.0\\Word\\InstallRoot\\");
//office xp
RegistryKey officexp = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\10.0\\Word\\InstallRoot\\");
//检查本机是否安装Office2010
if (office2010 != null)
{
string file03 = office2010.GetValue("Path").ToString();
if (File.Exists(file03 + "Excel.exe"))
{
istrue= true;
}
}
if (officexp != null)
{
string filexp = officexp.GetValue("Path").ToString();
if (File.Exists(filexp + "Excel.exe"))
{
istrue= false;
}
}
if (office2000 != null)
{
string file2000 = officexp.GetValue("Path").ToString();
if (File.Exists(file2000 + "Excel.exe"))
{
istrue= false;
}
}
if (office97 != null)
{
string file97 = officexp.GetValue("Path").ToString();
if (File.Exists(file97 + "Excel.exe"))
{
istrue= false;
}
}
if (office2007 != null)
{
string file2007 = officexp.GetValue("Path").ToString();
if (File.Exists(file2007 + "Excel.exe"))
{
istrue= false;
}
}
return istrue;
}
相关文章推荐
- c# 通过查看注册表的方式来判断电脑安装office的版本
- C#通过操作注册表检测office版本
- C#通过注册表检测是否安装Office和QQ等软件
- 通过注册表查看已安装 .NetFramework 版本
- c#让一个程序开机启动【通过改注册表的方式】
- 通过注册表来检测是否安装Office
- 检测Office是否安装以及获取安装 路径 及安装版本 QQ,迅雷,旺旺 C#代码
- 安装office版本出现注册表1403等问题无法安装的完美解决
- Windows查看电脑上安装的.Net Framework版本的五种方法(转)
- 安装 64 位版本的 Office 2010 后,无法查看数据表视图中的列表
- win7系统通过查看电脑的开机历史判断是否被他人使用
- 安装 64 位版本的 Office 2010 后,无法查看数据表视图中的列表
- asp.net中通过注册表来检测是否安装Office(迅雷/QQ是否已安装)
- 通过注册表检查本地office excel版本
- 安装office时,提示某项注册表无法写入,请查看是否有管理员权限
- C# 通过分析netstat -an所得信息 查看本机所监听的端口 及判断某端口是否可用
- C# 判断本机是否安装Excel及多版本安装?获取Excel进程信息和打开Excel应用软件
- 通过注册表查看 .NET Framework的版本信息
- 导出Excel之判断电脑中office的版本
- 如何快速配好java环境变量和查看电脑上安装JDK的版本位数