-
Notifications
You must be signed in to change notification settings - Fork 8
/
Startup.cs
62 lines (56 loc) · 1.97 KB
/
Startup.cs
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
//-----------------------------------------------------------------------// <copyright file="Startup.cs" company="Zhivko Kabaivanov">// Copyright (c) Zhivko Kabaivanov. All rights reserved.// </copyright>// <author>Zhivko Kabaivanov</author>//-----------------------------------------------------------------------
namespace TeamViewerPopupBlocker
{
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using Forms;
using Properties;
/// <summary>
/// Class for starting the application for blocking the TeamViewer popups.
/// </summary>
public static class Startup
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main()
{
bool result;
using (Mutex mutex = new Mutex(false, "5cb4795f-203f-4db7-bd9b-133c6d0565b1", out result))
{
if (!result)
{
var docReaderProcess = Process.GetProcessesByName(Resources.Program_Name);
var mainProcess = Process.GetCurrentProcess();
foreach (var currentProcess in docReaderProcess)
{
if (currentProcess.Id != mainProcess.Id)
{
currentProcess.Kill();
}
}
StartApplication();
return;
}
StartApplication();
}
}
/// <summary>
/// Starting the <see cref="MainForm"/> form.
/// </summary>
private static void StartApplication()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}