Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Get CPU Priority of a ProcessID

I'd like to read the current CPU priority as found in the task
managers' processes tab, when right-clicking on a process, and
selecting 'set priority'.

I've tried using
Private Declare Function GetPriorityClass Lib "kernel32" (ByVal
hProcess As Long) As Long

and using

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from
Win32_Process")

For Each objProcess In colProcesses
r = r + 1
POutput(r, 1) = objProcess.ProcessID
POutput(r, 2) = objProcess.Name
POutput(r, 3) = objProcess.Priority
POutput(r, 4) = objProcess.Handle
POutput(r, 5) = GetPriorityClass(POutput(r, 4))
Next

but, but this GetPriorityClass function always returns a zero, even
though I can see some priorities are 'AboveNormal'. So this is where
I'm stuck..

Your help is appreciated.
Poniente
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Get CPU Priority of a ProcessID

Hi Poniente;
You dont need the "GetPriorityClass" API function", you can translate the
process priority value by using a function like :

.....
POutput(r, 3) = PriorityClass(objProcess.Priority)
.....

' Base priority of a process is a numeric value from
' zero (lowest priority) to 31 (highest priority).
Private Function PriorityClass(ByVal Priority&) As String
PriorityClass = "Unknown"
Select Case Priority
Case 4: PriorityClass = "Low"
Case 8: PriorityClass = "Normal"
Case 13: PriorityClass = "High"
Case 24: PriorityClass = "RealTime"
End Select
End Function

Regards;
MP



"Poniente" a écrit dans le message de
...
I'd like to read the current CPU priority as found in the task
managers' processes tab, when right-clicking on a process, and
selecting 'set priority'.

I've tried using
Private Declare Function GetPriorityClass Lib "kernel32" (ByVal
hProcess As Long) As Long

and using

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from
Win32_Process")

For Each objProcess In colProcesses
r = r + 1
POutput(r, 1) = objProcess.ProcessID
POutput(r, 2) = objProcess.Name
POutput(r, 3) = objProcess.Priority
POutput(r, 4) = objProcess.Handle
POutput(r, 5) = GetPriorityClass(POutput(r, 4))
Next

but, but this GetPriorityClass function always returns a zero, even
though I can see some priorities are 'AboveNormal'. So this is where
I'm stuck..

Your help is appreciated.
Poniente


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Get CPU Priority of a ProcessID

Thanks again Michel (and sorry for the late reply).


On 23 aug, 13:14, "Michel Pierron" wrote:
HiPoniente;
You dont need the "GetPriorityClass" API function", you can translate the
process priority value *by using a function like :

....
POutput(r, 3) = PriorityClass(objProcess.Priority)
....

' Base priority of a process is a numeric value from
' zero (lowest priority) to 31 (highest priority).
Private Function PriorityClass(ByVal Priority&) As String
PriorityClass = "Unknown"
Select Case Priority
Case 4: PriorityClass = "Low"
Case 8: PriorityClass = "Normal"
Case 13: PriorityClass = "High"
Case 24: PriorityClass = "RealTime"
End Select
End Function

Regards;
MP

"Poniente" a écrit dans le message ...







I'd like to read the current CPU priority as found in the task
managers' processes tab, when right-clicking on a process, and
selecting 'set priority'.


I've tried using
Private Declare Function GetPriorityClass Lib "kernel32" (ByVal
hProcess As Long) As Long


and using


* *Set objWMIService = GetObject("winmgmts:" _
* * * *& "{impersonationLevel=impersonate}!\\" _
* * * *& strComputer & "\root\cimv2")
* *Set colProcesses = objWMIService.ExecQuery("Select * from
Win32_Process")


* *For Each objProcess In colProcesses
* * * *r = r + 1
* * * *POutput(r, 1) = objProcess.ProcessID
* * * *POutput(r, 2) = objProcess.Name
* * * *POutput(r, 3) = objProcess.Priority
* * * *POutput(r, 4) = objProcess.Handle
* * * *POutput(r, 5) = GetPriorityClass(POutput(r, 4))
* *Next


but, but this GetPriorityClass function always returns a zero, even
though I can see some priorities are 'AboveNormal'. So this is where
I'm stuck..


Your help is appreciated.
Poniente


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver Priority KSA Excel Worksheet Functions 0 October 22nd 09 06:58 PM
priority setting Formatting Excel Discussion (Misc queries) 0 April 1st 09 06:50 PM
Priority Charge Michell Major Excel Discussion (Misc queries) 3 October 18th 06 12:13 PM
Sorting according to priority help!! Aravind Excel Discussion (Misc queries) 3 July 28th 06 01:50 PM
Event priority anonymousA Excel Programming 2 November 3rd 05 09:06 PM


All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"