Sign in to follow this  
Followers 0
DarkMatter

Calling PDH.DLL

1 post in this topic

I'm doing this just to get a better handle on Dll calling. I am having issues calling C:\windows\system32\pdh.dll.

I'm sure it has something to do with the variable types I am using in calling the functions but I am unsure. Does anyone have any exsperiance calling PDH.DLL?

Here is my code:

Dim $QueryHandle
Dim $Counter
Dim $lData
Dim $Percent = 0


Init()

While 1

    DllCall("pdh.dll", "int", "PdhCollectQueryData", "long", $QueryHandle)
    $Percent = DllCall("pdh.dll", "double", "PdhVbGetDoubleCounterValue", "long", $Counter, "long", $lData)
    ConsoleWrite($Percent[0] & @CRLF & $Percent[1] & @CRLF & $Percent[2] & @CRLF)
Wend

Func Init()
    DllCall("pdh.dll", "long", "PdhVbOpenQuery", "long", $QueryHandle)
    DllCall("pdh.dll", "long", "PdhVbAddCounter", "long", $QueryHandle, "str", "\Processor(0)\% Processor Time", "long", $Counter)
    DllCall("pdh.dll", "int", "PdhCollectQueryData", "long", $QueryHandle)
    DllCall("pdh.dll", "double", "PdhVbGetDoubleCounterValue", "long", $Counter, "long", $lData)
EndFunc

The odd thing is I am not getting any errors when I check @error but my return value on $Percent is always nothing.

Any ideas?


[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0