' ---------------------------------------------
' Declarations API
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
' Constantes des priorités (6 niveaux de priorités)
Public Const IDLE_PRIORITY_CLASS As Long = &H40 ' minimum
Public Const BELOW_NORMAL_PRIORITY_CLASS As Long = &H4000 ' normal -
Public Const NORMAL_PRIORITY_CLASS As Long = &H20 ' normal
Public Const ABOVE_NORMAL_PRIORITY_CLASS As Long = &H8000 ' normal +
Public Const HIGH_PRIORITY_CLASS As Long = &H80 ' haute
Public Const REALTIME_PRIORITY_CLASS As Long = &H100 ' maximum
' Constante paramètre de l'API OpenProcess
Private Const PROCESS_SET_INFORMATION As Long = &H200
' Defini la priorité d'un processus
Public Function SetProcessPriority(ByVal ProcessID As Long, ByVal Level As Long)
Dim hProcess As Long
' Ouvre en ecriture
hProcess = OpenProcess(PROCESS_SET_INFORMATION, 0, ProcessID)
' On définit la priorité
SetPriorityClass hProcess, Level
' On ferme le pointeur ouvert
CloseHandle hProcess
End Function
23/11/2006 : Ajout des ByVal
23/11/2006 : Modif
23/11/2006 : bug daffichage
Le 30/12/2006 par MadMatt : Petit bug daffichage
Le 02/01/2007 par violent_ken : A rajouté la constante &H200 dans les déclarations
Seul les admins et l'auteur du code lui même peuvent modifier ce code.