public static List <IntPtr> GetChildWindows(IntPtr hwndParent) { List <IntPtr> result = new List <IntPtr>(); GCHandle listHandle = GCHandle.Alloc(result); try { Win32Callback childProc = new Win32Callback(EnumWindow); Api_User32.EnumChildWindows(hwndParent, childProc, GCHandle.ToIntPtr(listHandle)); } finally { if (listHandle.IsAllocated) { listHandle.Free(); } } return(result); }