USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Dicas

  Visual Basic    (Windows)

Título da Dica:  Alterando prioridade do processo em execução
Postada em 1/9/2003 por Ð@®l@n            
'
'Demonstrates the use of SetPriorityClass To change the priority of a process.
'
'In Windows 2000 there are additionally two more levels: ABOVE_NORMAL_PRIORITY
'       And BELOW_NORMAL_PRIORITY
'
'
'NOTE: That running this program In the debugging IDE will cause the VB6.exe process To have the chosen priority
'      
'
''Add a button To the main form. Name it cmdSetPriority. Add a combo box
''Name it cmbPriotity

Option Explicit

Private Declare Function SetPriorityClass Lib "kernel32" _
          (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long

''Constants For SetPriorityClass
Private Const IDLE_PRIORITY_CLASS = &H40
Private Const NORMAL_PRIORITY_CLASS = &H20
Private Const HIGH_PRIORITY_CLASS = &H80
Private Const REALTIME_PRIORITY_CLASS = &H100

''Program specific constants For Combo box selection
Private Const IDLE_PRIORITY As Long = 0
Private Const NORMAL_PRIORITY As Long = 1
Private Const HIGH_PRIORITY As Long = 2
Private Const REALTIME_PRIORITY As Long = 3

Private Sub cmdSetPriority_Click()
    ''Read the selection from the Combobox
    Select Case cmbPriority.ListIndex
        Case IDLE_PRIORITY
            SetPriorityClass GetCurrentProcess(), IDLE_PRIORITY_CLASS
        Case NORMAL_PRIORITY
            SetPriorityClass GetCurrentProcess(), NORMAL_PRIORITY_CLASS
        Case HIGH_PRIORITY
            SetPriorityClass GetCurrentProcess(), HIGH_PRIORITY_CLASS
        Case REALTIME_PRIORITY
            If Msgbox("Are you sure?", vbYesNo) = vbYes Then
                SetPriorityClass GetCurrentProcess(), REALTIME_PRIORITY_CLASS
            End If
    End Select
End Sub

Private Sub Form_Load()

    ''Add Labels To the Combo box
    cmbPriority.AddItem "Idle Priority", IDLE_PRIORITY
    cmbPriority.AddItem "Normal Priority", NORMAL_PRIORITY
    cmbPriority.AddItem "High Priority", HIGH_PRIORITY
    cmbPriority.AddItem "Realtime Priority", REALTIME_PRIORITY
    
    cmbPriority.ListIndex = IDLE_PRIORITY
End Sub

fonte: http://www.vbaccelerator.com/home
 


CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página