굿

프로세스 강제 종료

· 15년 전 · 1458
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,676
14년 전 조회 2,166
14년 전 조회 2,297
14년 전 조회 1,489
14년 전 조회 2,736
14년 전 조회 2,726
14년 전 조회 2,297
14년 전 조회 2,253
14년 전 조회 1,766
14년 전 조회 2,252
14년 전 조회 2,161
14년 전 조회 1,892
14년 전 조회 1,573
14년 전 조회 3,324
14년 전 조회 2,640
14년 전 조회 2,006
14년 전 조회 2,644
14년 전 조회 1,526
14년 전 조회 1,628
14년 전 조회 2,262
14년 전 조회 2,329
14년 전 조회 1,957
14년 전 조회 1,652
14년 전 조회 1,809
14년 전 조회 1,784
14년 전 조회 2,580
14년 전 조회 2,706
14년 전 조회 2,610
14년 전 조회 1,727
14년 전 조회 2,307
14년 전 조회 2,334
14년 전 조회 2,418
15년 전 조회 4,211
15년 전 조회 1,760
15년 전 조회 2,576
15년 전 조회 1,485
15년 전 조회 1,620
15년 전 조회 1,474
15년 전 조회 1,920
15년 전 조회 2,341
15년 전 조회 1,889
15년 전 조회 1,748
15년 전 조회 1,419
15년 전 조회 2,406
15년 전 조회 1,971
15년 전 조회 1,524
15년 전 조회 2,893
15년 전 조회 2,011
15년 전 조회 1,925
15년 전 조회 1,459
15년 전 조회 2,341
15년 전 조회 3,301
15년 전 조회 1,685
15년 전 조회 1,148
15년 전 조회 2,677
15년 전 조회 2,426
15년 전 조회 1,368
15년 전 조회 1,955
15년 전 조회 2,116
15년 전 조회 1,961
15년 전 조회 1,336
15년 전 조회 1,304
15년 전 조회 1,631
15년 전 조회 1,932
15년 전 조회 1,793
15년 전 조회 1,456
15년 전 조회 1,902
15년 전 조회 1,738
15년 전 조회 1,997
15년 전 조회 1,478
15년 전 조회 1,715
15년 전 조회 1,503
15년 전 조회 1,863
15년 전 조회 1,319
15년 전 조회 2,720
15년 전 조회 1,924
15년 전 조회 3,510
15년 전 조회 1,901
15년 전 조회 1,661
15년 전 조회 1,729
15년 전 조회 1,724
15년 전 조회 1,171
15년 전 조회 1,427
15년 전 조회 1,495
15년 전 조회 2,946
15년 전 조회 1,577
15년 전 조회 3,951
15년 전 조회 1,418
15년 전 조회 1,244
15년 전 조회 1,335
15년 전 조회 2,319
15년 전 조회 1,930
15년 전 조회 1,736
15년 전 조회 1,791
15년 전 조회 1,706
15년 전 조회 1,812
15년 전 조회 1,465
15년 전 조회 1,071
15년 전 조회 1,585
15년 전 조회 2,743