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