User32GetWindowText(SafeHandle, StringBuilder, Int32) Method
Copies the text of the specified window's title bar (if it has one) into a buffer.
If the specified window is a control, the text of the control is copied.
GetWindowText(IntPtr, StringBuilder, Int32) cannot retrieve the text of a control in another application than the calling application.
Namespace: DevCase.Win32.NativeMethodsAssembly: 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.Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
public static int GetWindowText(
SafeHandle hWnd,
StringBuilder lpString,
int cch
)
<DllImportAttribute("User32.dll", CharSet := CharSet.Ansi, BestFitMapping := false,
ThrowOnUnmappableChar := true, SetLastError := true>]
Public Shared Function GetWindowText (
hWnd As SafeHandle,
lpString As StringBuilder,
cch As Integer
) As Integer
Dim hWnd As SafeHandle
Dim lpString As StringBuilder
Dim cch As Integer
Dim returnValue As Integer
returnValue = User32.GetWindowText(hWnd,
lpString, cch)
public:
[DllImportAttribute(L"User32.dll", CharSet = CharSet::Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
static int GetWindowText(
SafeHandle^ hWnd,
StringBuilder^ lpString,
int cch
)
[<DllImportAttribute("User32.dll", CharSet = CharSet.Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)>]
static member GetWindowText :
hWnd : SafeHandle *
lpString : StringBuilder *
cch : int -> int
No code example is currently available or this language may not be supported.
- hWnd SafeHandle
-
A handle to the window or control containing the text.
- lpString StringBuilder
-
The buffer that will receive the text.
If the string is as long or longer than the buffer, the string is truncated and terminated with a null character.
- cch Int32
-
The maximum number of characters to copy to the buffer, including the null character.
If the text exceeds this limit, it is truncated.
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 zero.
To get extended error information, call
GetLastWin32Error.