以前在写两个进程中的窗口互相配合使用时,在激活窗口谈到最前面时,是要分几步走的,还要考虑最小化最大化正常情况的状态。原来用这个API就不用费神了。SwitchToThisWindow。缺点:隐藏的窗口切换不出来。 C# [DllImport("user32.dll", EntryPoint = "SwitchToThisWindow")] private static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab); private void button1_Click(object sender, EventArgs e) { SwitchToThisWindow((IntPtr)0xd0516/*窗口句柄*/, true); } VB.NET Private Declare Function SwitchToThisWindow Lib "user32.dll" (ByVal HWND As Long, ByVal fAltTab As Boolean) As Long Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SwitchToThisWindow(&HD0516, True)'&HD0516为窗口句柄 End Sub