SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
WinApi.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Runtime.InteropServices;
6 using System.Diagnostics;
7 
8 namespace SeciControls
9 {
10  public static class WinApi
11  {
12  public const int MF_REMOVE = 0x1000;
13  public const int MF_BYPOSITION = 0x400;
14 
15  [DllImport("user32.dll")]
16  public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
17 
18  [DllImport("user32.dll")]
19  public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
20 
21  [DllImport("user32.dll")]
22  public static extern bool LockWindowUpdate(IntPtr hwndLock);
23 
24  [DllImport("user32.dll")]
25  public static extern IntPtr GetDesktopWindow();
26 
27  [DllImport("User32")]
28  public static extern IntPtr GetSystemMenu(IntPtr hWnd, [MarshalAs(UnmanagedType.Bool)] Boolean revert);
29 
30  [DllImport("User32")]
31  public static extern int GetMenuItemCount(IntPtr hMenu);
32 
33  [DllImport("User32")]
34  public static extern int RemoveMenu(IntPtr hMenu, int index, int flags);
35 
36  [DllImport("User32")]
37  public static extern int MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, [MarshalAs(UnmanagedType.Bool)] Boolean repaint);
38 
39  [DllImport("User32")]
40  [return: MarshalAs(UnmanagedType.Bool)]
41  public static extern bool GetWindowRect(IntPtr hWnd, out Rect lpRect);
42 
43  [DllImport("User32")]
44  public static extern int ShowWindow(int hWnd, int nCmdShow);
45 
46  [DllImport("user32.dll", CharSet = CharSet.Auto)]
47  public static extern int GetWindowText(int hWnd, StringBuilder lpString, int nMaxCount);
48 
49  [DllImport("user32.dll", CharSet = CharSet.Auto)]
50  public static extern int GetWindowTextLength(int hWnd);
51 
52 
53  public class EnumReport
54  {
55  private delegate bool CallBackPtr(int hwnd, int lParam);
56  private CallBackPtr callBackPtr;
57 
58  public static List<int> Handles = new List<int>();
59 
60  [DllImport("user32.dll")]
61  private static extern int EnumWindows(CallBackPtr callPtr, int lPar);
62 
63  public static bool Report(int hwnd, int lParam)
64  {
65  Handles.Add(hwnd);
66  return true;
67  }
68 
69  public void GetEnums()
70  {
72  EnumReport.EnumWindows(callBackPtr, 0);
73  }
74  }
75 
76  public struct Rect
77  {
78  public int X;
79  public int Y;
80  public int Width;
81  public int Height;
82  }
83 
84  }
85 }
86 
static int GetWindowTextLength(int hWnd)
static IntPtr FindWindow(string lpClassName, string lpWindowName)
static int GetMenuItemCount(IntPtr hMenu)
static int ShowWindow(int hWnd, int nCmdShow)
delegate bool CallBackPtr(int hwnd, int lParam)
static IntPtr GetDesktopWindow()
const int MF_REMOVE
Definition: WinApi.cs:12
static int RemoveMenu(IntPtr hMenu, int index, int flags)
static List< int > Handles
Definition: WinApi.cs:58
static int EnumWindows(CallBackPtr callPtr, int lPar)
static bool GetWindowRect(IntPtr hWnd, out Rect lpRect)
static int GetWindowText(int hWnd, StringBuilder lpString, int nMaxCount)
static IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent)
const int MF_BYPOSITION
Definition: WinApi.cs:13
static bool Report(int hwnd, int lParam)
Definition: WinApi.cs:63
static bool LockWindowUpdate(IntPtr hwndLock)
static IntPtr GetSystemMenu(IntPtr hWnd, [MarshalAs(UnmanagedType.Bool)] Boolean revert)
static int MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, [MarshalAs(UnmanagedType.Bool)] Boolean repaint)