굿

프로세스 강제 종료

· 14년 전 · 1090
Option Explicit

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 Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Const TH32CS_SNAPPROCESS As Long = &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 * 260
End Type
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Const PROCESS_TERMINATE As Long = (&H1)
Private Declare Function TerminateProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Public Function GetPidByImage(ByVal image As String) As Long
On Local Error GoTo ErrOut:
Dim hSnapShot As Long
Dim uProcess As PROCESSENTRY32
Dim r As Long, l As Long

hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot = 0 Then Exit Function
uProcess.dwSize = Len(uProcess)
r = Process32First(hSnapShot, uProcess)
l = Len(image)
If l = 0 Then Exit Function
Do While r
If LCase(Left(uProcess.szExeFile, l)) = LCase(image) Then
GetPidByImage = uProcess.th32ProcessID
Exit Do
End If
r = Process32Next(hSnapShot, uProcess)
Loop
Call CloseHandle(hSnapShot)
ErrOut:
End Function

Public Sub KillPID(ByVal pid As Long)
On Local Error Resume Next
Dim h As Long
If pid = 0 Then Exit Sub
h = OpenProcess(PROCESS_TERMINATE, False, pid)
TerminateProcess h, 0
CloseHandle h
Sleep 1000
ErrOut:
End Sub<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:46:12 기타에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,256
14년 전 조회 1,724
14년 전 조회 1,834
14년 전 조회 1,054
14년 전 조회 2,305
14년 전 조회 2,262
14년 전 조회 1,845
14년 전 조회 1,792
14년 전 조회 1,310
14년 전 조회 1,800
14년 전 조회 1,736
14년 전 조회 1,440
14년 전 조회 1,159
14년 전 조회 2,899
14년 전 조회 2,210
14년 전 조회 1,585
14년 전 조회 2,227
14년 전 조회 1,117
14년 전 조회 1,224
14년 전 조회 1,855
14년 전 조회 1,919
14년 전 조회 1,543
14년 전 조회 1,228
14년 전 조회 1,400
14년 전 조회 1,340
14년 전 조회 2,174
14년 전 조회 2,302
14년 전 조회 2,176
14년 전 조회 1,331
14년 전 조회 1,889
14년 전 조회 1,942
14년 전 조회 2,027
14년 전 조회 3,812
14년 전 조회 1,351
14년 전 조회 2,148
14년 전 조회 1,069
14년 전 조회 1,197
14년 전 조회 1,061
14년 전 조회 1,500
14년 전 조회 1,961
14년 전 조회 1,495
14년 전 조회 1,351
14년 전 조회 1,033
14년 전 조회 1,982
14년 전 조회 1,563
14년 전 조회 1,103
14년 전 조회 2,513
14년 전 조회 1,619
14년 전 조회 1,562
14년 전 조회 1,091
14년 전 조회 1,954
14년 전 조회 2,922
14년 전 조회 1,377
14년 전 조회 823
14년 전 조회 2,350
14년 전 조회 2,115
14년 전 조회 1,067
14년 전 조회 1,636
14년 전 조회 1,818
14년 전 조회 1,676
14년 전 조회 1,034
14년 전 조회 1,006
14년 전 조회 1,320
14년 전 조회 1,635
14년 전 조회 1,493
14년 전 조회 1,189
14년 전 조회 1,593
14년 전 조회 1,436
14년 전 조회 1,734
14년 전 조회 1,186
14년 전 조회 1,422
14년 전 조회 1,204
14년 전 조회 1,565
14년 전 조회 1,033
14년 전 조회 2,443
14년 전 조회 1,631
14년 전 조회 3,226
14년 전 조회 1,612
14년 전 조회 1,384
14년 전 조회 1,436
14년 전 조회 1,426
14년 전 조회 883
14년 전 조회 1,138
14년 전 조회 1,209
14년 전 조회 2,667
14년 전 조회 1,307
14년 전 조회 3,671
14년 전 조회 1,127
14년 전 조회 965
14년 전 조회 1,034
14년 전 조회 2,028
14년 전 조회 1,634
14년 전 조회 1,445
14년 전 조회 1,497
14년 전 조회 1,428
14년 전 조회 1,541
14년 전 조회 1,193
14년 전 조회 795
14년 전 조회 1,313
14년 전 조회 2,474