我想使用 TerminateProcess    API来终止一个进程
它的hProcess参数想过这个可执行文件的文件名来获取。请问该用那个API?多谢!

解决方案 »

  1.   

    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As _
        Long, lpdwProcessId As Long) As Long
    Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As _
        Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Longaa = FindWindow(vbNullString, "文件名")
       
       GetWindowThreadProcessId aa, pID
          phandle = 0
       phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pID)
       If (phandle = 0) Then
             MsgBox "Unable to open process!"
       End If
    phandle 为进程句柄.