我怎么强制终止另外一个启动了的exe文件?
只要是在任务管理器存在,随时想终止它,也能随时启动它!

解决方案 »

  1.   

    Dim uProcess As PROCESSENTRY32
        Dim mSnapShot As Long
        Dim mName As String‘要关闭的进程名称
        Dim mSY As Long
        Dim i As Integer
        Dim mProcID As Long
        Dim mresult
        DoEvents
        uProcess.dwSize = Len(uProcess)
        mSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
        If mSnapShot Then
            mresult = ProcessFirst(mSnapShot, uProcess)'获取进程名称
                    Do While mresult’遍历进程
                i = InStr(1, uProcess.szexeFile, Chr(0))
                mName = LCase$(Left$(uProcess.szexeFile, i - 1))
                If InStr(1, LCase(pro), mName) <> 0 Then
                    mProcID = OpenProcess(1&, -1&, uProcess.th32ProcessID)
                    TerminateProcess mProcID, 0&                    
                     Exit Sub
                End If
                mresult = ProcessNext(mSnapShot, uProcess)
            Loop
        End If