굿

프로세스 강제 종료

· 15년 전 · 1418
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,620
14년 전 조회 2,103
14년 전 조회 2,233
14년 전 조회 1,423
14년 전 조회 2,679
14년 전 조회 2,667
14년 전 조회 2,238
14년 전 조회 2,200
14년 전 조회 1,704
14년 전 조회 2,192
14년 전 조회 2,099
14년 전 조회 1,828
14년 전 조회 1,528
14년 전 조회 3,267
14년 전 조회 2,594
14년 전 조회 1,951
14년 전 조회 2,593
14년 전 조회 1,467
14년 전 조회 1,582
14년 전 조회 2,211
14년 전 조회 2,293
14년 전 조회 1,907
14년 전 조회 1,595
14년 전 조회 1,757
14년 전 조회 1,719
14년 전 조회 2,529
14년 전 조회 2,655
14년 전 조회 2,555
14년 전 조회 1,672
14년 전 조회 2,252
14년 전 조회 2,290
14년 전 조회 2,372
14년 전 조회 4,165
14년 전 조회 1,703
14년 전 조회 2,527
14년 전 조회 1,437
14년 전 조회 1,566
14년 전 조회 1,425
14년 전 조회 1,873
15년 전 조회 2,283
15년 전 조회 1,845
15년 전 조회 1,705
15년 전 조회 1,370
15년 전 조회 2,349
15년 전 조회 1,933
15년 전 조회 1,469
15년 전 조회 2,848
15년 전 조회 1,966
15년 전 조회 1,891
15년 전 조회 1,419
15년 전 조회 2,287
15년 전 조회 3,256
15년 전 조회 1,645
15년 전 조회 1,103
15년 전 조회 2,633
15년 전 조회 2,378
15년 전 조회 1,327
15년 전 조회 1,910
15년 전 조회 2,066
15년 전 조회 1,917
15년 전 조회 1,286
15년 전 조회 1,262
15년 전 조회 1,581
15년 전 조회 1,887
15년 전 조회 1,742
15년 전 조회 1,416
15년 전 조회 1,854
15년 전 조회 1,688
15년 전 조회 1,960
15년 전 조회 1,428
15년 전 조회 1,666
15년 전 조회 1,466
15년 전 조회 1,816
15년 전 조회 1,284
15년 전 조회 2,683
15년 전 조회 1,888
15년 전 조회 3,468
15년 전 조회 1,861
15년 전 조회 1,623
15년 전 조회 1,686
15년 전 조회 1,681
15년 전 조회 1,128
15년 전 조회 1,392
15년 전 조회 1,455
15년 전 조회 2,900
15년 전 조회 1,541
15년 전 조회 3,908
15년 전 조회 1,382
15년 전 조회 1,215
15년 전 조회 1,295
15년 전 조회 2,267
15년 전 조회 1,892
15년 전 조회 1,691
15년 전 조회 1,749
15년 전 조회 1,664
15년 전 조회 1,773
15년 전 조회 1,429
15년 전 조회 1,034
15년 전 조회 1,546
15년 전 조회 2,707