EnumChildWindows (user32)
Last changed: sim2kid-174.69.1.142

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, ref IntPtr lParam);

public delegate bool Win32Callback(IntPtr hwnd, IntPtr lParam);
[DllImport("user32.Dll")]
public static extern IntPtr EnumChildWindows(IntPtr parentHandle, Win32Callback callback,ref IntPtr lParam);

VB Signature:

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function EnumChildWindows(ByVal hWndParent As System.IntPtr, _
   ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Integer) As Boolean
    ' Leave function empty    
End Function

User-Defined Types:

EnumWindowsProc

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    if(!isIEServerWindow(windowHandle))
    {
        //Get 1st child IE server window
        Win32.EnumChildWindows(windowHandle, new Win32Callback(this.EnumChild), ref windowHandle);
    }

    private bool EnumChild(IntPtr hWnd, ref IntPtr lParam)
    {
        if(isIEServerWindow(hWnd) )
        {
            lParam = hWnd;
        }
        else
        {
            return true;
        }
        return false;
    }

    private static bool isIEServerWindow(IntPtr hWnd)
    {
        IntPtr Res;
        StringBuilder ClassName = new StringBuilder(100);
        //Get the window class name
        Res = Win32.GetClassName(hWnd, ClassName, ClassName.MaxCapacity);
        if(Res != IntPtr.Zero)
        {
            return (string.Compare(ClassName.ToString(), "Internet Explorer_Server",true,CultureInfo.InvariantCulture) == 0);
        }
        else
        {
            return false;
        }
    }

http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows/Enumerating_Windows/article.asp has a nice article

Alternative Managed API:

Do you know one? Please contribute it!

Documentation