思路: 使用Form.GetType()、Type.GetValue()、和FiledInfo.GetValue()方法获得一个对于目标控件的引用。然后使用PropertyInfo.GetValue()方法和一个方法委托获得目标控件的属性值:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; using System.Reflection; using System.Drawing; namespace TestingAUT { class Program { static void Main(string[] args) { try { Console.WriteLine("Launching Form...."); //Form theForm = null; string formName = "AUT.Form1"; string Path = @"C:/Users/btslabs/Desktop/TE/AUT/AUT/bin/Debug/AUT.exe"; Form theForm = LaunchApp(Path, formName); MoveForm(theForm, 10, 20); ReSizeForm(theForm, 300, 300); GetFormLocation(theForm); SetCtrlProp(theForm, "textBox1", "Text", "Alex"); GetCtrlProp(theForm, "textBox1", "Text"); Console.WriteLine("/nAUT launched!"); Thread.Sleep(1500); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("Fatal error: " + ex.Message); Console.ReadKey(); } } #region 模块1,运行待测程序. static Form LaunchApp(string path, string formName) { Form result = null; //首先获得一个待测程序窗体对象的引用 //通过工厂机制来创建Assembly对象。 Assembly a = Assembly.LoadFrom(path); //Type的使用,其实就是不知道类名以及类的成员信息的情况下,一种泛泛使用class的概念. Type t = a.GetType(formName); //createInstance()是Assembly对象的方法, 它的参数是被创建实例的全名. //全名称参数是通过一个Type对象来调用的. result = (Form)a.CreateInstance(t.FullName); //using the wrapper class and Thread to launch the App AppState aps = new AppState(result); //要创建一个ThreadStart对象,需要传一个目标方法(Target method)给ThreadStart的构造函数. //这个目标方法必须返回void类型 //当线程开始执行时,要调用的就是这个目标方法.