public override bool IsMutexLocked(ToolType tool) { if (!OperatingSystem.IsWindows()) { Debug.Fail("Unsupported API!"); return(false); } if (tool == ToolType.Sapien) { string mutex_name = sapienWindowClass + " in " + BaseDirectory.Replace('\\', '/'); bool createdNew; try { Mutex shellMutex = new(true, mutex_name, out createdNew); shellMutex.Close(); return(!createdNew); } catch (UnauthorizedAccessException) { // The mutex exists so treat it as locked return(true); } catch (WaitHandleCannotBeOpenedException) { // very weird, shouldn't happen return(false); } catch (Exception ex) { // maybe it's bad to catch everything but WinAPI can be a crapshoot, better to not crash the whole launcher Debug.WriteLine(ex.ToString()); return(false); } } else { return(false); } }
public static string DiretorioEmail(StatusEmail status) { string emailHtml; if ((int)status == 0) { emailHtml = "EmailVerificacao.html"; } else if ((int)status == 1) { emailHtml = "EmailBemVindo.html"; } else if ((int)status == 2) { emailHtml = "EmailParabens.html"; } else { emailHtml = "EmailCobranca.html"; } return(BaseDirectory.Replace("bin", "Email_HTML") .Replace("Debug", emailHtml).Replace("html\\", "html")); }