굿

프로세스 강제 종료

· 14년 전 · 1279
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,475
14년 전 조회 1,952
14년 전 조회 2,076
14년 전 조회 1,280
14년 전 조회 2,523
14년 전 조회 2,507
14년 전 조회 2,089
14년 전 조회 2,030
14년 전 조회 1,560
14년 전 조회 2,042
14년 전 조회 1,966
14년 전 조회 1,668
14년 전 조회 1,369
14년 전 조회 3,123
14년 전 조회 2,439
14년 전 조회 1,800
14년 전 조회 2,444
14년 전 조회 1,309
14년 전 조회 1,433
14년 전 조회 2,059
14년 전 조회 2,154
14년 전 조회 1,760
14년 전 조회 1,442
14년 전 조회 1,621
14년 전 조회 1,570
14년 전 조회 2,372
14년 전 조회 2,522
14년 전 조회 2,384
14년 전 조회 1,535
14년 전 조회 2,099
14년 전 조회 2,149
14년 전 조회 2,234
14년 전 조회 4,020
14년 전 조회 1,567
14년 전 조회 2,370
14년 전 조회 1,292
14년 전 조회 1,426
14년 전 조회 1,282
14년 전 조회 1,707
14년 전 조회 2,160
14년 전 조회 1,704
14년 전 조회 1,569
14년 전 조회 1,236
14년 전 조회 2,209
14년 전 조회 1,782
14년 전 조회 1,308
14년 전 조회 2,736
14년 전 조회 1,833
14년 전 조회 1,774
14년 전 조회 1,280
14년 전 조회 2,166
14년 전 조회 3,127
14년 전 조회 1,523
14년 전 조회 974
14년 전 조회 2,515
14년 전 조회 2,268
14년 전 조회 1,220
14년 전 조회 1,789
14년 전 조회 1,959
14년 전 조회 1,822
14년 전 조회 1,154
14년 전 조회 1,151
14년 전 조회 1,455
14년 전 조회 1,780
14년 전 조회 1,629
14년 전 조회 1,313
14년 전 조회 1,738
14년 전 조회 1,561
14년 전 조회 1,861
14년 전 조회 1,322
14년 전 조회 1,560
14년 전 조회 1,347
14년 전 조회 1,709
14년 전 조회 1,176
14년 전 조회 2,580
14년 전 조회 1,781
14년 전 조회 3,360
14년 전 조회 1,756
15년 전 조회 1,515
15년 전 조회 1,576
15년 전 조회 1,561
15년 전 조회 1,017
15년 전 조회 1,274
15년 전 조회 1,346
15년 전 조회 2,804
15년 전 조회 1,439
15년 전 조회 3,805
15년 전 조회 1,267
15년 전 조회 1,091
15년 전 조회 1,176
15년 전 조회 2,175
15년 전 조회 1,777
15년 전 조회 1,592
15년 전 조회 1,643
15년 전 조회 1,578
15년 전 조회 1,674
15년 전 조회 1,326
15년 전 조회 937
15년 전 조회 1,444
15년 전 조회 2,610