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 WINAPI EnumDesktopWindows(
  _In_opt_  HDESK hDesktop,
  _In_      WNDENUMPROC lpfn,
  _In_      LPARAM lParam
);

Parameters

hDesktop [in, optional]

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 [in]

A pointer to an application-defined EnumWindowsProc callback function.

lParam [in]

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]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

CreateDesktop
Desktops
EnumWindowsProc
GetThreadDesktop
OpenDesktop
Window Station and Desktop Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft