굿

프로세스 강제 종료

· 14년 전 · 1069
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,232
14년 전 조회 1,703
14년 전 조회 1,804
14년 전 조회 1,034
14년 전 조회 2,278
14년 전 조회 2,241
14년 전 조회 1,826
14년 전 조회 1,766
14년 전 조회 1,291
14년 전 조회 1,781
14년 전 조회 1,721
14년 전 조회 1,426
14년 전 조회 1,142
14년 전 조회 2,876
14년 전 조회 2,192
14년 전 조회 1,572
14년 전 조회 2,215
14년 전 조회 1,102
14년 전 조회 1,205
14년 전 조회 1,833
14년 전 조회 1,903
14년 전 조회 1,519
14년 전 조회 1,211
14년 전 조회 1,381
14년 전 조회 1,320
14년 전 조회 2,157
14년 전 조회 2,289
14년 전 조회 2,156
14년 전 조회 1,312
14년 전 조회 1,867
14년 전 조회 1,914
14년 전 조회 2,003
14년 전 조회 3,787
14년 전 조회 1,337
14년 전 조회 2,132
14년 전 조회 1,042
14년 전 조회 1,174
14년 전 조회 1,040
14년 전 조회 1,480
14년 전 조회 1,941
14년 전 조회 1,476
14년 전 조회 1,335
14년 전 조회 1,017
14년 전 조회 1,964
14년 전 조회 1,542
14년 전 조회 1,091
14년 전 조회 2,497
14년 전 조회 1,599
14년 전 조회 1,539
14년 전 조회 1,070
14년 전 조회 1,941
14년 전 조회 2,903
14년 전 조회 1,365
14년 전 조회 809
14년 전 조회 2,342
14년 전 조회 2,104
14년 전 조회 1,057
14년 전 조회 1,623
14년 전 조회 1,809
14년 전 조회 1,671
14년 전 조회 1,023
14년 전 조회 986
14년 전 조회 1,308
14년 전 조회 1,625
14년 전 조회 1,483
14년 전 조회 1,179
14년 전 조회 1,583
14년 전 조회 1,429
14년 전 조회 1,725
14년 전 조회 1,184
14년 전 조회 1,416
14년 전 조회 1,193
14년 전 조회 1,553
14년 전 조회 1,025
14년 전 조회 2,435
14년 전 조회 1,623
14년 전 조회 3,220
14년 전 조회 1,597
14년 전 조회 1,376
14년 전 조회 1,425
14년 전 조회 1,411
14년 전 조회 875
14년 전 조회 1,131
14년 전 조회 1,201
14년 전 조회 2,654
14년 전 조회 1,298
14년 전 조회 3,666
14년 전 조회 1,115
14년 전 조회 952
14년 전 조회 1,026
14년 전 조회 2,018
14년 전 조회 1,623
14년 전 조회 1,438
14년 전 조회 1,485
14년 전 조회 1,419
14년 전 조회 1,531
14년 전 조회 1,181
14년 전 조회 782
14년 전 조회 1,296
14년 전 조회 2,468