per chiamarlacodice:Private Declare Function SetThreadPriority Lib "kernel32" _ (ByVal hThread As Long, ByVal nPriority As Long) As Long Private Declare Function SetPriorityClass Lib "kernel32" _ (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long Private Declare Function GetThreadPriority Lib "kernel32" _ (ByVal hThread As Long) As Long Private Declare Function GetPriorityClass Lib "kernel32" _ (ByVal hProcess As Long) As Long Private Const THREAD_BASE_PRIORITY_MAX = 2 Private Const THREAD_PRIORITY_NORMAL = 0 Private Const THREAD_BASE_PRIORITY_MIN = -2 Public Enum Priority Alta = &H80 Normale = &H20 Bassa = &H40 End Enum Public Function setPriority(ClassePriorità As Priority) Dim hThread As Long Dim hProcess As Long hThread = GetCurrentThread hProcess = GetCurrentProcess If GetPriorityClass(hProcess) <> ClassePriorità Then Select Case ClassePriorità Case Is = Alta SetThreadPriority hThread, THREAD_BASE_PRIORITY_MAX Case Is = Normale SetThreadPriority hThread, THREAD_PRIORITY_NORMAL Case Is = Bassa SetThreadPriority hThread, THREAD_BASE_PRIORITY_MIN End Select SetPriorityClass hProcess, ClassePriorità End If End Function
codice:call setpriority(alta)

Rispondi quotando