0 out of 2 rated this helpful - Rate this topic

EnumDesktopWindows function

Applies to: desktop apps only

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

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

CreateDesktop
Desktops
EnumWindowsProc
GetThreadDesktop
OpenDesktop
Window Station and Desktop Functions

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Order
What order are the windows enumerated in?  Is it the same as the Z-order?