RegistryKey rk = Registry.LocalMachine;
RegistryKey key03 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\11.0\\Word\\InstallRoot\\");
RegistryKey key07 = rk.OpenSubKey(@"SOFTWARE\\Microsoft\\Office\\12.0\\Word\\InstallRoot\\");
//检查本机是否安装Office2003
if (key03 != null)
{
//读取offcie03的版本
string file03 = key03.GetValue("Path").ToString();
if (File.Exists(file03 + "EXCEL.exe"))
{
_OfficeVersion = "11.0";
}
}
//检查本机是否安装Office2007
if (key07 != null)
{
//读取offcie07的版本
string file07 = key07.GetValue("Path").ToString();
if (File.Exists(file07 + "EXCEL.exe"))
{
_OfficeVersion = "12.0";
}
}