-
Notifications
You must be signed in to change notification settings - Fork 2
/
User32.cs
79 lines (70 loc) · 3.1 KB
/
User32.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace KimeraCS
{
class User32
{
internal const string DLLName = "USER32.DLL";
[StructLayout(LayoutKind.Sequential)]
public struct DEVMODE
{
private const int CCHDEVICENAME = 0x20;
private const int CCHFORMNAME = 0x20;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
public string dmDeviceName;
public short dmSpecVersion;
public short dmDriverVersion;
public short dmSize;
public short dmDriverExtra;
public int dmFields;
public int dmPositionX;
public int dmPositionY;
public ScreenOrientation dmDisplayOrientation;
public int dmDisplayFixedOutput;
public short dmColor;
public short dmDuplex;
public short dmYResolution;
public short dmTTOption;
public short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
public string dmFormName;
public short dmLogPixels;
public int dmBitsPerPel;
public int dmPelsWidth;
public int dmPelsHeight;
public int dmDisplayFlags;
public int dmDisplayFrequency;
public int dmICMMethod;
public int dmICMIntent;
public int dmMediaType;
public int dmDitherType;
public int dmReserved1;
public int dmReserved2;
public int dmPanningWidth;
public int dmPanningHeight;
}
[DllImport(DLLName, EntryPoint = "GetDC", SetLastError = true)]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport(DLLName, EntryPoint = "ReleaseDC")]
public static extern Int32 ReleaseDC(IntPtr hWnd, IntPtr hDC);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport(DLLName, EntryPoint = "BlockInput", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern void BlockInput([In, MarshalAs(UnmanagedType.Bool)] bool fBlockIt);
[DllImport(DLLName)]
public static extern bool EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);
// FolderBrowserDialogEx
[DllImport(DLLName, EntryPoint = "SendMessageW")]
public static extern IntPtr SendMessageW(IntPtr hWnd, uint msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
[DllImport(DLLName, EntryPoint = "FindWindowExW")]
public static extern IntPtr FindWindowExW(IntPtr hWndParent, IntPtr hWndChildAfter, [MarshalAs(UnmanagedType.LPWStr)] string lpszClass, [MarshalAs(UnmanagedType.LPWStr)] string lpszWindow);
[DllImport(DLLName, EntryPoint = "GetActiveWindow")]
public static extern IntPtr GetActiveWindow();
[DllImport(DLLName, EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int wMsg, bool wParam, int lParam);
}
}