-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
67 lines (65 loc) · 2.04 KB
/
Program.cs
File metadata and controls
67 lines (65 loc) · 2.04 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
using System;
using System.Threading;
using System.Windows.Forms;
using System.Runtime;
namespace XShort
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private static String _fileName = "";
public static String FileName
{
set
{
_fileName = value;
}
get
{
return _fileName;
}
}
private static Mutex m_Mutex;
[STAThread]
static void Main(String[] args)
{
if (args.Length > 0)
{
_fileName = args[0];
}
ProfileOptimization.SetProfileRoot(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "XShort"));
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
m_Mutex = new Mutex(true, "XShort");
if (m_Mutex.WaitOne(0, false))
{
Application.Run(new MainForm());
}
else
{
//MessageBox.Show("XShort is already running!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// send our Win32 message to make the currently running instance
// jump on top of all the other windows
if (args.Length > 0)
{
NativeMethods.PostMessage(
(IntPtr)NativeMethods.HWND_BROADCAST,
NativeMethods.WM_NEWSETTINGS,
IntPtr.Zero,
IntPtr.Zero);
}
else
{
NativeMethods.PostMessage(
(IntPtr)NativeMethods.HWND_BROADCAST,
NativeMethods.WM_SHOWME,
IntPtr.Zero,
IntPtr.Zero);
}
return;
}
}
}
}