굿

프로세스 강제 종료

· 15년 전 · 1435
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,647
14년 전 조회 2,129
14년 전 조회 2,264
14년 전 조회 1,447
14년 전 조회 2,702
14년 전 조회 2,696
14년 전 조회 2,261
14년 전 조회 2,222
14년 전 조회 1,728
14년 전 조회 2,217
14년 전 조회 2,122
14년 전 조회 1,863
14년 전 조회 1,548
14년 전 조회 3,289
14년 전 조회 2,619
14년 전 조회 1,978
14년 전 조회 2,615
14년 전 조회 1,496
14년 전 조회 1,600
14년 전 조회 2,233
14년 전 조회 2,309
14년 전 조회 1,929
14년 전 조회 1,620
14년 전 조회 1,784
14년 전 조회 1,745
14년 전 조회 2,548
14년 전 조회 2,677
14년 전 조회 2,574
14년 전 조회 1,686
14년 전 조회 2,274
14년 전 조회 2,309
14년 전 조회 2,391
14년 전 조회 4,189
14년 전 조회 1,722
14년 전 조회 2,544
14년 전 조회 1,457
14년 전 조회 1,592
14년 전 조회 1,439
15년 전 조회 1,892
15년 전 조회 2,311
15년 전 조회 1,866
15년 전 조회 1,729
15년 전 조회 1,383
15년 전 조회 2,363
15년 전 조회 1,945
15년 전 조회 1,489
15년 전 조회 2,870
15년 전 조회 1,988
15년 전 조회 1,905
15년 전 조회 1,436
15년 전 조회 2,316
15년 전 조회 3,278
15년 전 조회 1,662
15년 전 조회 1,123
15년 전 조회 2,649
15년 전 조회 2,398
15년 전 조회 1,344
15년 전 조회 1,924
15년 전 조회 2,084
15년 전 조회 1,939
15년 전 조회 1,308
15년 전 조회 1,276
15년 전 조회 1,606
15년 전 조회 1,904
15년 전 조회 1,753
15년 전 조회 1,432
15년 전 조회 1,880
15년 전 조회 1,705
15년 전 조회 1,970
15년 전 조회 1,446
15년 전 조회 1,687
15년 전 조회 1,479
15년 전 조회 1,831
15년 전 조회 1,302
15년 전 조회 2,697
15년 전 조회 1,904
15년 전 조회 3,483
15년 전 조회 1,879
15년 전 조회 1,636
15년 전 조회 1,705
15년 전 조회 1,697
15년 전 조회 1,148
15년 전 조회 1,403
15년 전 조회 1,469
15년 전 조회 2,919
15년 전 조회 1,555
15년 전 조회 3,927
15년 전 조회 1,396
15년 전 조회 1,222
15년 전 조회 1,305
15년 전 조회 2,286
15년 전 조회 1,905
15년 전 조회 1,711
15년 전 조회 1,766
15년 전 조회 1,680
15년 전 조회 1,782
15년 전 조회 1,441
15년 전 조회 1,052
15년 전 조회 1,562
15년 전 조회 2,720