User32InternalGetWindowText Method

Copies the text of the specified window's title bar (if it has one) into a buffer.

This function is similar to the GetWindowText(IntPtr, StringBuilder, Int32) function. However, it obtains the window text directly from the window structure associated with the specified window's handle and then always provides the text as a Unicode string.

This is unlike GetWindowText(IntPtr, StringBuilder, Int32) which obtains the text by sending the window a WM_GetText message.

If the specified window is a control, the text of the control is obtained.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", ExactSpelling = true, SetLastError = true)]
public static int InternalGetWindowText(
	IntPtr hWnd,
	StringBuilder buffer,
	int maxCount
)

Parameters

hWnd  IntPtr
A handle to the window or control containing the text.
buffer  StringBuilder
The buffer that is to receive the text.
maxCount  Int32
The maximum number of characters to be copied to the buffer, including the null character.

If the text exceeds this limit, it is truncated

Return Value

Int32
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 .

To get extended error information, call GetLastWin32Error.

Remarks

See Also