28 June 2014

set the process priority

o set the process priority, we  can set the Process.PriorityClass property. PriorityClass is captured in the ProcessPriorityClass enumeration, which lets us set the process priority to Idle, Normal, High, AboveNormal, BelowNormal, or RealTime.   Process.BasePriority is an integer value property and is read-only.
The following table shows the relationship between the BasePriority and PriorityClass values:
BasePriority            PriorityClass
4 Idle
8 Normal
13 High
24 RealTime
Note:
In Windows 98, and the Windows Millennium Edition Platform, setting the priority class to AboveNormal or BelowNormal causes an exception to be thrown.
How do I capture a screenshot of a process’s main window?
Here is one method to take a process screenshot.  We will use the process “notepad” for this example.   Please follow these steps:

1.   Use System.Diagnostics.Process.MainWindowHandle to get the process information we require to take a screenshot.
2.   Use the Windows API, SetForegroundWindow, to activate the target process.
3.   Pass the window handle to the first parameter of the Windows API GetWindowRect, to get the location information of the target process.
4.   Define the coordinates of the process window on the screen with the location information in step 3.
5.   Use the coordinates in step 4 and Graphics.CopyFromScreen to take the screenshot.

No comments: