-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
39 lines (32 loc) · 1.29 KB
/
Program.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
using System.Runtime.InteropServices;
namespace NeosModManager;
static class Program {
[STAThread]
static void Main(string[] args) {
if (args.Contains("-console")) {
AllocConsole();
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool GetConsoleMode(IntPtr handle, out int mode);
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GetStdHandle(int handle);
var handle = GetStdHandle(-11);
GetConsoleMode(handle, out int mode);
SetConsoleMode(handle, mode | 0x4);
}
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainWindow(args));
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) {
//Attempt to catch any crash missed and log it before closing
Log(e.Exception.Message, Level.FATAL);
Log(e.Exception.StackTrace, Level.FATAL);
}
}
}