66 lines
2.8 KiB
C#
66 lines
2.8 KiB
C#
using Microsoft.Win32;
|
|
using System.Diagnostics;
|
|
|
|
namespace updater
|
|
{
|
|
public class OfficeStarter
|
|
{
|
|
public void StartWPS()
|
|
{
|
|
try
|
|
{
|
|
if (UpdateData.GetInstance().ShouldRebootWPS)
|
|
{
|
|
string text = RegistHelper.GetRegistData(Registry.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Kingsoft Office", "DisplayIcon");
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
{
|
|
text = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Kingsoft Office", "DisplayIcon");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(text))
|
|
{
|
|
text = text.Substring(0, text.LastIndexOf("WPS Office")) + "WPS Office\\ksolaunch.exe";
|
|
Process.Start(text);
|
|
}
|
|
}
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
public void StartMSOffice()
|
|
{
|
|
try
|
|
{
|
|
if (UpdateData.GetInstance().ShouldRebootMSOffice)
|
|
{
|
|
string allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\16.0\\Word\\InstallRoot", "Path");
|
|
//检查2016 / 2019 / 365版本路径
|
|
if (string.IsNullOrWhiteSpace(allRegistData))
|
|
{
|
|
allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\15.0\\Common\\InstallRoot", "Path");
|
|
// 检查2013版本路径
|
|
}
|
|
if (string.IsNullOrWhiteSpace(allRegistData))
|
|
{
|
|
allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\14.0\\Common\\InstallRoot", "Path");
|
|
// 检查2010版本路径
|
|
}
|
|
if (string.IsNullOrWhiteSpace(allRegistData))
|
|
{
|
|
allRegistData = RegistHelper.GetAllRegistData(RegistryHive.LocalMachine, "SOFTWARE\\Microsoft\\Office\\12.0\\Common\\InstallRoot", "Path");
|
|
//检查2007版本路径
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(allRegistData))
|
|
{
|
|
allRegistData += "WINWORD.exe";
|
|
//MSOffice启动路径
|
|
Process.Start(allRegistData);
|
|
}
|
|
// 未能从注册表找到MS Office 安装路径
|
|
// 没有找到 直接不处理了
|
|
}
|
|
}
|
|
catch{}
|
|
}
|
|
}
|
|
}
|