굿

프로세스 강제 종료

· 14년 전 · 1321
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,525
14년 전 조회 1,988
14년 전 조회 2,128
14년 전 조회 1,328
14년 전 조회 2,568
14년 전 조회 2,554
14년 전 조회 2,136
14년 전 조회 2,095
14년 전 조회 1,612
14년 전 조회 2,095
14년 전 조회 2,001
14년 전 조회 1,718
14년 전 조회 1,411
14년 전 조회 3,179
14년 전 조회 2,491
14년 전 조회 1,845
14년 전 조회 2,487
14년 전 조회 1,373
14년 전 조회 1,479
14년 전 조회 2,108
14년 전 조회 2,183
14년 전 조회 1,803
14년 전 조회 1,484
14년 전 조회 1,670
14년 전 조회 1,618
14년 전 조회 2,429
14년 전 조회 2,567
14년 전 조회 2,447
14년 전 조회 1,575
14년 전 조회 2,145
14년 전 조회 2,182
14년 전 조회 2,275
14년 전 조회 4,063
14년 전 조회 1,601
14년 전 조회 2,422
14년 전 조회 1,336
14년 전 조회 1,474
14년 전 조회 1,333
14년 전 조회 1,770
14년 전 조회 2,197
14년 전 조회 1,744
14년 전 조회 1,606
14년 전 조회 1,275
14년 전 조회 2,254
14년 전 조회 1,827
14년 전 조회 1,362
14년 전 조회 2,777
14년 전 조회 1,875
14년 전 조회 1,809
14년 전 조회 1,322
14년 전 조회 2,201
14년 전 조회 3,174
14년 전 조회 1,568
14년 전 조회 1,025
14년 전 조회 2,555
14년 전 조회 2,293
14년 전 조회 1,242
14년 전 조회 1,821
14년 전 조회 1,985
14년 전 조회 1,843
14년 전 조회 1,195
14년 전 조회 1,185
15년 전 조회 1,487
15년 전 조회 1,809
15년 전 조회 1,662
15년 전 조회 1,347
15년 전 조회 1,769
15년 전 조회 1,599
15년 전 조회 1,882
15년 전 조회 1,357
15년 전 조회 1,592
15년 전 조회 1,379
15년 전 조회 1,737
15년 전 조회 1,220
15년 전 조회 2,619
15년 전 조회 1,819
15년 전 조회 3,389
15년 전 조회 1,786
15년 전 조회 1,541
15년 전 조회 1,604
15년 전 조회 1,593
15년 전 조회 1,052
15년 전 조회 1,319
15년 전 조회 1,376
15년 전 조회 2,830
15년 전 조회 1,469
15년 전 조회 3,831
15년 전 조회 1,304
15년 전 조회 1,129
15년 전 조회 1,211
15년 전 조회 2,198
15년 전 조회 1,806
15년 전 조회 1,631
15년 전 조회 1,677
15년 전 조회 1,603
15년 전 조회 1,701
15년 전 조회 1,361
15년 전 조회 974
15년 전 조회 1,476
15년 전 조회 2,646