Results 1 to 3 of 3

Thread: program priority

  1. #1
    Chinese Leper
    Guest

    Question program priority

    how do i change the priority of a program? (I have Windows 2000 Pro) and i'd like start programs from my program using shell and prioritize these programs. Is that possible????

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Const THREAD_BASE_PRIORITY_IDLE = -15
    2. Const THREAD_BASE_PRIORITY_LOWRT = 15
    3. Const THREAD_BASE_PRIORITY_MIN = -2
    4. Const THREAD_BASE_PRIORITY_MAX = 2
    5. Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
    6. Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
    7. Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
    8. Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
    9. Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
    10. Const THREAD_PRIORITY_NORMAL = 0
    11. Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
    12. Const HIGH_PRIORITY_CLASS = &H80
    13. Const IDLE_PRIORITY_CLASS = &H40
    14. Const NORMAL_PRIORITY_CLASS = &H20
    15. Const REALTIME_PRIORITY_CLASS = &H100
    16. Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long
    17. Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
    18. Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As Long) As Long
    19. Private Declare Function GetPriorityClass Lib "kernel32" (ByVal hProcess As Long) As Long
    20. Private Declare Function GetCurrentThread Lib "kernel32" () As Long
    21. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
    22. Private Sub Form_Load()
    23.     'KPD-Team 2000
    24.     'URL: [url]http://www.allapi.net/[/url]
    25.     'E-Mail: [email][email protected][/email]
    26.     Dim hThread As Long, hProcess As Long
    27.     'retrieve the current thread and process
    28.     hThread = GetCurrentThread
    29.     hProcess = GetCurrentProcess
    30.     'set the new thread priority to "lowest"
    31.     SetThreadPriority hThread, THREAD_PRIORITY_LOWEST
    32.     'set the new priority class to "idle"
    33.     SetPriorityClass hProcess, IDLE_PRIORITY_CLASS
    34.     'print some results
    35.     Me.AutoRedraw = True
    36.     Me.Print "Current Thread Priority:" + Str$(GetThreadPriority(hThread))
    37.     Me.Print "Current Priority Class:" + Str$(GetPriorityClass(hProcess))
    38. End Sub

  3. #3
    Chinese Leper
    Guest
    thanks a lot!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width