wps出现安装installer_判断本机是否安装Microsoft Office或者wps
網(wǎng)上通用的方法是Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Kingsoft\Office\6.0\common")中獲取WPS安裝信息,由于本機是win7 64位系統(tǒng),實際安裝后注冊表寫入路徑為SOFTWARE\Wow6432Node\Kingsoft\Office\6.0\common,本機安裝的是WPS2013,發(fā)現(xiàn)實際上common節(jié)點下并沒有可供判斷的值,并沒有存儲WPS安裝路徑,經(jīng)測試,發(fā)現(xiàn)安裝路徑實際寫入路徑為HKEY_CURRENT_USER\Software\Kingsoft\Office\6.0\common,因此此處用這個路徑進行判斷,估計是WPS版本問題,此方法后期需要在實際應(yīng)用中驗證
判斷本機是否安裝wps方法:
private boolisWpsInstall()
{bool isInstall = false;
RegistryKey wpsLibrary= Registry.CurrentUser.OpenSubKey(@"Software\Kingsoft\Office\6.0\common");if (wpsLibrary != null)
{if (wpsLibrary.GetValue("InstallRoot") != null)
{string strpath = wpsLibrary.GetValue("InstallRoot").ToString();if (File.Exists(strpath + @"\office6\wps.exe"))
{
isInstall= true;
}
}
}returnisInstall;
}
由于本機是win7 64位系統(tǒng),office 2007安裝后,注冊表寫的位置是在SOFTWARE\Wow6432Node\Microsoft節(jié)點之下因此寫了officeLibrary1進行判斷,考慮到32位系統(tǒng),注冊表的位置直接在SOFTWARE\Microsoft節(jié)點之下,因此增加了officeLibrary0進行判斷,滿足任一種,則判斷位office已安裝,但是實際測試的時候,發(fā)現(xiàn)本機win7 64位下也可以用officeLibrary0取到值,但實際本機的SOFTWARE\Microsoft\Office節(jié)點下并沒有對應(yīng)的節(jié)點,因此,實際上用officeLibrary0進行判斷即可,具體原因未知
判斷本機是否安裝office代碼:
參數(shù)officever輸入要驗證的office版本,例如office2007為12.0
private bool isOfficeInstall(stringofficever)
{bool isInstall = false;
RegistryKey officeLibrary0= Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office\" + officever + @"\Common\InstallRoot");
RegistryKey officeLibrary1= Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Office\" + officever + @"\Common\InstallRoot");if (officeLibrary0 != null)
{if (officeLibrary0.GetValue("Path") != null)
{string strpath = officeLibrary0.GetValue("Path").ToString();if (File.Exists(strpath + "WINWORD.EXE"))
{
isInstall= true;
}
}
}if (officeLibrary1 != null)
{if (officeLibrary1.GetValue("Path") != null)
{string strpath = officeLibrary1.GetValue("Path").ToString();if (File.Exists(strpath + "WINWORD.EXE"))
{
isInstall= true;
}
}
}returnisInstall;
}
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的wps出现安装installer_判断本机是否安装Microsoft Office或者wps的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是热钱 又称投机性短期资本
- 下一篇: append 降低数组位数_4.有序数组