mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Fixed software detection for actions
This commit is contained in:
parent
465b31844c
commit
7bbe79218c
2 changed files with 15 additions and 21 deletions
|
@ -109,7 +109,7 @@ public static ExternalProgram FindProgram(string name, string filename)
|
|||
|
||||
foreach (string command in commands)
|
||||
{
|
||||
string path = string.Format(@"HKEY_CLASSES_ROOT\Applications\{0}\shell\{1}\command", filename, command);
|
||||
string path = $@"HKEY_CLASSES_ROOT\Applications\{filename}\shell\{command}\command";
|
||||
string value = Registry.GetValue(path, null, null) as string;
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
|
@ -132,14 +132,22 @@ public static ExternalProgram FindProgram(string name, string filename)
|
|||
{
|
||||
foreach (string filePath in programs.GetValueNames())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(filePath) && programs.GetValueKind(filePath) == RegistryValueKind.String)
|
||||
{
|
||||
string programName = programs.GetValue(filePath, null) as string;
|
||||
string programPath = filePath;
|
||||
|
||||
if (!string.IsNullOrEmpty(programName) && programName.Equals(name, StringComparison.InvariantCultureIgnoreCase) && File.Exists(filePath))
|
||||
if (!string.IsNullOrEmpty(programPath))
|
||||
{
|
||||
DebugHelper.WriteLine("Found program with second method: " + filePath);
|
||||
return new ExternalProgram(name, filePath);
|
||||
foreach (string trim in new string[] { ".ApplicationCompany", ".FriendlyAppName" })
|
||||
{
|
||||
if (programPath.EndsWith(trim, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
programPath = programPath.Remove(programPath.Length - trim.Length);
|
||||
}
|
||||
}
|
||||
|
||||
if (programPath.EndsWith(filename, StringComparison.OrdinalIgnoreCase) && File.Exists(programPath))
|
||||
{
|
||||
DebugHelper.WriteLine("Found program with second method: " + programPath);
|
||||
return new ExternalProgram(name, programPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -608,20 +608,6 @@ public static void AddDefaultExternalPrograms(TaskSettings taskSettings)
|
|||
AddExternalProgramFromRegistry(taskSettings, "Adobe Photoshop", "Photoshop.exe");
|
||||
AddExternalProgramFromRegistry(taskSettings, "IrfanView", "i_view32.exe");
|
||||
AddExternalProgramFromRegistry(taskSettings, "XnView", "xnview.exe");
|
||||
AddExternalProgramFromFile(taskSettings, "OptiPNG", "optipng.exe");
|
||||
}
|
||||
|
||||
private static void AddExternalProgramFromFile(TaskSettings taskSettings, string name, string filename, string args = "")
|
||||
{
|
||||
if (!taskSettings.ExternalPrograms.Exists(x => x.Name == name))
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
DebugHelper.WriteLine("Found program: " + filename);
|
||||
|
||||
taskSettings.ExternalPrograms.Add(new ExternalProgram(name, filename, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddExternalProgramFromRegistry(TaskSettings taskSettings, string name, string filename)
|
||||
|
|
Loading…
Reference in a new issue