GetWindowText (user32)
Last changed: -71.239.92.169

.
Summary

C# Signature:

[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

public string GetText(IntPtr hWnd)
{
    // Allocate correct string length first
    int length       = GetWindowTextLength(hWnd);
    StringBuilder sb = new StringBuilder(length);
    GetWindowText(hWnd, sb, sb.Capacity);
    return sb.ToString();
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation