Answer the question
In order to leave comments, you need to log in
How to change the priority of a running process from the task manager list?
Please help me where to start to change the priority of the current process
. Here is the screen of my form, I implemented everything except changing the priority. From the screen, I enter the name of the file (i.e., the process) with the extension .exe, for example, let's say browser.exe and press the button to change the priority of
I sources I found little on my problem and some sources are not clear, tell me where to start how to implement?
Answer the question
In order to leave comments, you need to log in
Any question like this needs to be addressed starting with how this native API is done:
https://docs.microsoft.com/en-us/windows/win32/api...
And here's how to call native functions like this:
https:// docs.microsoft.com/en-us/dotnet/standard/n...
So you can do something like this:
[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 static bool SetProcessPriority(Process process, PriorityClass priorityClass) =>
SetPriorityClass(process.Handle, priorityClass);
public static void SetProcessPriority(Process process, ProcessPriorityClass priorityClass) =>
process.PriorityClass = priorityClass;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question