굿

프로세스 강제 종료

· 15년 전 · 1430
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,641
14년 전 조회 2,121
14년 전 조회 2,251
14년 전 조회 1,435
14년 전 조회 2,697
14년 전 조회 2,690
14년 전 조회 2,250
14년 전 조회 2,216
14년 전 조회 1,723
14년 전 조회 2,208
14년 전 조회 2,113
14년 전 조회 1,850
14년 전 조회 1,541
14년 전 조회 3,284
14년 전 조회 2,611
14년 전 조회 1,969
14년 전 조회 2,609
14년 전 조회 1,488
14년 전 조회 1,593
14년 전 조회 2,229
14년 전 조회 2,306
14년 전 조회 1,925
14년 전 조회 1,611
14년 전 조회 1,776
14년 전 조회 1,738
14년 전 조회 2,543
14년 전 조회 2,673
14년 전 조회 2,571
14년 전 조회 1,684
14년 전 조회 2,265
14년 전 조회 2,306
14년 전 조회 2,387
14년 전 조회 4,182
14년 전 조회 1,717
14년 전 조회 2,540
14년 전 조회 1,453
14년 전 조회 1,585
14년 전 조회 1,435
15년 전 조회 1,885
15년 전 조회 2,304
15년 전 조회 1,862
15년 전 조회 1,721
15년 전 조회 1,379
15년 전 조회 2,362
15년 전 조회 1,942
15년 전 조회 1,481
15년 전 조회 2,865
15년 전 조회 1,982
15년 전 조회 1,901
15년 전 조회 1,431
15년 전 조회 2,306
15년 전 조회 3,270
15년 전 조회 1,656
15년 전 조회 1,116
15년 전 조회 2,643
15년 전 조회 2,392
15년 전 조회 1,337
15년 전 조회 1,921
15년 전 조회 2,083
15년 전 조회 1,934
15년 전 조회 1,303
15년 전 조회 1,274
15년 전 조회 1,598
15년 전 조회 1,899
15년 전 조회 1,749
15년 전 조회 1,426
15년 전 조회 1,870
15년 전 조회 1,701
15년 전 조회 1,966
15년 전 조회 1,441
15년 전 조회 1,680
15년 전 조회 1,477
15년 전 조회 1,828
15년 전 조회 1,299
15년 전 조회 2,692
15년 전 조회 1,901
15년 전 조회 3,481
15년 전 조회 1,877
15년 전 조회 1,633
15년 전 조회 1,702
15년 전 조회 1,693
15년 전 조회 1,145
15년 전 조회 1,403
15년 전 조회 1,464
15년 전 조회 2,912
15년 전 조회 1,552
15년 전 조회 3,922
15년 전 조회 1,395
15년 전 조회 1,221
15년 전 조회 1,303
15년 전 조회 2,279
15년 전 조회 1,904
15년 전 조회 1,707
15년 전 조회 1,762
15년 전 조회 1,674
15년 전 조회 1,780
15년 전 조회 1,440
15년 전 조회 1,045
15년 전 조회 1,558
15년 전 조회 2,717