굿

프로세스 강제 종료

· 14년 전 · 895
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,054
14년 전 조회 1,479
14년 전 조회 1,645
14년 전 조회 843
14년 전 조회 2,092
14년 전 조회 2,068
14년 전 조회 1,655
14년 전 조회 1,607
14년 전 조회 1,123
14년 전 조회 1,602
14년 전 조회 1,531
14년 전 조회 1,243
14년 전 조회 975
14년 전 조회 2,723
14년 전 조회 2,033
14년 전 조회 1,387
14년 전 조회 2,046
14년 전 조회 922
14년 전 조회 1,020
14년 전 조회 1,646
14년 전 조회 1,751
14년 전 조회 1,353
14년 전 조회 1,042
14년 전 조회 1,210
14년 전 조회 1,148
14년 전 조회 1,995
14년 전 조회 2,121
14년 전 조회 1,994
14년 전 조회 1,127
14년 전 조회 1,696
14년 전 조회 1,753
14년 전 조회 1,849
14년 전 조회 3,623
14년 전 조회 1,174
14년 전 조회 1,975
14년 전 조회 890
14년 전 조회 1,023
14년 전 조회 873
14년 전 조회 1,326
14년 전 조회 1,783
14년 전 조회 1,321
14년 전 조회 1,171
14년 전 조회 832
14년 전 조회 1,809
14년 전 조회 1,380
14년 전 조회 940
14년 전 조회 2,327
14년 전 조회 1,441
14년 전 조회 1,360
14년 전 조회 896
14년 전 조회 1,766
14년 전 조회 2,737
14년 전 조회 1,233
14년 전 조회 631
14년 전 조회 2,191
14년 전 조회 1,951
14년 전 조회 899
14년 전 조회 1,482
14년 전 조회 1,658
14년 전 조회 1,517
14년 전 조회 878
14년 전 조회 847
14년 전 조회 1,154
14년 전 조회 1,478
14년 전 조회 1,333
14년 전 조회 1,016
14년 전 조회 1,445
14년 전 조회 1,289
14년 전 조회 1,564
14년 전 조회 1,011
14년 전 조회 1,250
14년 전 조회 1,050
14년 전 조회 1,406
14년 전 조회 872
14년 전 조회 2,266
14년 전 조회 1,478
14년 전 조회 3,077
14년 전 조회 1,451
14년 전 조회 1,223
14년 전 조회 1,270
14년 전 조회 1,271
14년 전 조회 737
14년 전 조회 996
14년 전 조회 1,037
14년 전 조회 2,496
14년 전 조회 1,132
14년 전 조회 3,493
14년 전 조회 966
14년 전 조회 800
14년 전 조회 867
14년 전 조회 1,850
14년 전 조회 1,470
14년 전 조회 1,283
14년 전 조회 1,344
14년 전 조회 1,273
14년 전 조회 1,376
14년 전 조회 1,033
14년 전 조회 638
14년 전 조회 1,149
14년 전 조회 2,303
🐛 버그신고