public AppRegistration GetAppRegistration([NotNull] CommandMapper commandMapper, [NotNull] CapabilityList capabilities, ref string appName, ref string appDescription)
{
#region Sanity checks
if (capabilities == null) throw new ArgumentNullException(nameof(capabilities));
if (commandMapper == null) throw new ArgumentNullException(nameof(commandMapper));
#endregion
// Ambiguity warnings
if (RegisteredApplications.Length == 0)
return null;
if (RegisteredApplications.Length > 1)
Log.Warn(Resources.MultipleRegisteredAppsDetected);
// Get registry path pointer
string appRegName = RegisteredApplications[0];
var capabilitiesRegPath = RegistryUtils.GetString(@"HKEY_LOCAL_MACHINE\" + DesktopIntegration.Windows.AppRegistration.RegKeyMachineRegisteredApplications, appRegName);
if (string.IsNullOrEmpty(capabilitiesRegPath))
return null;
bool x64;
using (var capsKey = RegistryUtils.OpenHklmKey(capabilitiesRegPath, out x64))
{
if (string.IsNullOrEmpty(appName)) appName = capsKey.GetValue(DesktopIntegration.Windows.AppRegistration.RegValueAppName, "").ToString();
if (string.IsNullOrEmpty(appDescription)) appDescription = capsKey.GetValue(DesktopIntegration.Windows.AppRegistration.RegValueAppDescription, "").ToString();
CollectProtocolAssocsEx(capsKey, commandMapper, capabilities);
CollectFileAssocsEx(capsKey, capabilities);
// Note: Contenders for StartMenu entries are detected elsewhere
return new AppRegistration
{
ID = appRegName,
CapabilityRegPath = capabilitiesRegPath
};
}
}