-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProgram.cs
57 lines (48 loc) · 1.97 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using EditClipboardContents;
using System;
using System.Collections.Specialized;
using System.Windows.Forms;
using System.Configuration;
using System.Runtime.InteropServices;
#nullable enable
namespace EditClipboardContents
{
static class Program
{
[DllImport("kernel32.dll")]
static extern bool AttachConsole(int dwProcessId);
[DllImport("kernel32.dll")]
static extern bool FreeConsole();
[DllImport("kernel32.dll")]
static extern bool AllocConsole();
[STAThread]
static void Main(string[] args)
{
bool showConsole = args.Length > 0 && (args[0].ToLower() == "-console");
bool debugMode = args.Length > 0 && (args[0].ToLower() == "-debug");
if (showConsole || debugMode)
{
AllocConsole();
Console.WriteLine("Debug console attached.");
}
// -------- This code seems to be needed to actually get it to work with high DPI awareness even after adding app.manifest and app.config stuff --------
// Also need to add reference to System.Configuration as dependency by right clicking Project > Add > Reference > Search: System.Configuration
if (ConfigurationManager.GetSection("System.Windows.Forms.ApplicationConfigurationSection") is NameValueCollection section)
{
section["DpiAwareness"] = "PerMonitorV2";
}
//------------------------------------------------------------------------------------------------------------------------------------------------------
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm(debugMode:debugMode));
if (showConsole || debugMode)
{
FreeConsole();
}
}
}
}
namespace System.Runtime.CompilerServices
{
internal static class IsExternalInit { }
}