1.已知可执行程序的名字a.exe,如何判断程序是否已经在运行?怎么杀死它?
   
  
2.已知对话框的窗口标题“**”,怎么判断对话框已经弹出(以下程序代码不知道为什么没有举出所有窗口),并用代码关掉该窗口?
   
   Private Sub Command1_Click()
   Dim co As Variant
    List1.Clear
    Call EnumWindows(AddressOf EnumWindowsProc, 0&)
    For Each co In coll
    If Mid(co, 1, 3) = "-!@" Then
       co = "Class Name:" + Mid(co, 4)
    End If
    List1.AddItem co
    Next
End Sub
'hWnd是Window传给我们的Window handle,而lParam是我们呼叫EnumWindows()时的第
'二个叁数值,在这个例子中,我们传0进来,所以lParam一直是0
Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
    Dim S As String, pid As Long
     If GetParent(hwnd) = 0 Then
       '读取 hWnd 的视窗标题
       S = String(80, 0)
       Call GetWindowText(hwnd, S, 80)
       S = Left(S, InStr(S, Chr(0)) - 1)
       Call GetWindowThreadProcessId(hwnd, pid)
       '当没有标题的hWnd之pid被加入Coll的Collection时,若pid重覆会有错,我们不管它
       On Error Resume Next
       If Len(S) = 0 Then
      '没有标题,则记录Class Name
      S = String(255, 0)
      Call GetClassName(hwnd, S, 255)
      S = Left(S, InStr(S, Chr(0)) - 1)
      coll.Add "-!@" + S, Str(pid) 'key 为Pid
       Else
      '如果相同的pid记录两次,便会产生err, 而去执行errh的程序
      On Error GoTo errh
      If IsWindowVisible(hwnd) Then
         coll.Add S, Str(pid)
      End If
       End If
    End If
    EnumWindowsProc = True ' 表示继续列举 hWnd
    Exit Function
errh:
    '如果先前coll 记录key=pid的 那个Item记录的是ClassName,则Item以Window
    '的Title来取代
    If Mid(coll.Item(Str(pid)), 1, 3) = "-!@" Then '表示先前以ClassName记录
       coll.Remove (Str(pid))
       coll.Add S, Str(pid)
    End If
    EnumWindowsProc = True ' 表示继续列举 hWnd
End Function