Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
private delegate bool EnumDesktopWindowsDelegate(IntPtr hWnd, int lParam);
Notes:
None.
Tips & Tricks:
Please add some!
Sample Code:
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System;
using System.Text;
/// <summary>
/// EnumDesktopWindows Demo - shows the caption of all desktop windows.
/// Authors: Svetlin Nakov, Martin Kulov
/// Bulgarian Association of Software Developers - http://www.devbg.org/en/
/// </summary>
public class user32
{
/// <summary>
/// filter function
/// </summary>
/// <param name="hWnd"></param>
/// <param name="lParam"></param>
/// <returns></returns>
public delegate bool EnumDelegate(IntPtr hWnd, int lParam);
/// <summary>
/// check if windows visible
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindowVisible(IntPtr hWnd);
/// <summary>
/// return windows text
/// </summary>
/// <param name="hWnd"></param>
/// <param name="lpWindowText"></param>
/// <param name="nMaxCount"></param>
/// <returns></returns>
[DllImport("user32.dll", EntryPoint = "GetWindowText",
ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount);
/// <summary>
/// entry point of the program
/// </summary>
static void Main()
{
var collection = new List<string>();
user32.EnumDelegate filter = delegate(IntPtr hWnd, int lParam)
{
StringBuilder strbTitle = new StringBuilder(255);
int nLength = user32.GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1);
string strTitle = strbTitle.ToString();
if (user32.EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero))
{
foreach (var item in collection)
{
Console.WriteLine(item);
}
}
Console.Read();
}
}
Alternative Managed API:
Do you know one? Please contribute it!
The EnumDesktopWindows API
1/23/2016 4:09:36 PM - -216.166.58.66
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).