Spring – Diff between revs 1 and 3
?pathlinks?
Rev 1 | Rev 3 | |||
---|---|---|---|---|
1 | using System; |
1 | using System; |
|
- | 2 | using System.IO; |
||
2 | using System.Runtime.InteropServices; |
3 | using System.Runtime.InteropServices; |
|
3 | using System.Threading; |
4 | using System.Threading; |
|
4 | using System.Windows.Forms; |
5 | using System.Windows.Forms; |
|
5 | using Spring.Main; |
6 | using Spring.Main; |
|
6 | |
7 | |
|
7 | namespace Spring |
8 | namespace Spring |
|
8 | { |
9 | { |
|
9 | internal static class Program |
10 | internal static class Program |
|
10 | { |
11 | { |
|
11 | #region Static Fields and Constants |
12 | #region Static Fields and Constants |
|
12 | |
13 | |
|
13 | private static readonly Mutex Mutex = new Mutex(true, Constants.AssemblyGuid); |
14 | private static readonly Mutex Mutex = new Mutex(true, Constants.AssemblyGuid); |
|
14 | |
15 | |
|
15 | #endregion |
16 | #endregion |
|
16 | |
17 | |
|
17 | #region Private Methods |
18 | #region Private Methods |
|
18 | |
19 | |
|
19 | /// <summary> |
20 | /// <summary> |
|
20 | /// The main entry point for the application. |
21 | /// The main entry point for the application. |
|
21 | /// </summary> |
22 | /// </summary> |
|
22 | [STAThread] |
23 | [STAThread] |
|
23 | private static void Main() |
24 | private static void Main() |
|
24 | { |
25 | { |
|
- | 26 | Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); |
||
- | 27 | |
||
25 | if (Mutex.WaitOne(TimeSpan.Zero, true)) |
28 | if (Mutex.WaitOne(TimeSpan.Zero, true)) |
|
26 | { |
29 | { |
|
27 | Application.EnableVisualStyles(); |
30 | Application.EnableVisualStyles(); |
|
28 | Application.SetCompatibleTextRenderingDefault(false); |
31 | Application.SetCompatibleTextRenderingDefault(false); |
|
29 | Application.Run(new MainForm()); |
32 | Application.Run(new MainForm()); |
|
30 | |
33 | |
|
31 | return; |
34 | return; |
|
32 | } |
35 | } |
|
33 | |
36 | |
|
34 | // Foreground current other application window. |
37 | // Foreground current other application window. |
|
35 | Natives.PostMessage( |
38 | Natives.PostMessage( |
|
36 | (IntPtr) Natives.HWndBroadcast, |
39 | (IntPtr) Natives.HWndBroadcast, |
|
37 | Natives.WmShowMe, |
40 | Natives.WmShowMe, |
|
38 | IntPtr.Zero, |
41 | IntPtr.Zero, |
|
39 | IntPtr.Zero); |
42 | IntPtr.Zero); |
|
40 | } |
43 | } |
|
41 | |
44 | |
|
42 | #endregion |
45 | #endregion |
|
43 | |
46 | |
|
44 | #region Nested Types |
47 | #region Nested Types |
|
45 | |
48 | |
|
46 | internal class Natives |
49 | internal class Natives |
|
47 | { |
50 | { |
|
48 | #region Static Fields and Constants |
51 | #region Static Fields and Constants |
|
49 | |
52 | |
|
50 | public const int HWndBroadcast = 0xffff; |
53 | public const int HWndBroadcast = 0xffff; |
|
51 | |
54 | |
|
52 | public static readonly int WmShowMe = RegisterWindowMessage("WM_SHOWME"); |
55 | public static readonly int WmShowMe = RegisterWindowMessage("WM_SHOWME"); |
|
53 | |
56 | |
|
54 | #endregion |
57 | #endregion |
|
55 | |
58 | |
|
56 | #region Public Methods |
59 | #region Public Methods |
|
57 | |
60 | |
|
58 | [DllImport("user32.dll", EntryPoint = "RegisterWindowMessageW", SetLastError = true)] |
61 | [DllImport("user32.dll", EntryPoint = "RegisterWindowMessageW", SetLastError = true)] |
|
59 | public static extern int RegisterWindowMessage(string lpString); |
62 | public static extern int RegisterWindowMessage(string lpString); |
|
60 | |
63 | |
|
61 | [DllImport("user32")] |
64 | [DllImport("user32")] |
|
62 | public static extern bool PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); |
65 | public static extern bool PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); |
|
63 | |
66 | |
|
64 | #endregion |
67 | #endregion |
|
65 | } |
68 | } |
|
66 | |
69 | |
|
67 | #endregion |
70 | #endregion |
|
68 | } |
71 | } |
|
69 | } |
72 | } |
|
70 | |
73 | |