怎樣殺掉已經啟動得EXE

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3228/3228845.xml?temp=.5653803
    http://vip.6to23.com/nowcan1/tech/remotethread1.htm
    http://vip.6to23.com/nowcan1/tech/remotethread2.htm
    http://vip.6to23.com/nowcan1/tech/remotethread3.htm
      

  2.   

    用enumwindows枚举所有的窗口然后用sendmessage这个API发送WM_CLOSE消息
      

  3.   

    toolhelp32snap函数组枚举所有进程,找你要kill的进程
    包括
    createtoolhelp32snapshort
    Process32First
    Process32Next
    openprocess 取得进程的句柄
    terminateprocess 关闭该进程
        Dim lngProcessid As Long
        Dim hProcess As Long
         
            hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, lngProcessid) 'lngProcessid为用toolhelp32snap函数得到的该进程的processid,而
            If (hProcess = 0) Then Exit Sub
            TerminateProcess hProcess, 0
            CloseHandle hProcess
            
      

  4.   

    Option Explicit
    Const PROCESS_QUERY_INFORMATION = &H400
    Const PROCESS_TERMINATE = &H1
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As LongSub main()
        Dim ProcessId As Long
        Dim hProcess  As Long
        ProcessId = Shell("notepad.exe", 1) '此处利用了 Shell当函数使用时返回的任务标识
        hProcess = OpenProcess(PROCESS_TERMINATE Or PROCESS_QUERY_INFORMATION, False, ProcessId)
        Call TerminateProcess(hProcess, 3838)
    End Sub
      

  5.   

    If you know the program's caption (title in title bar)Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst WM_CLOSE = &H10Private Sub Form_Load()
        Dim WinWnd As Long     WinWnd = FindWindow(vbNullString, "Title Of Window")    If WinWnd <> 0 Then 
            PostMessage WinWnd, WM_CLOSE, 0&, 0&
        Else
            MsgBox "No window of that name exists." 
        End If
    End Sub