굿

프로세스 강제 종료

· 15년 전 · 1407
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,618
14년 전 조회 2,097
14년 전 조회 2,229
14년 전 조회 1,418
14년 전 조회 2,676
14년 전 조회 2,659
14년 전 조회 2,233
14년 전 조회 2,196
14년 전 조회 1,701
14년 전 조회 2,187
14년 전 조회 2,094
14년 전 조회 1,825
14년 전 조회 1,523
14년 전 조회 3,262
14년 전 조회 2,590
14년 전 조회 1,945
14년 전 조회 2,585
14년 전 조회 1,459
14년 전 조회 1,578
14년 전 조회 2,204
14년 전 조회 2,284
14년 전 조회 1,900
14년 전 조회 1,590
14년 전 조회 1,751
14년 전 조회 1,713
14년 전 조회 2,522
14년 전 조회 2,652
14년 전 조회 2,552
14년 전 조회 1,665
14년 전 조회 2,247
14년 전 조회 2,281
14년 전 조회 2,362
14년 전 조회 4,158
14년 전 조회 1,699
14년 전 조회 2,521
14년 전 조회 1,431
14년 전 조회 1,561
14년 전 조회 1,419
14년 전 조회 1,864
14년 전 조회 2,279
14년 전 조회 1,842
15년 전 조회 1,699
15년 전 조회 1,367
15년 전 조회 2,344
15년 전 조회 1,929
15년 전 조회 1,461
15년 전 조회 2,845
15년 전 조회 1,957
15년 전 조회 1,885
15년 전 조회 1,408
15년 전 조회 2,281
15년 전 조회 3,250
15년 전 조회 1,638
15년 전 조회 1,098
15년 전 조회 2,628
15년 전 조회 2,371
15년 전 조회 1,324
15년 전 조회 1,904
15년 전 조회 2,061
15년 전 조회 1,913
15년 전 조회 1,281
15년 전 조회 1,257
15년 전 조회 1,576
15년 전 조회 1,883
15년 전 조회 1,740
15년 전 조회 1,413
15년 전 조회 1,853
15년 전 조회 1,686
15년 전 조회 1,957
15년 전 조회 1,427
15년 전 조회 1,665
15년 전 조회 1,464
15년 전 조회 1,813
15년 전 조회 1,284
15년 전 조회 2,681
15년 전 조회 1,886
15년 전 조회 3,465
15년 전 조회 1,859
15년 전 조회 1,623
15년 전 조회 1,680
15년 전 조회 1,679
15년 전 조회 1,127
15년 전 조회 1,390
15년 전 조회 1,451
15년 전 조회 2,899
15년 전 조회 1,538
15년 전 조회 3,906
15년 전 조회 1,378
15년 전 조회 1,212
15년 전 조회 1,292
15년 전 조회 2,264
15년 전 조회 1,888
15년 전 조회 1,687
15년 전 조회 1,745
15년 전 조회 1,663
15년 전 조회 1,770
15년 전 조회 1,427
15년 전 조회 1,032
15년 전 조회 1,543
15년 전 조회 2,704