Isto deve dar
Public Const NORMAL_PRIORITY_CLASS = &H20
Public Const IDLE_PRIORITY_CLASS = &H40
Public Const HIGH_PRIORITY_CLASS = &H80
Public Const REALTIME_PRIORITY_CLASS = &H100
Public Const PROCESS_DUP_HANDLE = &H40
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function SetPriorityClass& Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long)
Public Sub ChangePriority(dwPriorityClass As Long)
Dim hProcess&
Dim ret&, pid&
pid = GetCurrentProcessId() ' pid do processo actual
' handle para o processo em pid
hProcess = OpenProcess(PROCESS_DUP_HANDLE, True, pid)
If hProcess = 0 Then
Err.Raise 2, "ChangePriority", "erro ao abrir processo"
Exit Sub
End If
' Mudar a priioridade do processo
ret = SetPriorityClass(hProcess, dwPriorityClass)
Call CloseHandle(hProcess)
If ret = 0 Then
Err.Raise 4, "ChangePriority", "Erro ao fechar processo"
Exit Sub
End If
End Sub