프로세스 일시정지 suspend
세움
Private Declare Function FindWindow Lib user32.dll Alias FindWindowA ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _) As LongPrivate Declare Function GetWindowThreadProcessId Lib user32.dll ( _ ByVal hWnd As Long, _ ByRef lpdwProcessId As Long _) As LongPrivate Declare Function CreateToolhelp32Snapshot Lib kernel32.dll ( _ ByVal dwFlags As Long, _ ByVal th32ProcessID As Long _) As LongPrivate Declare Function Thread32First Lib kernel32.dll ( _ ByVal hSnapShot As Long, _ ByRef lpte As THREADENTRY32 _) As LongPrivate Declare Function Thread32Next Lib kernel32.dll ( _ ByVal hSnapShot As Long, _ ByRef lpte As THREADENTRY32 _) As LongPrivate Declare Function CloseHandle Lib kernel32.dll (ByVal hObject As Long) As LongPrivate Declare Function OpenThread Lib kernel32.dll ( _ ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwThreadId As Long _) As LongPrivate Declare Function SuspendThread Lib kernel32.dll (ByVal hThread As Long) As LongPrivate Declare Function ResumeThread Lib kernel32.dll (ByVal hThread As Long) As LongPrivate Type THREADENTRY32DENTRY32 dwSize As Long cntUsage As Long th32ThreadID As Long th32OwnerProcessID As Long tpBasePri As Long tpDeltaPri As Long dwFlags As LongEnd TypePrivate Const TH32CS_SNAPTHREAD& = 4&Private Const THREAD_ALL_ACCESS& = &H1F03FFPublic Sub SuspendProcess(ByRef WindowTitle As String) Dim lhWnd As Long, dwProcessId As Long lhWnd = FindWindow(vbNullString, WindowTitle) If lhWnd Then GetWindowThreadProcessId lhWnd, dwProcessId If dwProcessId Then SuspendProcessById dwProcessId End If End IfEnd SubPublic Sub ResumeProcess(ByRef WindowTitle As String) Dim lhWnd As Long, dwProcessId As Long lhWnd = FindWindow(vbNullString, WindowTitle) If lhWnd Then GetWindowThreadProcessId lhWnd, dwProcessId If dwProcessId Then ResumeProcessById dwProcessId End If End IfEnd SubPrivate Sub SuspendProcessById(ByVal dwProcessId As Long) Dim hSnapShot As Long, te As THREADENTRY32, lRet As Long, hThread As Long te.dwSize = LenB(te) hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0&) If Not hSnapShot Then&nbsbsp; lRet = Thread32First(hSnapShot, te) Do While lRet If te.th32OwnerProcessID = dwProcessId Then hThread = OpenThread(THREAD_ALL_ACCESS, 0&, te.th32ThreadID) If hThread Then SuspendThread hThread CloseHandle hThread End If End If lRet = Thread32Next(hSnapShot, te) Loop CloseHandle hSnapShot End IfEnd SubPrivate Sub ResumeProcessById(ByVal dwProcessId As Long) Dim hSnapShot As Long, te As THREADENTRY32, lRet As Long, hThread As Long te.dwSize = LenB(te) hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0&) If Not hSnapShot Then lRet = Thread32First(hSnapShot, te) Do While lRet If te.th32OwnerProcessID = dwProcessId Then hThread = OpenThread(THREAD_ALL_ACCESS, 0&, te.th32ThreadID) If hThread Then ResumeThread hThread CloseHandle hThread End If End If lRet = Thread32Next(hSnapShot, te) Loop CloseHandle hSnapShot End IfEnd SubPrivate Sub Command1_Click()SuspendProcess chrome.exeEnd SubPrivate Sub Command2_Click()ResumeProcess chrome.exeEnd Sub
이런 소스를 얻었는데 chrome이멈추진 않구요윈도우 창이름 (캡션)을 넣으니까되더라구요프로세스 이름으로 정지시키는건 없을까요?
-
후회중
CreateToolhelp32Snapshot()
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2676006 | 질문하나더~ | 찬바리 | 2024-11-23 |
2675930 | 작업관리자 차단 | 별빛 | 2024-11-22 |
2675901 | 숫자를 제외한 문자를 어떻게 나타내야될까요? | 진나 | 2024-11-22 |
2675871 | 거의마지막질문인데요 | 아메 | 2024-11-22 |
2675846 | 제가 완성햇는데요 ㅎ; | 거늘 | 2024-11-21 |
2675824 | 타이머. 프로그래스바 코드 질문입니다. (10) | 빛글 | 2024-11-21 |
2675798 | 이걸 머라고해야 할지모르지만 질문합니다 (2) | 리라 | 2024-11-21 |
2675772 | 구구단 함수 질문이요~! (1) | 테이 | 2024-11-21 |
2675746 | exe저장시 런타임53 에러 | 아픔이보여 | 2024-11-20 |
2675718 | ocx 설치법 | 달달한캔디 | 2024-11-20 |
2675630 | ""안에 큰따음표 넣기. | 터전 | 2024-11-19 |
2675519 | 컴파일 오류 ?? | 슬아라 | 2024-11-18 |
2675492 | 비베 수다 사이트채팅 접속방법 | 마법 | 2024-11-18 |
2675463 | ㅠㅠ;; | 지은 | 2024-11-18 |
2675434 | 타이머로 라벨바꾸는거 (2) | 대나무 | 2024-11-18 |
2675386 | 선형보간법 문의 | 나길 | 2024-11-17 |
2675328 | 프로세스 강제종료하는방법좀... (1) | 슬아라 | 2024-11-17 |
2675226 | 폼 관련 질문&버튼 관련질문 (7) | 한울 | 2024-11-16 |
2675194 | 파일 삭제 소스 (4) | AngelsTears | 2024-11-15 |
2675147 | 예기치 않은 오류 (2) | 촉촉한 초코칩 | 2024-11-15 |