굿

프로세스 강제 종료

· 15년 전 · 1455
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,674
14년 전 조회 2,162
14년 전 조회 2,293
14년 전 조회 1,485
14년 전 조회 2,733
14년 전 조회 2,725
14년 전 조회 2,294
14년 전 조회 2,251
14년 전 조회 1,765
14년 전 조회 2,247
14년 전 조회 2,160
14년 전 조회 1,891
14년 전 조회 1,571
14년 전 조회 3,321
14년 전 조회 2,637
14년 전 조회 2,004
14년 전 조회 2,643
14년 전 조회 1,524
14년 전 조회 1,625
14년 전 조회 2,260
14년 전 조회 2,328
14년 전 조회 1,954
14년 전 조회 1,648
14년 전 조회 1,806
14년 전 조회 1,781
14년 전 조회 2,577
14년 전 조회 2,703
14년 전 조회 2,606
14년 전 조회 1,722
14년 전 조회 2,305
14년 전 조회 2,330
14년 전 조회 2,416
15년 전 조회 4,209
15년 전 조회 1,757
15년 전 조회 2,573
15년 전 조회 1,483
15년 전 조회 1,618
15년 전 조회 1,472
15년 전 조회 1,918
15년 전 조회 2,338
15년 전 조회 1,885
15년 전 조회 1,746
15년 전 조회 1,416
15년 전 조회 2,401
15년 전 조회 1,968
15년 전 조회 1,518
15년 전 조회 2,891
15년 전 조회 2,006
15년 전 조회 1,924
15년 전 조회 1,456
15년 전 조회 2,340
15년 전 조회 3,297
15년 전 조회 1,684
15년 전 조회 1,144
15년 전 조회 2,674
15년 전 조회 2,423
15년 전 조회 1,366
15년 전 조회 1,955
15년 전 조회 2,112
15년 전 조회 1,959
15년 전 조회 1,334
15년 전 조회 1,303
15년 전 조회 1,629
15년 전 조회 1,929
15년 전 조회 1,789
15년 전 조회 1,452
15년 전 조회 1,901
15년 전 조회 1,732
15년 전 조회 1,993
15년 전 조회 1,476
15년 전 조회 1,713
15년 전 조회 1,500
15년 전 조회 1,860
15년 전 조회 1,318
15년 전 조회 2,716
15년 전 조회 1,921
15년 전 조회 3,507
15년 전 조회 1,899
15년 전 조회 1,661
15년 전 조회 1,724
15년 전 조회 1,721
15년 전 조회 1,167
15년 전 조회 1,424
15년 전 조회 1,492
15년 전 조회 2,943
15년 전 조회 1,575
15년 전 조회 3,949
15년 전 조회 1,414
15년 전 조회 1,242
15년 전 조회 1,335
15년 전 조회 2,318
15년 전 조회 1,927
15년 전 조회 1,733
15년 전 조회 1,788
15년 전 조회 1,705
15년 전 조회 1,809
15년 전 조회 1,464
15년 전 조회 1,069
15년 전 조회 1,582
15년 전 조회 2,739