굿

프로세스 강제 종료

· 15년 전 · 1406
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,096
14년 전 조회 2,226
14년 전 조회 1,418
14년 전 조회 2,675
14년 전 조회 2,657
14년 전 조회 2,233
14년 전 조회 2,195
14년 전 조회 1,700
14년 전 조회 2,185
14년 전 조회 2,094
14년 전 조회 1,824
14년 전 조회 1,521
14년 전 조회 3,262
14년 전 조회 2,589
14년 전 조회 1,943
14년 전 조회 2,582
14년 전 조회 1,458
14년 전 조회 1,577
14년 전 조회 2,203
14년 전 조회 2,283
14년 전 조회 1,899
14년 전 조회 1,589
14년 전 조회 1,750
14년 전 조회 1,712
14년 전 조회 2,520
14년 전 조회 2,652
14년 전 조회 2,551
14년 전 조회 1,664
14년 전 조회 2,246
14년 전 조회 2,281
14년 전 조회 2,361
14년 전 조회 4,157
14년 전 조회 1,697
14년 전 조회 2,518
14년 전 조회 1,427
14년 전 조회 1,560
14년 전 조회 1,417
14년 전 조회 1,863
14년 전 조회 2,278
14년 전 조회 1,840
15년 전 조회 1,697
15년 전 조회 1,365
15년 전 조회 2,343
15년 전 조회 1,928
15년 전 조회 1,458
15년 전 조회 2,845
15년 전 조회 1,957
15년 전 조회 1,884
15년 전 조회 1,407
15년 전 조회 2,281
15년 전 조회 3,249
15년 전 조회 1,636
15년 전 조회 1,098
15년 전 조회 2,627
15년 전 조회 2,371
15년 전 조회 1,323
15년 전 조회 1,903
15년 전 조회 2,060
15년 전 조회 1,912
15년 전 조회 1,280
15년 전 조회 1,257
15년 전 조회 1,575
15년 전 조회 1,881
15년 전 조회 1,740
15년 전 조회 1,413
15년 전 조회 1,853
15년 전 조회 1,686
15년 전 조회 1,954
15년 전 조회 1,426
15년 전 조회 1,665
15년 전 조회 1,464
15년 전 조회 1,813
15년 전 조회 1,284
15년 전 조회 2,680
15년 전 조회 1,884
15년 전 조회 3,465
15년 전 조회 1,858
15년 전 조회 1,621
15년 전 조회 1,680
15년 전 조회 1,678
15년 전 조회 1,127
15년 전 조회 1,390
15년 전 조회 1,451
15년 전 조회 2,898
15년 전 조회 1,538
15년 전 조회 3,906
15년 전 조회 1,376
15년 전 조회 1,212
15년 전 조회 1,292
15년 전 조회 2,264
15년 전 조회 1,888
15년 전 조회 1,687
15년 전 조회 1,744
15년 전 조회 1,662
15년 전 조회 1,769
15년 전 조회 1,425
15년 전 조회 1,032
15년 전 조회 1,542
15년 전 조회 2,704