1。首先需要添加FLASH相关的引用,在工具箱右键-选择项
2.新建类EnumWindowsItem
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Collections;
namespace Demo
{
/// <summary>
/// Window Style Flags
/// </summary>
[Flags]
public enum WindowStyleFlags : uint
{
WS_OVERLAPPED = 0x00000000,
WS_POPUP = 0x80000000,
WS_CHILD = 0x40000000,
WS_MINIMIZE = 0x20000000,
WS_VISIBLE = 0x10000000,
WS_DISABLED = 0x08000000,
WS_CLIPSIBLINGS = 0x04000000,
WS_CLIPCHILDREN = 0x02000000,
WS_MAXIMIZE = 0x01000000,
WS_BORDER = 0x00800000,
WS_DLGFRAME = 0x00400000,
WS_VSCROLL = 0x00200000,
WS_HSCROLL = 0x00100000,
WS_SYSMENU = 0x00080000,
WS_THICKFRAME = 0x00040000,
WS_GROUP = 0x00020000,
WS_TABSTOP = 0x00010000,
WS_MINIMIZEBOX = 0x00020000,
WS_MAXIMIZEBOX = 0x00010000,
}
/// <summary>
/// Extended Windows Style flags
/// </summary>
[Flags]
public enum ExtendedWindowStyleFlags : int
{
WS_EX_DLGMODALFRAME = 0x00000001,
WS_EX_NOPARENTNOTIFY = 0x00000004,
WS_EX_TOPMOST = 0x00000008,
WS_EX_ACCEPTFILES = 0x00000010,
WS_EX_TRANSPARENT = 0x00000020,
WS_EX_MDICHILD = 0x00000040,
WS_EX_TOOLWINDOW = 0x00000080,
WS_EX_WINDOWEDGE = 0x00000100,
WS_EX_CLIENTEDGE = 0x00000200,
WS_EX_CONTEXTHELP = 0x00000400,
WS_EX_RIGHT = 0x00001000,
WS_EX_LEFT = 0x00000000,
WS_EX_RTLREADING = 0x00002000,
WS_EX_LTRREADING = 0x00000000,
WS_EX_LEFTSCROLLBAR = 0x00004000,
WS_EX_RIGHTSCROLLBAR = 0x00000000,
WS_EX_CONTROLPARENT = 0x00010000,
WS_EX_STATICEDGE = 0x00020000,
WS_EX_APPWINDOW = 0x00040000,
WS_EX_LAYERED = 0x00080000,
WS_EX_NOINHERITLAYOUT = 0x00100000, // Disable inheritence of mirroring by children
WS_EX_LAYOUTRTL = 0x00400000, // Right to left mirroring
WS_EX_COMPOSITED = 0x02000000,
WS_EX_NOACTIVATE = 0x08000000
}
#region EnumWindows
/// <summary>
/// EnumWindows wrapper for .NET
/// </summary>
public class EnumWindows
{
#region Delegates
private delegate int EnumWindowsProc(IntPtr hwnd, int lParam);
#endregion
#region UnManagedMethods
private class UnManagedMethods
{
[DllImport("user32")]
public extern static int EnumWindows(
EnumWindowsProc lpEnumFunc,
int lParam);
[DllImport("user32")]
public extern static int EnumChildWindows(
IntPtr hWndParent,
EnumWindowsProc lpEnumFunc,
int lParam);
}
#endregion
#region Member Variables
private EnumWindowsCollection items = null;
#endregion
/// <summary>
/// Returns the collection of windows returned by
/// GetWindows
/// </summary>
public EnumWindowsCollection Items
{
get
{
return this.items;
}
}
/// <summary>
/// Gets all top level windows on the system.
/// </summary>
public void GetWindows()
{
this.items = new EnumWindowsCollection();
UnManagedMethods.EnumWindows(
new EnumWindowsProc(this.WindowEnum),
0);
}
/// <summary>
/// Gets all child windows of the specified window
/// </summary>
/// <param name="hWndParent">Window Handle to get children for</param>
public void GetWindows(
IntPtr hWndParent)
{
this.items = new EnumWindowsCollection();
UnManagedMethods.EnumChildWindows(
hWndParent,
new EnumWindowsProc(this.WindowEnum),
0);
}
#region EnumWindows callback
/// <summary>
/// The enum Windows callback.
/// </summary>
/// <param name="hWnd">Window Handle</param>
/// <param name="lParam">Application defined value</param>
/// <returns>1 to continue enumeration, 0 to stop</returns>
private int Win