-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
85 lines (80 loc) · 3.13 KB
/
Program.cs
File metadata and controls
85 lines (80 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using System.Configuration;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
namespace Sobreclick
{
static class Program
{
/// <summary>
/// Punto de entrada principal para la aplicación.
/// </summary>
static Mutex mutex = new Mutex(true, "sobreclick");
[STAThread]
static void Main()
{
// Revisar si ya hay una instancia activa del programa
if (mutex.WaitOne(TimeSpan.Zero, true))
{
// Comprobar existencia de archivos internos
if (!File.Exists(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile))
{
MessageBox.Show(sobreclick.rm.GetString("errorLoadingConfigFile"), sobreclick.rm.GetString("msgErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Environment.Exit(0);
}
Application.EnableVisualStyles();
Application.ThreadException += new ThreadExceptionEventHandler(UIThreadException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new sobreclick());
}
else
{
MessageBox.Show(sobreclick.rm.GetString("errorProgramAlreadyRunning"), sobreclick.rm.GetString("msgErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Environment.Exit(0);
}
}
// Controlador de excepciones casero
private static void UIThreadException(object sender, ThreadExceptionEventArgs e)
{
try
{
excpt exception = new excpt(e.Exception.ToString());
exception.TopMost = true;
exception.ShowDialog();
Application.ExitThread();
Application.Exit();
}
catch
{
try
{
excpt exception = new excpt(e.Exception.ToString());
exception.TopMost = true;
exception.ShowDialog();
Application.Exit();
}
finally
{
Application.ExitThread();
Application.Exit();
}
}
Application.ExitThread();
Application.Exit();
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
excpt exception = new excpt(e.ExceptionObject.ToString());
exception.TopMost = true;
exception.ShowDialog();
Application.ExitThread();
Application.Exit();
}
}
}