public void Check_OfficeAndWps(){//是否安装Officebool isOfficeInstall = false;//是否安装Wpsbool isWpsInstall = false;//Office版本int officeVersion = 0;//32位RegistryKey localMachine32 = Registry.LocalMachine;RegistryKey akey03 = localMachine32.OpenSubKey(@"SOFTWARE\Microsoft\Office\11.0\Excel\InstallRoot\");RegistryKey akey07 = localMachine32.OpenSubKey(@"SOFTWARE\Microsoft\Office\12.0\Excel\InstallRoot\");RegistryKey akey10 = localMachine32.OpenSubKey(@"SOFTWARE\Microsoft\Office\14.0\Excel\InstallRoot\");RegistryKey akey13 = localMachine32.OpenSubKey(@"SOFTWARE\Microsoft\Office\15.0\Excel\InstallRoot\");RegistryKey akey16 = localMachine32.OpenSubKey(@"SOFTWARE\Microsoft\Office\16.0\Excel\InstallRoot\");RegistryKey akeywps = localMachine32.OpenSubKey(@"SOFTWARE\Kingsoft\Office\6.0\common\");//64位RegistryKey localMachine64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);if (akey03 == null)akey03 = localMachine64.OpenSubKey(@"SOFTWARE\Microsoft\Office\11.0\Excel\InstallRoot\");//查询if (akey07 == null)akey07 = localMachine64.OpenSubKey(@"SOFTWARE\Microsoft\Office\12.0\Excel\InstallRoot\");//查询if (akey10 == null)akey10 = localMachine64.OpenSubKey(@"SOFTWARE\Microsoft\Office\14.0\Excel\InstallRoot\");//查询if (akey13 == null)akey13 = localMachine64.OpenSubKey(@"SOFTWARE\Microsoft\Office\15.0\Excel\InstallRoot\");//查询if (akey16 == null)akey16 = localMachine64.OpenSubKey(@"SOFTWARE\Microsoft\Office\16.0\Excel\InstallRoot\");//查询if (akeywps == null)akeywps = localMachine64.OpenSubKey(@"SOFTWARE\Kingsoft\Office\6.0\common\");//查询wps//检查本机是否安装Officeif (akey03 != null){string office03 = akey03.GetValue("Path").ToString();if (File.Exists(office03 + "Excel.exe")){isOfficeInstall = true;officeVersion = ;}}//检查本机是否安装Officeif (akey07 != null){string office07 = akey07.GetValue("Path").ToString();if (File.Exists(office07 + "Excel.exe")){isOfficeInstall = true;officeVersion = ;}}//检查本机是否安装Officeif (akey10 != null){string office10 = akey10.GetValue("Path").ToString();if (File.Exists(office10 + "Excel.exe")){isOfficeInstall = true;officeVersion = ;}}//检查本机是否安装Officeif (akey13 != null){string office13 = akey13.GetValue("Path").ToString();if (File.Exists(office13 + "Excel.exe")){isOfficeInstall = true;officeVersion = ;}}//检查本机是否安装Office if (akey16 != null){string office16 = akey16.GetValue("Path").ToString();if (File.Exists(office16 + "Excel.exe")){isOfficeInstall = true;officeVersion = ;}}//检查本机是否安装wpsif (akeywps != null){string filewps = akeywps.GetValue("InstallRoot").ToString();if (File.Exists(filewps + @"\office6\et.exe"))isWpsInstall = true;}}
1200字范文,内容丰富有趣,写作的好帮手!