Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long '取句柄
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long '判断窗体是否可见
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long '控制窗口的可见性
Private Const SW_SHOW = 5
Private Const SW_HIDE = 0
Private Sub Command1_Click()
Dim a As Long
a = FindWindow(vbNullString, "QQ2011") '查找QQ句柄
If IsWindowVisible(a) Then '如果可见
ShowWindow a, SW_HIDE '则隐藏
Else
ShowWindow a, SW_SHOW '反之不隐藏
End If
End Sub