我帮你写了个例子,按Command1是挂起进程的一个线程,按Command2是恢复这个线程,至于这个进程名是否有重复的,或者这个进程是否有多个现程都没有判断,你可以自己根据这个例子来添加代码。
Option Explicit
Private Const MAX_PATH As Integer = 260
Private Const TH32CS_SNAPPROCESS = &H2
Private Const TH32CS_SNAPTHREAD = &H4
Private Const THREAD_SUSPEND_RESUME = &H2
Private Type PROCESSENTRY32
dwsize As Long
cntusage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Type THREADENTRY32
dwsize As Long
cntusage As Long
th32threadID As Long
th32OwnerProcessID As Long
tpBasePri As Long
tpDeltaPri As Long
dwFlags As Long
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Thread32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As THREADENTRY32) As Long
Private Declare Function Thread32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As THREADENTRY32) As Long
Private Declare Function OpenThread Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwThreadId As Long) As Long
Private Declare Function SuspendThread Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function ResumeThread Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Function SuspendOrResumeThread(ByVal dwProcessName As String, ByVal cbSuspend As Boolean) As Boolean
Dim dwRet As Boolean
Dim FindProcess As Boolean, FindThread As Boolean
Dim hSnapshot As Long, hThread As Long
Dim pe32 As PROCESSENTRY32, peZero As PROCESSENTRY32
Dim te32 As THREADENTRY32, teZero As THREADENTRY32
Dim tempStr As String
Dim tempNum As Long
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If hSnapshot <> 0 Then
pe32.dwsize = LenB(pe32)
If Process32First(hSnapshot, pe32) <> 0 Then