굿

프로세스 강제 종료

· 14년 전 · 1034
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,194
14년 전 조회 1,644
14년 전 조회 1,779
14년 전 조회 997
14년 전 조회 2,242
14년 전 조회 2,206
14년 전 조회 1,785
14년 전 조회 1,744
14년 전 조회 1,254
14년 전 조회 1,755
14년 전 조회 1,680
14년 전 조회 1,386
14년 전 조회 1,112
14년 전 조회 2,846
14년 전 조회 2,166
14년 전 조회 1,532
14년 전 조회 2,183
14년 전 조회 1,068
14년 전 조회 1,168
14년 전 조회 1,804
14년 전 조회 1,873
14년 전 조회 1,495
14년 전 조회 1,180
14년 전 조회 1,354
14년 전 조회 1,291
14년 전 조회 2,131
14년 전 조회 2,249
14년 전 조회 2,130
14년 전 조회 1,279
14년 전 조회 1,838
14년 전 조회 1,881
14년 전 조회 1,972
14년 전 조회 3,762
14년 전 조회 1,302
14년 전 조회 2,106
14년 전 조회 1,022
14년 전 조회 1,146
14년 전 조회 1,003
14년 전 조회 1,458
14년 전 조회 1,913
14년 전 조회 1,451
14년 전 조회 1,313
14년 전 조회 975
14년 전 조회 1,940
14년 전 조회 1,516
14년 전 조회 1,067
14년 전 조회 2,465
14년 전 조회 1,574
14년 전 조회 1,509
14년 전 조회 1,035
14년 전 조회 1,911
14년 전 조회 2,874
14년 전 조회 1,346
14년 전 조회 781
14년 전 조회 2,322
14년 전 조회 2,088
14년 전 조회 1,032
14년 전 조회 1,607
14년 전 조회 1,784
14년 전 조회 1,651
14년 전 조회 1,011
14년 전 조회 969
14년 전 조회 1,285
14년 전 조회 1,597
14년 전 조회 1,466
14년 전 조회 1,156
14년 전 조회 1,571
14년 전 조회 1,413
14년 전 조회 1,707
14년 전 조회 1,167
14년 전 조회 1,389
14년 전 조회 1,178
14년 전 조회 1,535
14년 전 조회 1,002
14년 전 조회 2,416
14년 전 조회 1,599
14년 전 조회 3,195
14년 전 조회 1,583
14년 전 조회 1,361
14년 전 조회 1,403
14년 전 조회 1,401
14년 전 조회 862
14년 전 조회 1,103
14년 전 조회 1,176
14년 전 조회 2,631
14년 전 조회 1,275
14년 전 조회 3,637
14년 전 조회 1,095
14년 전 조회 935
14년 전 조회 1,006
14년 전 조회 1,999
14년 전 조회 1,607
14년 전 조회 1,418
14년 전 조회 1,469
14년 전 조회 1,402
14년 전 조회 1,511
14년 전 조회 1,167
14년 전 조회 768
14년 전 조회 1,279
14년 전 조회 2,446