This repository was archived by the owner on Sep 23, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathNativeMethods.cs
More file actions
98 lines (80 loc) · 3.31 KB
/
Copy pathNativeMethods.cs
File metadata and controls
98 lines (80 loc) · 3.31 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
namespace Adrenalize;
[SupportedOSPlatform("windows")]
internal static partial class NativeMethods
{
// Window Show State Codes
internal const int ShowWindowHide = 0;
internal const int ShowWindowRestore = 9;
// Window Event Hook Codes
internal const uint EventSystemMinimizeStart = 0x0016;
internal const uint WinEventOutOfContext = 0x0000;
// System Menu Item And Flag Codes
internal const uint SystemCommandClose = 0xF060;
internal const uint MenuFlagByCommand = 0x00000000;
// Console Input Handle And Mode Flags
internal const int StandardInputHandle = -10;
internal const uint EnableLineInput = 0x0002;
internal const uint EnableEchoInput = 0x0004;
internal const uint EnableQuickEditMode = 0x0040;
internal const uint EnableExtendedFlags = 0x0080;
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
internal delegate bool EnumWindowsCallback(IntPtr windowHandle, IntPtr parameter);
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
internal delegate void WinEventCallback(
IntPtr hookHandle,
uint eventType,
IntPtr windowHandle,
int objectIdentifier,
int childIdentifier,
uint threadIdentifier,
uint timestamp
);
[LibraryImport("user32.dll")]
internal static partial IntPtr SetWinEventHook(
uint eventMinimum,
uint eventMaximum,
IntPtr moduleHandle,
[MarshalAs(UnmanagedType.FunctionPtr)] WinEventCallback callback,
uint processIdentifier,
uint threadIdentifier,
uint flags
);
[LibraryImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool EnumWindows(
[MarshalAs(UnmanagedType.FunctionPtr)] EnumWindowsCallback callback,
IntPtr parameter
);
[LibraryImport("user32.dll")]
internal static partial uint GetWindowThreadProcessId(
IntPtr windowHandle,
out uint processIdentifier
);
[LibraryImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool IsWindowVisible(IntPtr windowHandle);
[LibraryImport("kernel32.dll")]
internal static partial IntPtr GetConsoleWindow();
[LibraryImport("kernel32.dll", SetLastError = true)]
internal static partial IntPtr GetStdHandle(int standardHandle);
[LibraryImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool GetConsoleMode(IntPtr consoleHandle, out uint mode);
[LibraryImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool SetConsoleMode(IntPtr consoleHandle, uint mode);
[LibraryImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool ShowWindow(IntPtr windowHandle, int showCommand);
[LibraryImport("user32.dll")]
internal static partial IntPtr GetSystemMenu(
IntPtr windowHandle,
[MarshalAs(UnmanagedType.Bool)] bool revert
);
[LibraryImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DeleteMenu(IntPtr menuHandle, uint itemIdentifier, uint flags);
}