User32GetWindowTextLength Method

Retrieves the length, in characters, of the specified window's title bar text (if the window has a title bar).

If the specified window is a control, the function retrieves the length of the text within the control. However, GetWindowTextLength(IntPtr) cannot retrieve the length of the text of an edit control in another application.

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", CharSet = CharSet.Auto, SetLastError = true)]
public static int GetWindowTextLength(
	IntPtr hWnd
)

Parameters

hWnd  IntPtr
A handle to the window or control.

Return Value

Int32
If the function succeeds, the return value is the length, in characters, of the text. Under certain conditions, this value may actually be greater than the length of the text.

If the window has no text, the return value is .

To get extended error information, call GetLastWin32Error.

Remarks

See Also