private void timer1_Tick(object sender, EventArgs e) { IntPtr handle1 = Classpub.FindWindow(null, "MessageBox1111"); if (handle1 != IntPtr.Zero) { Classpub.PostMessage(handle1, Classpub.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); //MessageBox.Show("MessageBox"); } }
private void button6_Click(object sender, EventArgs e) { IntPtr handle1 = Classpub.FindWindow(null, "chuangkou2"); if (handle1 != IntPtr.Zero) { Classpub.SendMessage(handle1, Classpub.WM_CLOSE, 0, 0); //MessageBox.Show("chuangkou2", "MessageBox1111"); //MessageBox.Show("sendmessage 这里是跟随运行的窗口", "窗口"); } }
private void button5_Click(object sender, EventArgs e) { IntPtr handle1 = Classpub.FindWindow(null, "chuangkou1"); if (handle1 != IntPtr.Zero) { Classpub.PostMessage(handle1, Classpub.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); //MessageBox.Show("chuangkou1", "MessageBox1111"); //MessageBox.Show("postmessage 这里是跟随运行的窗口", "窗口"); } }