-
Notifications
You must be signed in to change notification settings - Fork 51
/
App.xaml.cs
62 lines (52 loc) · 1.63 KB
/
App.xaml.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
58
59
60
61
62
#region
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
using LeagueSharp.Loader.Class;
using Microsoft.Win32;
#endregion
namespace LeagueSharp.Loader
{
public partial class App : Application {
private Mutex _mutex;
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
protected override void OnStartup(StartupEventArgs e)
{
bool createdNew;
_mutex = new Mutex(true, @"LeagueSharp.Loader.Mutex", out createdNew);
if (!createdNew)
{
if (e.Args.Length > 0)
{
var wnd = Injection.FindWindow(IntPtr.Zero, "LeagueSharp");
if (wnd != IntPtr.Zero)
{
if (e.Args[0] == "addregkey")
{
LSUriScheme.CreateRegistryKeys(true);
}
else
{
Clipboard.SetText(e.Args[0]);
ShowWindow(wnd, 5);
SetForegroundWindow(wnd);
}
}
}
_mutex = null;
Environment.Exit(0);
}
base.OnStartup(e);
}
protected override void OnExit(ExitEventArgs e)
{
if (_mutex != null)
_mutex.ReleaseMutex();
base.OnExit(e);
}
}
}