如何取出遍历窗口控件后的句柄?
public System.Collections.ArrayList handleList = new System.Collections.ArrayList();
public void GetHandle(Control.ControlCollection controls)
{
if (controls != null)
{
foreach (Control c in controls)
{
handleList.Add(c.Handle);
GetHandle(c.Controls);
}
}
else
{
return;
}
}
private void button5_Click(object sender, EventArgs e)
{
k = FindWindow(null, "人员信息");
GetHandle(this.Controls);
int y = Convert.ToInt32(handleList[5]);
MessageBox.Show(y.ToString());
}
前面的是网上下的,似乎正确,最后一段是我想取出“人员信息”窗口中的控件句柄,有错误,不知怎么改?