Function:
GetWindowText(HWNDhWnd,LPSTRlpString,intnMaxCount)

 

Description:
Copies the text of the specified window’s title bar (if it has one) into a buffer. I found that this function would only work when loaded directly from the user32.dll where it is named GetWindowTextA.

 

Parameters:
hWnd: Identifies the window or control containing the text.

lpString: Points to the buffer that will receive the text

nMaxCount:
Specifies the maximum number of characters to copy to the buffer, including the NULL character. If the text exceeds this limit, it is truncated.

 

Returns:
If the function succeeds, the return value is the length, in characters, of the copied string, not including the terminating null character. If the window has no title bar or text, if the title bar is empty, or if the window or control handle is invalid, the return value is zero.

 

Example:
Click on the calc icon to view a sample of the GetWindowText function.