-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (38 loc) · 1.29 KB
/
Copy pathProgram.cs
File metadata and controls
39 lines (38 loc) · 1.29 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Pinger
{
static class Program
{
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");
[STAThread]
static void Main()
{
if (mutex.WaitOne(TimeSpan.Zero, true))
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
mutex.ReleaseMutex();
}
else
{
// send our Win32 message to make the currently running instance
// jump on top of all the other windows
MessageBox.Show("Одна копия приложения уже запущена", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
WinAPI.PostMessage(
(IntPtr)WinAPI.HWND_BROADCAST,
WinAPI.WM_SHOWME,
IntPtr.Zero,
IntPtr.Zero);
}
}
}
}