Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Runtime.InteropServices
- Public Class clsProcessProtect
- <DllImport("ntdll")> _
- Private Shared Function NtSetInformationProcess(ByVal hProcess As IntPtr, ByVal processInformationClass As Integer, ByRef processInformation As Integer, ByVal processInformationLength As Integer) As Integer
- End Function
- Dim psStop As New EventHandler(AddressOf StopProcessProtection)
- 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 As Integer) 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement