private static string TryDeriveConEmuConsoleServerExecutablePath([NotNull] string sConEmuPath)
{
if(sConEmuPath == null)
throw new ArgumentNullException(nameof(sConEmuPath));
if(sConEmuPath == "")
return "";
string dir = Path.GetDirectoryName(sConEmuPath);
if(string.IsNullOrEmpty(dir))
return "";
// Make up the file name for the CPU arch of the current process, as we're gonna load it in-process
string sFileName = ConEmuConstants.ConEmuConsoleServerFileNameNoExt;
if(IntPtr.Size == 8)
sFileName += "64";
sFileName += ".dll";
string candidate = Path.Combine(dir, sFileName);
if(File.Exists(candidate))
return candidate;
candidate = Path.Combine(Path.Combine(dir, ConEmuConstants.ConEmuSubfolderName), sFileName);
if(File.Exists(candidate))
return candidate;
return "";
}