FindWindow

From aldeid
Jump to navigation Jump to search

Description

Retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.

To search child windows, beginning with a specified child window, use the FindWindowEx function.

Note
Sometimes this function is used as an anti-debugging technique to search for OllyDbg windows.

Syntax

HWND WINAPI FindWindow(
  _In_opt_  LPCTSTR lpClassName,
  _In_opt_  LPCTSTR lpWindowName
);

Parameters

lpClassName [in, optional]
Type: LPCTSTR
The class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero.
If lpClassName points to a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names.
If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.
lpWindowName [in, optional]
Type: LPCTSTR
The window name (the window's title). If this parameter is NULL, all window names match.

Return value

Type:

Type: HWND

If the function succeeds, the return value is a handle to the window that has the specified class name and window name.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.