[DllImport("user32.dll", EntryPoint = "FindWindowEx",SetLastError = true)]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtrhwndChildAfter, string lpszClass, string lpszWindow);
IntPtr hwndCalc = FindWindow(null, "计算器"); //查找计算器的句柄
if (hwndCalc != IntPtr.Zero)
{
//取计算器下面的对象CalFrame
IntPtr hwndThree = FindWindowEx(hwndCalc, IntPtr.Zero, "CalcFrame",null);
//取CalFrame下面的Static
IntPtr hwndPlus = FindWindowEx(hwndThree, IntPtr.Zero, "Static",null);
//取CalFrame下面的第一个对话框
IntPtr hwndTwo = FindWindowEx(hwndThree, IntPtr.Zero, "#32770",null);
//取CalFrame下面的第二个对话框
IntPtr hwndEqual = FindWindowEx(hwndThree, hwndTwo, "#32770",null);
}
WIN7-64、VS2010下编译通过。