<Runtime.InteropServices.DllImport("kernel32.dll", CharSet:=Runtime.InteropServices.CharSet.Auto, CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall)> _
Public Shared Function SetPriorityClass( _
ByVal hProcess As IntPtr, _
ByVal dwPriorityClass As IntPtr _
) As Boolean
End Function
[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern bool SetPriorityClass(IntPtr handle, PriorityClass priorityClass);
public enum PriorityClass : uint
{
ABOVE_NORMAL_PRIORITY_CLASS = 0x8000,
BELOW_NORMAL_PRIORITY_CLASS = 0x4000,
HIGH_PRIORITY_CLASS = 0x80,
IDLE_PRIORITY_CLASS = 0x40,
NORMAL_PRIORITY_CLASS = 0x20,
PROCESS_MODE_BACKGROUND_BEGIN = 0x100000,// 'Windows Vista/2008 and higher
PROCESS_MODE_BACKGROUND_END = 0x200000,// 'Windows Vista/2008 and higher
REALTIME_PRIORITY_CLASS = 0x100
}
Public Enum PriorityClass
ABOVE_NORMAL_PRIORITY_CLASS = &H8000
BELOW_NORMAL_PRIORITY_CLASS = &H4000
HIGH_PRIORITY_CLASS = &H80
IDLE_PRIORITY_CLASS = &H40
NORMAL_PRIORITY_CLASS = &H20
PROCESS_MODE_BACKGROUND_BEGIN = &H100000 'Windows Vista/2008 and higher
PROCESS_MODE_BACKGROUND_END = &H200000 'Windows Vista/2008 and higher
REALTIME_PRIORITY_CLASS = &H100
End Enum
VB no warnings with option strict = on.
Please add some!
SetPriorityClass(mhHwnd, CType(20, System.IntPtr)) '20 = high !!
SetPriorityClass(Process.GetCurrentProcess.Handle, PriorityClass.PROCESS_MODE_BACKGROUND_BEGIN)
System.Diagnostics.Process.PriorityClass (Does not provide PROCESS_MODE_BACKGROUND options)