-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSendMessageHelper.cs
More file actions
30 lines (26 loc) · 943 Bytes
/
SendMessageHelper.cs
File metadata and controls
30 lines (26 loc) · 943 Bytes
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
using System;
using System.Runtime.InteropServices;
namespace KeepRDPAlive
{
class SendMessageHelper
{
private const UInt32 WM_SYSCOMMAND = 0x0112;
private const UInt32 SC_MAXIMIZE = 0xF030;
private const UInt32 SC_MINIMIZE = 0xF020;
private const UInt32 SC_RESTORE = 0xF120;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
public static void MaximizeWindow(IntPtr hWnd)
{
SendMessage(hWnd, WM_SYSCOMMAND, (IntPtr)SC_MAXIMIZE, (IntPtr)0);
}
public static void RestoreWindow(IntPtr hWnd)
{
SendMessage(hWnd, WM_SYSCOMMAND, (IntPtr)SC_RESTORE, (IntPtr)0);
}
public static void MinimizeWindow(IntPtr hWnd)
{
SendMessage(hWnd, WM_SYSCOMMAND, (IntPtr)SC_MINIMIZE, (IntPtr)0);
}
}
}