EnumDesktopWindows function

Enumerates all top-level windows associated with the specified desktop. It passes the handle to each window, in turn, to an application-defined callback function.

Syntax

BOOL EnumDesktopWindows(
  HDESK       hDesktop,
  WNDENUMPROC lpfn,
  LPARAM      lParam
);

Parameters

hDesktop

A handle to the desktop whose top-level windows are to be enumerated. This handle is returned by the CreateDesktop, GetThreadDesktop, OpenDesktop, or OpenInputDesktop function, and must have the DESKTOP_READOBJECTS access right. For more information, see Desktop Security and Access Rights.

If this parameter is NULL, the current desktop is used.

lpfn

A pointer to an application-defined EnumWindowsProc callback function.

lParam

An application-defined value to be passed to the callback function.

Return Value

If the function fails or is unable to perform the enumeration, the return value is zero.

To get extended error information, call GetLastError.

You must ensure that the callback function sets SetLastError if it fails.

Windows Server 2003 and Windows XP/2000:  If there are no windows on the desktop, GetLastError returns ERROR_INVALID_HANDLE.

Remarks

The EnumDesktopWindows function repeatedly invokes the lpfn callback function until the last top-level window is enumerated or the callback function returns FALSE.

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See Also

CreateDesktop

Desktops

EnumWindowsProc

GetThreadDesktop

OpenDesktop

Window Station and Desktop Functions