굿

프로세스 강제 종료

· 15년 전 · 1401
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,615
14년 전 조회 2,093
14년 전 조회 2,222
14년 전 조회 1,414
14년 전 조회 2,671
14년 전 조회 2,656
14년 전 조회 2,230
14년 전 조회 2,191
14년 전 조회 1,698
14년 전 조회 2,182
14년 전 조회 2,092
14년 전 조회 1,820
14년 전 조회 1,520
14년 전 조회 3,255
14년 전 조회 2,584
14년 전 조회 1,940
14년 전 조회 2,580
14년 전 조회 1,455
14년 전 조회 1,571
14년 전 조회 2,199
14년 전 조회 2,278
14년 전 조회 1,892
14년 전 조회 1,586
14년 전 조회 1,748
14년 전 조회 1,708
14년 전 조회 2,516
14년 전 조회 2,647
14년 전 조회 2,544
14년 전 조회 1,661
14년 전 조회 2,241
14년 전 조회 2,276
14년 전 조회 2,357
14년 전 조회 4,152
14년 전 조회 1,691
14년 전 조회 2,515
14년 전 조회 1,425
14년 전 조회 1,554
14년 전 조회 1,416
14년 전 조회 1,860
14년 전 조회 2,275
14년 전 조회 1,838
15년 전 조회 1,691
15년 전 조회 1,361
15년 전 조회 2,340
15년 전 조회 1,927
15년 전 조회 1,455
15년 전 조회 2,843
15년 전 조회 1,951
15년 전 조회 1,879
15년 전 조회 1,402
15년 전 조회 2,279
15년 전 조회 3,245
15년 전 조회 1,635
15년 전 조회 1,098
15년 전 조회 2,623
15년 전 조회 2,368
15년 전 조회 1,321
15년 전 조회 1,899
15년 전 조회 2,057
15년 전 조회 1,911
15년 전 조회 1,280
15년 전 조회 1,255
15년 전 조회 1,573
15년 전 조회 1,877
15년 전 조회 1,738
15년 전 조회 1,410
15년 전 조회 1,849
15년 전 조회 1,680
15년 전 조회 1,949
15년 전 조회 1,422
15년 전 조회 1,662
15년 전 조회 1,464
15년 전 조회 1,808
15년 전 조회 1,282
15년 전 조회 2,679
15년 전 조회 1,881
15년 전 조회 3,460
15년 전 조회 1,858
15년 전 조회 1,620
15년 전 조회 1,677
15년 전 조회 1,676
15년 전 조회 1,126
15년 전 조회 1,389
15년 전 조회 1,451
15년 전 조회 2,895
15년 전 조회 1,535
15년 전 조회 3,902
15년 전 조회 1,375
15년 전 조회 1,211
15년 전 조회 1,288
15년 전 조회 2,261
15년 전 조회 1,884
15년 전 조회 1,685
15년 전 조회 1,743
15년 전 조회 1,660
15년 전 조회 1,768
15년 전 조회 1,421
15년 전 조회 1,029
15년 전 조회 1,542
15년 전 조회 2,702