굿

프로세스 강제 종료

· 14년 전 · 1293
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,498
14년 전 조회 1,960
14년 전 조회 2,090
14년 전 조회 1,301
14년 전 조회 2,536
14년 전 조회 2,525
14년 전 조회 2,099
14년 전 조회 2,041
14년 전 조회 1,571
14년 전 조회 2,050
14년 전 조회 1,973
14년 전 조회 1,678
14년 전 조회 1,382
14년 전 조회 3,140
14년 전 조회 2,456
14년 전 조회 1,812
14년 전 조회 2,456
14년 전 조회 1,329
14년 전 조회 1,442
14년 전 조회 2,074
14년 전 조회 2,160
14년 전 조회 1,773
14년 전 조회 1,454
14년 전 조회 1,645
14년 전 조회 1,592
14년 전 조회 2,390
14년 전 조회 2,536
14년 전 조회 2,401
14년 전 조회 1,544
14년 전 조회 2,112
14년 전 조회 2,157
14년 전 조회 2,247
14년 전 조회 4,034
14년 전 조회 1,577
14년 전 조회 2,397
14년 전 조회 1,301
14년 전 조회 1,436
14년 전 조회 1,288
14년 전 조회 1,722
14년 전 조회 2,174
14년 전 조회 1,720
14년 전 조회 1,582
14년 전 조회 1,249
14년 전 조회 2,224
14년 전 조회 1,799
14년 전 조회 1,323
14년 전 조회 2,750
14년 전 조회 1,845
14년 전 조회 1,782
14년 전 조회 1,294
14년 전 조회 2,178
14년 전 조회 3,145
14년 전 조회 1,538
14년 전 조회 1,002
14년 전 조회 2,524
14년 전 조회 2,269
14년 전 조회 1,225
14년 전 조회 1,799
14년 전 조회 1,965
14년 전 조회 1,832
14년 전 조회 1,168
14년 전 조회 1,166
14년 전 조회 1,463
14년 전 조회 1,791
14년 전 조회 1,637
14년 전 조회 1,322
14년 전 조회 1,750
14년 전 조회 1,570
15년 전 조회 1,871
15년 전 조회 1,330
15년 전 조회 1,570
15년 전 조회 1,357
15년 전 조회 1,717
15년 전 조회 1,191
15년 전 조회 2,592
15년 전 조회 1,791
15년 전 조회 3,366
15년 전 조회 1,766
15년 전 조회 1,525
15년 전 조회 1,581
15년 전 조회 1,574
15년 전 조회 1,025
15년 전 조회 1,287
15년 전 조회 1,356
15년 전 조회 2,808
15년 전 조회 1,449
15년 전 조회 3,808
15년 전 조회 1,279
15년 전 조회 1,107
15년 전 조회 1,185
15년 전 조회 2,178
15년 전 조회 1,784
15년 전 조회 1,601
15년 전 조회 1,656
15년 전 조회 1,585
15년 전 조회 1,685
15년 전 조회 1,336
15년 전 조회 954
15년 전 조회 1,454
15년 전 조회 2,619