hWnd [in]
Type: HWND
A handle to the window or control containing the text.
一个指向特定窗口或控件的句柄。 lpString [out]Type: LPTSTR
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. 一个用来接受文本的缓冲区。如果(取回的)字符串与缓冲区等长或者比缓冲区长,那么该字串会被截断,并用NULL字符结束。 nMaxCount [in]Type: int
The maximum number of characters to copy to the buffer, including the null character. If the text exceeds this limit, it is truncated.
将要拷贝到缓冲区中的字符的最大个数,包括NULL字符。如果目标TEXT超出限制则会被截断。 最后 经测试正确的
[DllImport("user32.dll")]
public static extern int GetWindowTextA(int hwnd, StringBuilder Title,int Length);
StringBuilder Title=new StringBuilder(256);//缓冲区
GetWindowTextA(hwnd, Title, 256);
MessageBox.Show( Title );