Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("kernel32.dll")> _
Private Shared Function SuspendThread(ByVal hThread As IntPtr) As Int32
End Function
Public Function Thread_Suspend(ByVal ThreadHandle As IntPtr) As Integer
Return SuspendThread(ThreadHandle)
End Function
<DllImport("kernel32.dll")> _
Private Shared Function ResumeThread(ByVal hThread As IntPtr) As Integer
End Function
Public Function Thread_Resume(ByVal ThreadHandle As IntPtr) As Integer
Return ResumeThread(ThreadHandle)
End Function
<DllImport("kernel32.dll")> _
Private Shared Function OpenThread(ByVal dwDesiredAccess As ThreadAccess, ByVal bInheritHandle As Boolean, ByVal dwThreadId As Integer) As IntPtr
End Function
Public Function Thread_GetHandle(ByVal ThreadID As Integer) As IntPtr
Return OpenThread(ThreadAccess.SUSPEND_RESUME, False, ThreadID)
End Function
Public Function Thread_GetHandle(ByVal ThreadID As Integer, ByVal DesiredAccess As ThreadAccess) As IntPtr
Return OpenThread(DesiredAccess, False, ThreadID)
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Shared Function CloseHandle(ByVal hHandle As IntPtr) As Boolean
End Function
Public Function Handle_Close(ByVal OpenedHandle As IntPtr) As Boolean
Return CloseHandle(OpenedHandle)
End Function
<Flags()> _
Public Enum ThreadAccess As Integer
TERMINATE = (&H1)
SUSPEND_RESUME = (&H2)
GET_CONTEXT = (&H8)
SET_CONTEXT = (&H10)
SET_INFORMATION = (&H20)
QUERY_INFORMATION = (&H40)
SET_THREAD_TOKEN = (&H80)
IMPERSONATE = (&H100)
DIRECT_IMPERSONATION = (&H200)
End Enum
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each thread As ProcessThread In Process.GetProcessesByName("Process Name")(0).Threads
Thread_Suspend(Thread_GetHandle(thread.Id))
Next
End Sub
End Class
Tag : .NET, Report Others, Win (Windows App), VB.NET
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Thread1 = 6196
Dim Thread2 = 6644
Dim Thread3 = 6648
For Each thread As ProcessThread In Process.GetProcessesByName("chrome")(0).Threads
Thread_Suspend(Thread_GetHandle(Thread1))
' Thread_Suspend(Thread_GetHandle(Thread2))
' Thread_Suspend(Thread_GetHandle(Thread3))
Next
End Sub
ส่วน Button2_Click จะเป็นส่วนของ การ เล่น เทรด
ตัวอย่าง
Code (VB.NET)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Thread1 = 6196
Dim Thread2 = 6644
Dim Thread3 = 6648
For Each thread As ProcessThread In Process.GetProcessesByName("chrome")(0).Threads
Thread_Resume(Thread_GetHandle(Thread1))
' Thread_Resume(Thread_GetHandle(Thread2))
'Thread_Resume(Thread_GetHandle(Thread3))
Next
End Sub