-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathNativeMethods.cs
1336 lines (1099 loc) · 54.3 KB
/
NativeMethods.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
namespace HighVoltz.HBRelog
{
internal class NativeMethods
{
// credits to http://www.pinvoke.net/ for most of this.
private const int GWL_STYLE = -16;
// Window Styles
[Flags]
public enum WindowStyle : uint
{
Border = 0x00800000,
SysMenu = 0x00080000,
Popup = 0x80000000,
PopupWindow = Popup | Border | SysMenu
}
#region ConnectionStates enum
[Flags]
public enum ConnectionStates
{
Modem = 0x1,
Lan = 0x2,
Proxy = 0x4,
RasInstalled = 0x10,
Offline = 0x20,
Configured = 0x40,
}
#endregion
#region Protection enum
public enum Protection
{
PageNoaccess = 0x01,
PageReadonly = 0x02,
PageReadwrite = 0x04,
PageWritecopy = 0x08,
PageExecute = 0x10,
PageExecuteRead = 0x20,
PageExecuteReadwrite = 0x40,
PageExecuteWritecopy = 0x80,
PageGuard = 0x100,
PageNocache = 0x200,
PageWritecombine = 0x400
}
#endregion
#region EnumWindows
#region Delegates
/// <summary>
/// Delegate for the EnumChildWindows method
/// </summary>
/// <param name="hWnd"> Window handle </param>
/// <param name="parameter"> Caller-defined variable; we use it for a pointer to our list </param>
/// <returns> True to continue enumerating, false to bail. </returns>
public delegate bool EnumWindowProc(IntPtr hWnd, IntPtr parameter);
#endregion
[SuppressUnmanagedCodeSecurity, DllImport("kernel32")]
public static extern IntPtr LoadLibrary(string libraryName);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr GetWindow(IntPtr hWnd, GetWindow_Cmd uCmd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindowVisible(IntPtr hWnd);
// ReSharper disable InconsistentNaming
public enum GetWindow_Cmd : uint
{
GW_HWNDFIRST = 0,
GW_HWNDLAST = 1,
GW_HWNDNEXT = 2,
GW_HWNDPREV = 3,
GW_OWNER = 4,
GW_CHILD = 5,
GW_ENABLEDPOPUP = 6
}
// ReSharper restore InconsistentNaming
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll", SetLastError = true)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
public static WindowStyle GetWindowStyle(IntPtr hWnd)
{
return (WindowStyle)GetWindowLong(hWnd, GWL_STYLE);
}
public static string GetClassName(IntPtr hWnd)
{
var buf = new StringBuilder(100);
GetClassName(hWnd, buf, buf.Capacity);
return buf.ToString();
}
[DllImport("user32.dll", SetLastError = true)]
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
public static uint GetWindowProcessId(IntPtr hWnd)
{
uint pid;
GetWindowThreadProcessId(hWnd, out pid);
return pid;
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FreeLibrary(IntPtr hModule);
[DllImport("user32.dll")]
public static extern bool EnumThreadWindows(int dwThreadId, EnumWindowProc lpfn, IntPtr lParam);
[DllImport("user32.dll")]
protected static extern bool EnumWindows(EnumWindowProc enumProc, IntPtr lParam);
[DllImport("user32")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr i);
public static List<IntPtr> EnumerateProcessWindowHandles(int processId)
{
var allWindows = new List<IntPtr>();
GCHandle listHandle = GCHandle.Alloc(allWindows);
try
{
EnumWindows(EnumWindow, GCHandle.ToIntPtr(listHandle));
}
finally
{
if (listHandle.IsAllocated)
listHandle.Free();
}
return allWindows.Where(h => GetWindowProcessId(h) == processId).ToList();
}
/// <summary>
/// Returns a list of child windows
/// </summary>
/// <param name="parent"> Parent of the windows to return </param>
/// <returns> List of child windows </returns>
public static List<IntPtr> GetChildWindows(IntPtr parent)
{
var result = new List<IntPtr>();
GCHandle listHandle = GCHandle.Alloc(result);
try
{
EnumChildWindows(parent, EnumWindow, GCHandle.ToIntPtr(listHandle));
}
finally
{
if (listHandle.IsAllocated)
listHandle.Free();
}
return result;
}
/// <summary>
/// Callback method to be used when enumerating windows.
/// </summary>
/// <param name="handle"> Handle of the next window </param>
/// <param name="pointer"> Pointer to a GCHandle that holds a reference to the list to fill </param>
/// <returns> True to continue the enumeration, false to bail </returns>
private static bool EnumWindow(IntPtr handle, IntPtr pointer)
{
GCHandle gch = GCHandle.FromIntPtr(pointer);
var list = gch.Target as List<IntPtr>;
if (list == null)
{
throw new InvalidCastException("GCHandle Target could not be cast as List<IntPtr>");
}
list.Add(handle);
// You can modify this to check to see if you want to cancel the operation, then return a null here
return true;
}
#endregion
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, UIntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr PostMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, UIntPtr lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd,
uint Msg,
IntPtr wParam,
UIntPtr lParam,
SendMessageTimeoutFlags fuFlags,
uint uTimeout,
out UIntPtr lpdwResult);
[Flags]
public enum SendMessageTimeoutFlags : uint
{
SMTO_NORMAL = 0x0,
SMTO_BLOCK = 0x1,
SMTO_ABORTIFHUNG = 0x2,
SMTO_NOTIMEOUTIFNOTHUNG = 0x8,
SMTO_ERRORONEXIT = 0x20
}
public const int MaxPath = 260;
public const int MaxAlternate = 14;
[DllImport("user32.dll")]
public static extern uint MapVirtualKey(uint uCode, uint uMapType);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteFile(string name);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetFileAttributes(string lpFileName);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy,
SetWindowPosFlags uFlags);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowPlacement(IntPtr hWnd, ref Windowplacement lpwndpl);
[DllImport("wininet.dll", SetLastError = true)]
public static extern bool InternetGetConnectedState(out int lpdwFlags, int dwReserved);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, out Rect lpRect);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindFirstFile(string lpFileName, out Win32FindData lpFindFileData);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool FindClose(IntPtr hFindFile);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool FindNextFile(IntPtr hFindFile, out Win32FindData lpFindFileData);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int GetWindowTextLength(IntPtr hWnd);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool VirtualProtect(uint lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);
[DllImportAttribute("user32.dll", EntryPoint = "BlockInput")]
[return: MarshalAsAttribute(UnmanagedType.Bool)]
public static extern bool BlockInput([MarshalAsAttribute(UnmanagedType.Bool)] bool fBlockIt);
[DllImport("user32.dll")]
public static extern int SetWindowText(IntPtr hWnd, string text);
[DllImport("user32.dll")]
public static extern int GetSystemMetrics(SystemMetric smIndex);
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(out Point lpPoint);
[DllImport("user32.dll", SetLastError = true)]
public static extern uint SendInput(uint nInputs, ref Input pInputs, int cbSize);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool GetWindowInfo(IntPtr hwnd, ref WindowInfo pwi);
public static string GetWindowText(IntPtr hWnd)
{
// Allocate correct string length first
int length = GetWindowTextLength(hWnd);
var sb = new StringBuilder(length + 1);
GetWindowText(hWnd, sb, sb.Capacity);
return sb.ToString();
}
/// <summary>
/// A utility class to determine a process parent.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct ParentProcessUtilities
{
// These members must match PROCESS_BASIC_INFORMATION
internal IntPtr Reserved1;
internal IntPtr PebBaseAddress;
internal IntPtr Reserved2_0;
internal IntPtr Reserved2_1;
internal IntPtr UniqueProcessId;
internal IntPtr InheritedFromUniqueProcessId;
[DllImport("ntdll.dll")]
private static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessUtilities processInformation, int processInformationLength, out int returnLength);
public static int GetParentProcessId(int id)
{
Process process = Process.GetProcessById(id);
try
{
return GetParentProcessId(process.Handle);
}
finally
{
process.Dispose();
}
}
/// <summary>
/// Gets the parent process of a specified process.
/// </summary>
/// <param name="handle">The process handle.</param>
/// <returns>An instance of the Process class.</returns>
public static int GetParentProcessId(IntPtr handle)
{
var pbi = new ParentProcessUtilities();
int returnLength;
int status = NtQueryInformationProcess(handle, 0, ref pbi, Marshal.SizeOf(pbi), out returnLength);
if (status != 0) // fail silently...
return -1;
//throw new Win32Exception(status);
try
{
return pbi.InheritedFromUniqueProcessId.ToInt32();
}
catch (ArgumentException)
{
// not found
return -1;
}
}
}
#region Nested Type: WindowInfo
[StructLayout(LayoutKind.Sequential)]
public struct WindowInfo
{
public uint cbSize;
public Rect rcWindow;
public Rect rcClient;
public uint dwStyle;
public uint dwExStyle;
public uint dwWindowStatus;
public uint cxWindowBorders;
public uint cyWindowBorders;
public ushort atomWindowType;
public ushort wCreatorVersion;
public WindowInfo(Boolean? filler) : this() // Allows automatic initialization of "cbSize" with "new WINDOWINFO(null/true/false)".
{
cbSize = (UInt32)(Marshal.SizeOf(typeof(WindowInfo)));
}
}
#endregion
#region Nested Types for SendInput
[StructLayout(LayoutKind.Sequential)]
public struct Keybdinput
{
public ushort wVk;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct Hardwareinput
{
public int uMsg;
public short wParamL;
public short wParamH;
}
/// <summary>
/// Captures the union of the three three structures.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
public struct MouseKeybdhardwareInputUnion
{
/// <summary>
/// The Mouse Input Data
/// </summary>
[FieldOffset(0)] public MouseInputData mi;
/// <summary>
/// The Keyboard input data
/// </summary>
[FieldOffset(0)] public Keybdinput ki;
/// <summary>
/// The hardware input data
/// </summary>
[FieldOffset(0)] public Hardwareinput hi;
}
/// <summary>
/// The mouse data structure
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct MouseInputData
{
/// <summary>
/// The x value, if ABSOLUTE is passed in the flag then this is an actual X and Y value
/// otherwise it is a delta from the last position
/// </summary>
public int dx;
/// <summary>
/// The y value, if ABSOLUTE is passed in the flag then this is an actual X and Y value
/// otherwise it is a delta from the last position
/// </summary>
public int dy;
/// <summary>
/// Wheel event data, X buttons
/// </summary>
public uint mouseData;
/// <summary>
/// ORable field with the various flags about buttons and nature of event
/// </summary>
public MouseEventFlags dwFlags;
/// <summary>
/// The timestamp for the event, if zero then the system will provide
/// </summary>
public uint time;
/// <summary>
/// Additional data obtained by calling app via GetMessageExtraInfo
/// </summary>
public IntPtr dwExtraInfo;
}
[Flags]
public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
/// <summary>
/// The Data passed to SendInput in an array.
/// </summary>
/// <remarks>Contains a union field type specifies what it contains </remarks>
[StructLayout(LayoutKind.Sequential)]
public struct Input
{
/// <summary>
/// The actual data type contained in the union Field
/// </summary>
public SendInputEventType type;
public MouseKeybdhardwareInputUnion mkhi;
}
/// <summary>
/// The event type contained in the union field
/// </summary>
public enum SendInputEventType : int
{
/// <summary>
/// Contains Mouse event data
/// </summary>
InputMouse,
/// <summary>
/// Contains Keyboard event data
/// </summary>
InputKeyboard,
/// <summary>
/// Contains Hardware event data
/// </summary>
InputHardware
}
#endregion
#region Nested Type: SetWindowPosFlags enum
[Flags]
public enum SetWindowPosFlags : uint
{
// ReSharper disable InconsistentNaming
/// <summary>
/// If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
/// </summary>
SWP_ASYNCWINDOWPOS = 0x4000,
/// <summary>
/// Prevents generation of the WM_SYNCPAINT message.
/// </summary>
SWP_DEFERERASE = 0x2000,
/// <summary>
/// Draws a frame (defined in the window's class description) around the window.
/// </summary>
SWP_DRAWFRAME = 0x0020,
/// <summary>
/// Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.
/// </summary>
SWP_FRAMECHANGED = 0x0020,
/// <summary>
/// Hides the window.
/// </summary>
SWP_HIDEWINDOW = 0x0080,
/// <summary>
/// Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).
/// </summary>
SWP_NOACTIVATE = 0x0010,
/// <summary>
/// Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.
/// </summary>
SWP_NOCOPYBITS = 0x0100,
/// <summary>
/// Retains the current position (ignores X and Y parameters).
/// </summary>
SWP_NOMOVE = 0x0002,
/// <summary>
/// Does not change the owner window's position in the Z order.
/// </summary>
SWP_NOOWNERZORDER = 0x0200,
/// <summary>
/// Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
/// </summary>
SWP_NOREDRAW = 0x0008,
/// <summary>
/// Same as the SWP_NOOWNERZORDER flag.
/// </summary>
SWP_NOREPOSITION = 0x0200,
/// <summary>
/// Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
/// </summary>
SWP_NOSENDCHANGING = 0x0400,
/// <summary>
/// Retains the current size (ignores the cx and cy parameters).
/// </summary>
SWP_NOSIZE = 0x0001,
/// <summary>
/// Retains the current Z order (ignores the hWndInsertAfter parameter).
/// </summary>
SWP_NOZORDER = 0x0004,
/// <summary>
/// Displays the window.
/// </summary>
SWP_SHOWWINDOW = 0x0040,
// ReSharper restore InconsistentNaming
}
#endregion
#region Nested Type: SystemMetric
/// <summary>
/// Flags used with the Windows API (User32.dll):GetSystemMetrics(SystemMetric smIndex)
///
/// This Enum and declaration signature was written by Gabriel T. Sharp
/// Obtained on pinvoke.net, please contribute your code to support the wiki!
/// </summary>
public enum SystemMetric : int
{
/// <summary>
/// The flags that specify how the system arranged minimized windows. For more information, see the Remarks section in this topic.
/// </summary>
SM_ARRANGE = 56,
/// <summary>
/// The value that specifies how the system is started:
/// 0 Normal boot
/// 1 Fail-safe boot
/// 2 Fail-safe with network boot
/// A fail-safe boot (also called SafeBoot, Safe Mode, or Clean Boot) bypasses the user startup files.
/// </summary>
SM_CLEANBOOT = 67,
/// <summary>
/// The number of display monitors on a desktop. For more information, see the Remarks section in this topic.
/// </summary>
SM_CMONITORS = 80,
/// <summary>
/// The number of buttons on a mouse, or zero if no mouse is installed.
/// </summary>
SM_CMOUSEBUTTONS = 43,
/// <summary>
/// The width of a window border, in pixels. This is equivalent to the SM_CXEDGE value for windows with the 3-D look.
/// </summary>
SM_CXBORDER = 5,
/// <summary>
/// The width of a cursor, in pixels. The system cannot create cursors of other sizes.
/// </summary>
SM_CXCURSOR = 13,
/// <summary>
/// This value is the same as SM_CXFIXEDFRAME.
/// </summary>
SM_CXDLGFRAME = 7,
/// <summary>
/// The width of the rectangle around the location of a first click in a double-click sequence, in pixels. ,
/// The second click must occur within the rectangle that is defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system
/// to consider the two clicks a double-click. The two clicks must also occur within a specified time.
/// To set the width of the double-click rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKWIDTH.
/// </summary>
SM_CXDOUBLECLK = 36,
/// <summary>
/// The number of pixels on either side of a mouse-down point that the mouse pointer can move before a drag operation begins.
/// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
/// If this value is negative, it is subtracted from the left of the mouse-down point and added to the right of it.
/// </summary>
SM_CXDRAG = 68,
/// <summary>
/// The width of a 3-D border, in pixels. This metric is the 3-D counterpart of SM_CXBORDER.
/// </summary>
SM_CXEDGE = 45,
/// <summary>
/// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels.
/// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border.
/// This value is the same as SM_CXDLGFRAME.
/// </summary>
SM_CXFIXEDFRAME = 7,
/// <summary>
/// The width of the left and right edges of the focus rectangle that the DrawFocusRectdraws.
/// This value is in pixels.
/// Windows 2000: This value is not supported.
/// </summary>
SM_CXFOCUSBORDER = 83,
/// <summary>
/// This value is the same as SM_CXSIZEFRAME.
/// </summary>
SM_CXFRAME = 32,
/// <summary>
/// The width of the client area for a full-screen window on the primary display monitor, in pixels.
/// To get the coordinates of the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars,
/// call the SystemParametersInfofunction with the SPI_GETWORKAREA value.
/// </summary>
SM_CXFULLSCREEN = 16,
/// <summary>
/// The width of the arrow bitmap on a horizontal scroll bar, in pixels.
/// </summary>
SM_CXHSCROLL = 21,
/// <summary>
/// The width of the thumb box in a horizontal scroll bar, in pixels.
/// </summary>
SM_CXHTHUMB = 10,
/// <summary>
/// The default width of an icon, in pixels. The LoadIcon function can load only icons with the dimensions
/// that SM_CXICON and SM_CYICON specifies.
/// </summary>
SM_CXICON = 11,
/// <summary>
/// The width of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size
/// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CXICON.
/// </summary>
SM_CXICONSPACING = 38,
/// <summary>
/// The default width, in pixels, of a maximized top-level window on the primary display monitor.
/// </summary>
SM_CXMAXIMIZED = 61,
/// <summary>
/// The default maximum width of a window that has a caption and sizing borders, in pixels.
/// This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions.
/// A window can override this value by processing the WM_GETMINMAXINFO message.
/// </summary>
SM_CXMAXTRACK = 59,
/// <summary>
/// The width of the default menu check-mark bitmap, in pixels.
/// </summary>
SM_CXMENUCHECK = 71,
/// <summary>
/// The width of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels.
/// </summary>
SM_CXMENUSIZE = 54,
/// <summary>
/// The minimum width of a window, in pixels.
/// </summary>
SM_CXMIN = 28,
/// <summary>
/// The width of a minimized window, in pixels.
/// </summary>
SM_CXMINIMIZED = 57,
/// <summary>
/// The width of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged.
/// This value is always greater than or equal to SM_CXMINIMIZED.
/// </summary>
SM_CXMINSPACING = 47,
/// <summary>
/// The minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions.
/// A window can override this value by processing the WM_GETMINMAXINFO message.
/// </summary>
SM_CXMINTRACK = 34,
/// <summary>
/// The amount of border padding for captioned windows, in pixels. Windows XP/2000: This value is not supported.
/// </summary>
SM_CXPADDEDBORDER = 92,
/// <summary>
/// The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling
/// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES).
/// </summary>
SM_CXSCREEN = 0,
/// <summary>
/// The width of a button in a window caption or title bar, in pixels.
/// </summary>
SM_CXSIZE = 30,
/// <summary>
/// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels.
/// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
/// This value is the same as SM_CXFRAME.
/// </summary>
SM_CXSIZEFRAME = 32,
/// <summary>
/// The recommended width of a small icon, in pixels. Small icons typically appear in window captions and in small icon view.
/// </summary>
SM_CXSMICON = 49,
/// <summary>
/// The width of small caption buttons, in pixels.
/// </summary>
SM_CXSMSIZE = 52,
/// <summary>
/// The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors.
/// The SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen.
/// </summary>
SM_CXVIRTUALSCREEN = 78,
/// <summary>
/// The width of a vertical scroll bar, in pixels.
/// </summary>
SM_CXVSCROLL = 2,
/// <summary>
/// The height of a window border, in pixels. This is equivalent to the SM_CYEDGE value for windows with the 3-D look.
/// </summary>
SM_CYBORDER = 6,
/// <summary>
/// The height of a caption area, in pixels.
/// </summary>
SM_CYCAPTION = 4,
/// <summary>
/// The height of a cursor, in pixels. The system cannot create cursors of other sizes.
/// </summary>
SM_CYCURSOR = 14,
/// <summary>
/// This value is the same as SM_CYFIXEDFRAME.
/// </summary>
SM_CYDLGFRAME = 8,
/// <summary>
/// The height of the rectangle around the location of a first click in a double-click sequence, in pixels.
/// The second click must occur within the rectangle defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system to consider
/// the two clicks a double-click. The two clicks must also occur within a specified time. To set the height of the double-click
/// rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKHEIGHT.
/// </summary>
SM_CYDOUBLECLK = 37,
/// <summary>
/// The number of pixels above and below a mouse-down point that the mouse pointer can move before a drag operation begins.
/// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
/// If this value is negative, it is subtracted from above the mouse-down point and added below it.
/// </summary>
SM_CYDRAG = 69,
/// <summary>
/// The height of a 3-D border, in pixels. This is the 3-D counterpart of SM_CYBORDER.
/// </summary>
SM_CYEDGE = 46,
/// <summary>
/// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels.
/// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border.
/// This value is the same as SM_CYDLGFRAME.
/// </summary>
SM_CYFIXEDFRAME = 8,
/// <summary>
/// The height of the top and bottom edges of the focus rectangle drawn byDrawFocusRect.
/// This value is in pixels.
/// Windows 2000: This value is not supported.
/// </summary>
SM_CYFOCUSBORDER = 84,
/// <summary>
/// This value is the same as SM_CYSIZEFRAME.
/// </summary>
SM_CYFRAME = 33,
/// <summary>
/// The height of the client area for a full-screen window on the primary display monitor, in pixels.
/// To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars,
/// call the SystemParametersInfo function with the SPI_GETWORKAREA value.
/// </summary>
SM_CYFULLSCREEN = 17,
/// <summary>
/// The height of a horizontal scroll bar, in pixels.
/// </summary>
SM_CYHSCROLL = 3,
/// <summary>
/// The default height of an icon, in pixels. The LoadIcon function can load only icons with the dimensions SM_CXICON and SM_CYICON.
/// </summary>
SM_CYICON = 12,
/// <summary>
/// The height of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size
/// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CYICON.
/// </summary>
SM_CYICONSPACING = 39,
/// <summary>
/// For double byte character set versions of the system, this is the height of the Kanji window at the bottom of the screen, in pixels.
/// </summary>
SM_CYKANJIWINDOW = 18,
/// <summary>
/// The default height, in pixels, of a maximized top-level window on the primary display monitor.
/// </summary>
SM_CYMAXIMIZED = 62,
/// <summary>
/// The default maximum height of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop.
/// The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing
/// the WM_GETMINMAXINFO message.
/// </summary>
SM_CYMAXTRACK = 60,
/// <summary>
/// The height of a single-line menu bar, in pixels.
/// </summary>
SM_CYMENU = 15,
/// <summary>
/// The height of the default menu check-mark bitmap, in pixels.
/// </summary>
SM_CYMENUCHECK = 72,
/// <summary>
/// The height of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels.
/// </summary>
SM_CYMENUSIZE = 55,
/// <summary>
/// The minimum height of a window, in pixels.
/// </summary>
SM_CYMIN = 29,
/// <summary>
/// The height of a minimized window, in pixels.
/// </summary>
SM_CYMINIMIZED = 58,
/// <summary>
/// The height of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged.
/// This value is always greater than or equal to SM_CYMINIMIZED.
/// </summary>
SM_CYMINSPACING = 48,
/// <summary>
/// The minimum tracking height of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions.
/// A window can override this value by processing the WM_GETMINMAXINFO message.
/// </summary>
SM_CYMINTRACK = 35,
/// <summary>
/// The height of the screen of the primary display monitor, in pixels. This is the same value obtained by calling
/// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES).
/// </summary>
SM_CYSCREEN = 1,
/// <summary>
/// The height of a button in a window caption or title bar, in pixels.
/// </summary>
SM_CYSIZE = 31,
/// <summary>
/// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels.
/// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
/// This value is the same as SM_CYFRAME.
/// </summary>
SM_CYSIZEFRAME = 33,
/// <summary>
/// The height of a small caption, in pixels.
/// </summary>
SM_CYSMCAPTION = 51,
/// <summary>
/// The recommended height of a small icon, in pixels. Small icons typically appear in window captions and in small icon view.
/// </summary>
SM_CYSMICON = 50,
/// <summary>
/// The height of small caption buttons, in pixels.
/// </summary>
SM_CYSMSIZE = 53,