您的位置:首页 > 编程语言 > C#

c#调用GetWindowText函数

2015-08-27 15:35 621 查看
[DllImport("user32.dll")]
public static extern int GetWindowTextLength(IntPtr hWnd);

[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int nMaxCount);
int length = GetWindowTextLength(hWnd);
StringBuilder windowName = new StringBuilder(length + 1);
GetWindowText(hWnd, windowName, windowName.Capacity);

用DllImport声明GetWindowText时,千万别跟第2个参数加out。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: