[Pb] sets the priority.

Source: Internet
Author: User

Set a priority.CodeThere is no difference between it and the following: it is easy to use after a new one, and it is vague on the Internet. Write it down as a prompt to view it in the future or give it a result as needed.

Step 1: declare

Function long getpriorityclass (long hprocess) Library "kernel32.dll"
Function long setpriorityclass (long HPR, long class) Library "kernel32.dll"

Function long getcurrentprocess () Library "kernel32.dll"

Step 2: click a button to test the code

If the test window won't work out, it won't work.

Ulong lul_cp // currentProgramProcess Handle

Ulong lul_old_leval

Ulong lul_new_leval

Lul_new_levy = 128

Lul_cp = getcurrentprocess ()
Lul_old_leval = getpriorityclass (lul_cp) // get the level of the original process to see if the change was successful
Setpriorityclass (lul_cp, lul_new_leval)

PS:

1. The handle is different from the PID seen by the task manager. It took a long time to wander around here.

2. Level correspondence

32 low

64 Standard

128 high

256 Real-Time

3. If it fails, you can use the getlasterror API to check the returned value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.