Option Explicit
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 * 260
End Type
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (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 Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Sub cmdRefresh_Click()
Dim hSnapShot As Long, nProcess As Long
Dim uProcess As PROCESSENTRY32
lstProcess.Clear
hSnapShot = CreateToolhelpSnapshot(2, 0)
uProcess.dwSize = LenB(uProcess)
nProcess = Process32First(hSnapShot, uProcess)
Do While nProcess
lstProcess.AddItem uProcess.szExeFile
lstProcess.ItemData(lstProcess.NewIndex) = uProcess.th32ProcessID
nProcess = Process32Next(hSnapShot, uProcess)
Loop
CloseHandle hSnapShot
End Sub
Private Sub cmdKill_Click()
Dim hProcess As Long
'hProcess = OpenProcess(&H1F0FFF, 1, lstProcess.ItemData(lstProcess.ListIndex))
TerminateProcess hProcess, 0
DoEvents
cmdRefresh.Value = True
End Sub
Private Sub Command1_Click()
About.Show 1
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub form_Load()
WinToCenter Me
cmdRefresh.Value = True
End Sub