public async Task<OfficeInstallation> CheckForOfficeInstallAsync()
{
var localInstall = new OfficeInstallation()
{
Installed = false
};
var officeRegKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office\ClickToRun\Configuration");
if (officeRegKey == null)
{
officeRegKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office\16.0\ClickToRun\Configuration");
if (officeRegKey == null)
{
officeRegKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office\15.0\ClickToRun\Configuration");
}
}
if (officeRegKey != null)
{
localInstall.Version = GetRegistryValue(officeRegKey, "VersionToReport");
if (string.IsNullOrEmpty(localInstall.Version)) return localInstall;
localInstall.Installed = true;
var currentBaseCDNUrl = GetRegistryValue(officeRegKey, "CDNBaseUrl");
var installFile = await GetOfficeInstallFileXml();
if (installFile == null) return localInstall;
var currentBranch = installFile.BaseURL.FirstOrDefault(b => b.URL.Equals(currentBaseCDNUrl) &&
!b.Branch.ToLower().Contains("business"));
if (currentBranch != null)
{
localInstall.Channel = currentBranch.Branch;
var latestVersion = await GetOfficeLatestVersion(currentBranch.Branch, OfficeEdition.Office32Bit);
localInstall.LatestVersion = latestVersion;
}
}
return localInstall;
}