ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to call GetPriorityClass,GetThreadPriority? (https://www.excelbanter.com/excel-programming/425653-how-call-getpriorityclass-getthreadpriority.html)

joeu2004

How to call GetPriorityClass,GetThreadPriority?
 
How can I call Get/SetPriorityClass and Get/SetThreadPriority?

At issue is the HANDLE parameter. I had hoped that I might get away
with passing a NULL pointer (ByVal 0), but it didn't work.

Public Declare Function GetPriorityClass Lib "kernel32" (ByRef pHandle
As Long) As Long
Public Declare Function GetThreadPriority Lib "kernel32" (ByRef
tHandle As Long) As Long

Private Sub getProcInfo()
Dim x As Long
x = GetPriorityClass(ByVal 0)
Debug.Print "GetPriorityClass= "; Hex(x)
x = GetThreadPriority(ByVal 0)
Debug.Print "GetThreadPriority= "; Hex(x)
End Sub

Leith Ross[_771_]

How to call GetPriorityClass,GetThreadPriority?
 

joeu2004;272545 Wrote:
How can I call Get/SetPriorityClass and Get/SetThreadPriority?

At issue is the HANDLE parameter. I had hoped that I might get away
with passing a NULL pointer (ByVal 0), but it didn't work.

Public Declare Function GetPriorityClass Lib "kernel32" (ByRef pHandle
As Long) As Long
Public Declare Function GetThreadPriority Lib "kernel32" (ByRef
tHandle As Long) As Long

Private Sub getProcInfo()
Dim x As Long
x = GetPriorityClass(ByVal 0)
Debug.Print "GetPriorityClass= "; Hex(x)
x = GetThreadPriority(ByVal 0)
Debug.Print "GetThreadPriority= "; Hex(x)
End Sub


Hello joeu2004,

You have to pass in a valid handle to the function. Null will not
default to the calling thread or class.


--
Leith Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=75943


joeu2004

How to call GetPriorityClass,GetThreadPriority?
 
On Mar 16, 11:24*pm, Leith Ross
wrote:
You have to pass in a valid handle to the function.
Null will not default to the calling thread or class.


Okay. Aha! I just discovered GetCurrentProcess() and GetCurrentThread
(). I also realized that I should pass those pseudo-handles by value,
not by reference, to GetPriorityClass() and GetThreadPriority().

With those two fixes, things are working now.

Many thanks!


All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com