프로세스 일시정지 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()
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2655524 | for문 좀 높이 올라가면 프로그램이 멈추네요.. (5) | 가욋길 | 2024-05-20 |
2655492 | 포함된 문자로 파일명 검색하기? (5) | 모아 | 2024-05-20 |
2655472 | winhttp를 이용해 네이버 로그인에 성공했을때... | 개구리 | 2024-05-20 |
2655417 | VB로 프로세스 어떻게잡아요?? settini 나오게 또어떻게하나요? (3) | 모해 | 2024-05-19 |
2655384 | 비베로 클래스파일 실행하기 (5) | 달달한캔디 | 2024-05-19 |
2655362 | 컴파일시 오류 ㅠㅠ | 맨삶이 | 2024-05-19 |
2655329 | 트레이너 질문. 핫키를누르면 적용됫다가풀림 (1) | SweetChoco | 2024-05-18 |
2655300 | 특정 프로그램 루프문으로 팅기게 하고싶은데 (2) | 애교 | 2024-05-18 |
2655272 | 강좌소스확인하는법좀요 | 말달리자 | 2024-05-18 |
2655243 | 파일크기비교 | 혜윤 | 2024-05-18 |
2655211 | 우엉~ Winhttp 겁나 급해요 ㅜㅜ (2) | 정훈 | 2024-05-17 |
2655185 | 화면의 x좌표 가장큰값 구하기 질문 (1) | 해길 | 2024-05-17 |
2655158 | 이거 강좌를 받앗는대 어떻개따라해요? | 하람 | 2024-05-17 |
2655130 | 컴퓨터 사운드 녹음 질문 | 갤쓰리 | 2024-05-17 |
2655073 | 폼끄기 질문 다시합니다 | 해찬솔 | 2024-05-16 |
2654987 | 메세지 박스 질문입니다 ~ (3) | 안다미로 | 2024-05-15 |
2654960 | 블로그 글쓰기 질문 (2) | 힘찬 | 2024-05-15 |
2654931 | 질문 하나 하겠습니다 .!! | 소윤 | 2024-05-15 |
2654904 | 비베 질문요 ㅠㅠ | 미련곰탱이 | 2024-05-15 |
2654851 | 미투데이에 글을 다는 소스를 만들어보려고 하는데 | 횃불 | 2024-05-14 |