Repository navigation
Expand file tree
/
Copy pathNativeMethods.cs
More file actions
56 lines (45 loc) · 1.66 KB
/
Copy pathNativeMethods.cs
File metadata and controls
56 lines (45 loc) · 1.66 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
using System.Runtime.InteropServices;
using System.Drawing;
namespace Caffeinated;
internal static class NativeMethods {
[DllImport("kernel32.dll")]
public static extern uint SetThreadExecutionState(uint esFlags);
public const uint ES_CONTINUOUS = 0x80000000;
public const uint ES_SYSTEM_REQUIRED = 0x00000001;
public const uint ES_DISPLAY_REQUIRED = 0x00000002;
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern int RegisterApplicationRestart(
string? pwzCommandline,
int dwFlags);
public const int RESTART_NO_CRASH = 1;
public const int RESTART_NO_HANG = 2;
public const int RESTART_NO_PATCH = 4;
public const int RESTART_NO_REBOOT = 8;
[StructLayout(LayoutKind.Sequential)]
public struct NOTIFYICONIDENTIFIER {
public int cbSize;
public nint hWnd;
public uint uID;
public System.Guid guidItem;
}
[DllImport("shell32.dll", SetLastError = true)]
public static extern int Shell_NotifyIconGetRect(
[In] ref NOTIFYICONIDENTIFIER identifier,
[Out] out RECT iconLocation);
[DllImport("user32.dll")]
public static extern uint GetDpiForWindow(nint hwnd);
[DllImport("user32.dll")]
public static extern int GetSystemMetricsForDpi(int nIndex, uint dpi);
public const int SM_CXSMICON = 49;
public const int SM_CYSMICON = 50;
[StructLayout(LayoutKind.Sequential)]
public struct RECT {
public int left;
public int top;
public int right;
public int bottom;
public Rectangle ToRectangle() {
return Rectangle.FromLTRB(left, top, right, bottom);
}
}
}