using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms; using System.Diagnostics;using System.Threading;using System.Runtime.InteropServices; namespace T1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("User32.dll")] private static extern void SendMessage(IntPtr hwnd, int msg, int wParam, int lParam); private void button1_Click(object sender, EventArgs e) { Process p = Process.Start("T2.exe"); Thread.Sleep(200);//短暂等待程序启动 IntPtr hWnd=p.MainWindowHandle; Text = hWnd.ToString(); SendMessage(hWnd, 0, 0, 0); } }}