mirror of
https://github.com/greenshot/greenshot
synced 2025-08-24 07:06:23 -07:00
Fix of BUG2951
This commit is contained in:
parent
2b5e45e33e
commit
fb9a0c2a24
6 changed files with 91 additions and 7 deletions
|
@ -40,13 +40,87 @@ namespace Greenshot.Base.Core
|
||||||
private static readonly ILog Log = LogManager.GetLogger(typeof(PluginUtils));
|
private static readonly ILog Log = LogManager.GetLogger(typeof(PluginUtils));
|
||||||
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private const string PathKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
|
private const string PathKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
|
||||||
|
private static string[] strRootKeys = { @"SOFTWARE\Microsoft\Office", @"SOFTWARE\WOW6432Node\Microsoft\Office" };
|
||||||
private static readonly IDictionary<string, Image> ExeIconCache = new Dictionary<string, Image>();
|
private static readonly IDictionary<string, Image> ExeIconCache = new Dictionary<string, Image>();
|
||||||
|
|
||||||
static PluginUtils()
|
static PluginUtils()
|
||||||
{
|
{
|
||||||
CoreConfig.PropertyChanged += OnIconSizeChanged;
|
CoreConfig.PropertyChanged += OnIconSizeChanged;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Clear icon cache
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
public static string GetOfficeExePath(string keyname, string returnValue)
|
||||||
|
{
|
||||||
|
string strKeyName = "";
|
||||||
|
|
||||||
|
switch (keyname)
|
||||||
|
{
|
||||||
|
case "WINWORD.EXE":
|
||||||
|
strKeyName = "Word";
|
||||||
|
break;
|
||||||
|
case "EXCEL.EXE":
|
||||||
|
strKeyName = "Excel";
|
||||||
|
break;
|
||||||
|
case "MSACCESS.EXE":
|
||||||
|
strKeyName = "Access";
|
||||||
|
break;
|
||||||
|
case "POWERPNT.EXE":
|
||||||
|
strKeyName = "PowerPoint";
|
||||||
|
break;
|
||||||
|
case "OUTLOOK.EXE":
|
||||||
|
strKeyName = "Outlook";
|
||||||
|
break;
|
||||||
|
case "ONENOTE.EXE":
|
||||||
|
strKeyName = "OneNote";
|
||||||
|
break;
|
||||||
|
case "MSPUB.EXE":
|
||||||
|
strKeyName = "Publisher";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strKeyName = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
RegistryKey rootKey = null;
|
||||||
|
RegistryKey officeKey;
|
||||||
|
RegistryKey programKey;
|
||||||
|
RegistryKey installRootKey;
|
||||||
|
|
||||||
|
foreach (string strRootKey in strRootKeys)
|
||||||
|
{
|
||||||
|
rootKey = Registry.LocalMachine.OpenSubKey(strRootKey);
|
||||||
|
|
||||||
|
if (rootKey != null)
|
||||||
|
{
|
||||||
|
string[] officeVersions = rootKey.GetSubKeyNames();
|
||||||
|
if (officeVersions != null)
|
||||||
|
{
|
||||||
|
officeVersions = Array.FindAll(officeVersions, r => r.Contains("."));
|
||||||
|
Array.Reverse(officeVersions);
|
||||||
|
// string latestOfficeVersion = officeVersions.Where(r => r.Contains(".")).Max();
|
||||||
|
|
||||||
|
foreach (string officeVersion in officeVersions)
|
||||||
|
{
|
||||||
|
officeKey = Registry.LocalMachine.OpenSubKey(strRootKey + "\\" + officeVersion);
|
||||||
|
|
||||||
|
if (officeKey != null)
|
||||||
|
{
|
||||||
|
programKey = officeKey.OpenSubKey(strKeyName);
|
||||||
|
if (programKey != null)
|
||||||
|
{
|
||||||
|
installRootKey = programKey.OpenSubKey("InstallRoot");
|
||||||
|
if (installRootKey != null)
|
||||||
|
return installRootKey.GetValue(returnValue).ToString() + "\\" + keyname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clear icon cache
|
/// Clear icon cache
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -84,7 +158,7 @@ namespace Greenshot.Base.Core
|
||||||
if (key != null)
|
if (key != null)
|
||||||
{
|
{
|
||||||
// "" is the default key, which should point to the requested location
|
// "" is the default key, which should point to the requested location
|
||||||
return (string) key.GetValue(string.Empty);
|
return (string)key.GetValue(string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,10 @@ namespace Greenshot.Plugin.Office.Destinations
|
||||||
|
|
||||||
static ExcelDestination()
|
static ExcelDestination()
|
||||||
{
|
{
|
||||||
ExePath = PluginUtils.GetExePath("EXCEL.EXE");
|
ExePath = PluginUtils.GetOfficeExePath("EXCEL.EXE", "Path");
|
||||||
|
if (ExePath == null)
|
||||||
|
ExePath = PluginUtils.GetExePath("EXCEL.EXE");
|
||||||
|
|
||||||
if (ExePath != null && File.Exists(ExePath))
|
if (ExePath != null && File.Exists(ExePath))
|
||||||
{
|
{
|
||||||
WindowDetails.AddProcessToExcludeFromFreeze("excel");
|
WindowDetails.AddProcessToExcludeFromFreeze("excel");
|
||||||
|
|
|
@ -41,7 +41,9 @@ namespace Greenshot.Plugin.Office.Destinations
|
||||||
|
|
||||||
static OneNoteDestination()
|
static OneNoteDestination()
|
||||||
{
|
{
|
||||||
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
|
exePath = PluginUtils.GetOfficeExePath("ONENOTE.EXE", "Path");
|
||||||
|
if (exePath == null)
|
||||||
|
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
|
||||||
if (exePath != null && File.Exists(exePath))
|
if (exePath != null && File.Exists(exePath))
|
||||||
{
|
{
|
||||||
WindowDetails.AddProcessToExcludeFromFreeze("onenote");
|
WindowDetails.AddProcessToExcludeFromFreeze("onenote");
|
||||||
|
|
|
@ -58,8 +58,9 @@ namespace Greenshot.Plugin.Office.Destinations
|
||||||
{
|
{
|
||||||
IsActiveFlag = true;
|
IsActiveFlag = true;
|
||||||
}
|
}
|
||||||
|
ExePath = PluginUtils.GetOfficeExePath("OUTLOOK.EXE", "Path");
|
||||||
ExePath = PluginUtils.GetExePath("OUTLOOK.EXE");
|
if (ExePath == null)
|
||||||
|
ExePath = PluginUtils.GetExePath("OUTLOOK.EXE");
|
||||||
if (ExePath != null && File.Exists(ExePath))
|
if (ExePath != null && File.Exists(ExePath))
|
||||||
{
|
{
|
||||||
WindowDetails.AddProcessToExcludeFromFreeze("outlook");
|
WindowDetails.AddProcessToExcludeFromFreeze("outlook");
|
||||||
|
|
|
@ -45,7 +45,9 @@ namespace Greenshot.Plugin.Office.Destinations
|
||||||
|
|
||||||
static PowerpointDestination()
|
static PowerpointDestination()
|
||||||
{
|
{
|
||||||
ExePath = PluginUtils.GetExePath("POWERPNT.EXE");
|
ExePath = PluginUtils.GetOfficeExePath("POWERPNT.EXE", "Path");
|
||||||
|
if (ExePath == null)
|
||||||
|
ExePath = PluginUtils.GetExePath("POWERPNT.EXE");
|
||||||
if (ExePath != null && File.Exists(ExePath))
|
if (ExePath != null && File.Exists(ExePath))
|
||||||
{
|
{
|
||||||
WindowDetails.AddProcessToExcludeFromFreeze("powerpnt");
|
WindowDetails.AddProcessToExcludeFromFreeze("powerpnt");
|
||||||
|
|
|
@ -46,7 +46,9 @@ namespace Greenshot.Plugin.Office.Destinations
|
||||||
|
|
||||||
static WordDestination()
|
static WordDestination()
|
||||||
{
|
{
|
||||||
ExePath = PluginUtils.GetExePath("WINWORD.EXE");
|
ExePath = PluginUtils.GetOfficeExePath("WINWORD.EXE", "Path");
|
||||||
|
if (ExePath == null)
|
||||||
|
ExePath = PluginUtils.GetExePath("WINWORD.EXE");
|
||||||
if (ExePath != null && !File.Exists(ExePath))
|
if (ExePath != null && !File.Exists(ExePath))
|
||||||
{
|
{
|
||||||
ExePath = null;
|
ExePath = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue