/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
Program prioritet (Proces)
Fra : Ebbe H. Hjorth


Dato : 22-07-01 18:44

hejsa!

Er der nogen der ved hvordan man sætter sit program til at have en høj
prioritet, i forhold til de andre programmer?

I win2000 kan man gøre det fra sin "Windows jobliste", men hvordan gør man
det fra sit VB program?


Svar/eksempler sendes gerne til email, da jeg ik er så meget på nettet!

Mvh Ebbe



 
 
Tomas Christiansen (23-07-2001)
Kommentar
Fra : Tomas Christiansen


Dato : 23-07-01 09:35

Ebbe H. Hjorth skrev:
> Er der nogen der ved hvordan man sætter sit program til at have en høj
> prioritet, i forhold til de andre programmer?
>
> I win2000 kan man gøre det fra sin "Windows jobliste", men hvordan gør man
> det fra sit VB program?

Sådan "lige fra hovedet" er det noget i retning af:

Const IDLE_PRIORITY_CLASS As Long = &H40
Const BELOW_NORMAL_PRIORITY_CLASS As Long = &H4000
Const NORMAL_PRIORITY_CLASS As Long = &H20
Const ABOVE_NORMAL_PRIORITY_CLASS As Long = &H8000
Const HIGH_PRIORITY_CLASS As Long = &H80
Const REALTIME_PRIORITY_CLASS As Long = &H100

Const PROCESS_SET_INFORMATION As Long = &H200

Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

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

Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Dim lHandle As Long
Dim lResult As Long

lResult = OpenProcess(lPROCESS_SET_INFORMATION, 0&, GetCurrentProcessId)
lResult = SetPriorityClass(lHandle, HIGH_PRIORITY_CLASS)
lResult = CloseHandle(lHandle)

-------
Tomas


Tomas Christiansen (23-07-2001)
Kommentar
Fra : Tomas Christiansen


Dato : 23-07-01 11:55

Tomas Christiansen skrev meget som var rigtigt ... og lidt som var forkert.

Jeg fandt en VB-compler et der var lige et par fejl i den kode, som jeg sendte.
Følgende kode er lige til at lægge ind på en form og køre:

Option Explicit

Const IDLE_PRIORITY_CLASS As Long = &H40
Const BELOW_NORMAL_PRIORITY_CLASS As Long = &H4000
Const NORMAL_PRIORITY_CLASS As Long = &H20
Const ABOVE_NORMAL_PRIORITY_CLASS As Long = &H8000
Const HIGH_PRIORITY_CLASS As Long = &H80
Const REALTIME_PRIORITY_CLASS As Long = &H100

Const PROCESS_SET_INFORMATION As Long = &H200

Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

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

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long


Private Sub Form_Load()
Dim lHandle As Long
Dim lResult As Long

lHandle = OpenProcess(PROCESS_SET_INFORMATION, 0&, GetCurrentProcessId)
lResult = SetPriorityClass(lHandle, HIGH_PRIORITY_CLASS)
lResult = CloseHandle(lHandle)
End Sub

-------
Tomas



Søg
Reklame
Statistik
Spørgsmål : 177501
Tips : 31968
Nyheder : 719565
Indlæg : 6408527
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste