Imports System.Runtime.InteropServices
Public Class clsProcessProtect
<DllImport("ntdll")> _
Private Shared Function NtSetInformationProcess(ByVal hProcess As IntPtr, ByVal processInformationClass As Integer, ByRefprocessInformation As Integer, ByVal processInformationLength As Integer) As Integer
End Function
Dim psStop As New EventHandler(AddressOfStopProcessProtection)
Const iStop = 0
Const iStart = 1
Const ProcessPriorityClass = 29
Public Sub New()
End Sub
Public Sub New()
End Sub
Public Sub Start()
StartProcessProtection(iStart)
AddHandler AppDomain.CurrentDomain.ProcessExit, psStop
AddHandler AppDomain.CurrentDomain.DomainUnload, psStop
AddHandler Application.ApplicationExit, psStop
End Sub
Private Function StartProcessProtection(ByRef psInfo AsInteger) As Boolean
Try
NtSetInformationProcess(Process.GetCurrentProcess().Handle, ProcessPriorityClass, psInfo, Marshal.SizeOf(psInfo))
Return True
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine &ex.InnerException.ToString())
End Try
End Function
Private Function StopProcessProtection() As Boolean
Try
StartProcessProtection(iStop)
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine &ex.InnerException.ToString())
End Try
End Function
End Class
RAW Paste
Data