굿

프로세스 강제 종료

· 15년 전 · 1456
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,676
14년 전 조회 2,164
14년 전 조회 2,296
14년 전 조회 1,487
14년 전 조회 2,736
14년 전 조회 2,726
14년 전 조회 2,296
14년 전 조회 2,253
14년 전 조회 1,765
14년 전 조회 2,251
14년 전 조회 2,160
14년 전 조회 1,891
14년 전 조회 1,572
14년 전 조회 3,322
14년 전 조회 2,639
14년 전 조회 2,006
14년 전 조회 2,643
14년 전 조회 1,526
14년 전 조회 1,628
14년 전 조회 2,261
14년 전 조회 2,329
14년 전 조회 1,956
14년 전 조회 1,650
14년 전 조회 1,807
14년 전 조회 1,784
14년 전 조회 2,580
14년 전 조회 2,706
14년 전 조회 2,610
14년 전 조회 1,726
14년 전 조회 2,306
14년 전 조회 2,331
14년 전 조회 2,417
15년 전 조회 4,211
15년 전 조회 1,759
15년 전 조회 2,574
15년 전 조회 1,485
15년 전 조회 1,619
15년 전 조회 1,474
15년 전 조회 1,919
15년 전 조회 2,339
15년 전 조회 1,888
15년 전 조회 1,747
15년 전 조회 1,417
15년 전 조회 2,405
15년 전 조회 1,971
15년 전 조회 1,522
15년 전 조회 2,891
15년 전 조회 2,010
15년 전 조회 1,924
15년 전 조회 1,457
15년 전 조회 2,340
15년 전 조회 3,300
15년 전 조회 1,685
15년 전 조회 1,147
15년 전 조회 2,677
15년 전 조회 2,424
15년 전 조회 1,368
15년 전 조회 1,955
15년 전 조회 2,114
15년 전 조회 1,961
15년 전 조회 1,336
15년 전 조회 1,304
15년 전 조회 1,630
15년 전 조회 1,931
15년 전 조회 1,792
15년 전 조회 1,454
15년 전 조회 1,901
15년 전 조회 1,737
15년 전 조회 1,995
15년 전 조회 1,476
15년 전 조회 1,714
15년 전 조회 1,503
15년 전 조회 1,863
15년 전 조회 1,319
15년 전 조회 2,718
15년 전 조회 1,924
15년 전 조회 3,509
15년 전 조회 1,900
15년 전 조회 1,661
15년 전 조회 1,729
15년 전 조회 1,723
15년 전 조회 1,170
15년 전 조회 1,427
15년 전 조회 1,495
15년 전 조회 2,944
15년 전 조회 1,577
15년 전 조회 3,950
15년 전 조회 1,416
15년 전 조회 1,244
15년 전 조회 1,335
15년 전 조회 2,319
15년 전 조회 1,929
15년 전 조회 1,736
15년 전 조회 1,790
15년 전 조회 1,705
15년 전 조회 1,811
15년 전 조회 1,464
15년 전 조회 1,070
15년 전 조회 1,583
15년 전 조회 2,743