EnumWindows

Syntax

BOOL EnumWindows(lpEnumFunc,lParam)

This function enumerates all parent windows on the screen by passing the handle of each window, in turn, to the callback function pointed to by the lpEnumFunc parameter. Child windows are not enumerated.

The EnumWindows function continues to enumerate windows until the called function returns zero or until the last window has been enumerated.

Parameter Type/Description  

lpEnumFunc FARPROC Is the procedure-instance address of the callback function. See the following “Comments” section for details.  
lParam DWORD Specifies the value to be passed to the callback function for the application's use.  

Return Value

The return value specifies the outcome of the function. It is nonzero if all windows have been enumerated. Otherwise, it is zero.

Comments

The address passed as the lpEnumFunc parameter must be created by using the MakeProcInstance function.

The callback function must use the Pascal calling convention and must be declared FAR. The callback function must have the following form:

Callback Function

BOOL FAR PASCAL EnumFunc(hWnd, lParam)
HWND hWnd;
DWORD lParam;

EnumFunc is a placeholder for the application-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the application's module-definition file.

Parameter Description  

hWnd Identifies the window handle.  
lParam Specifies the 32-bit argument of the EnumWindows function.  

Return Value

The function must return a nonzero value to continue enumeration, or zero to stop it.