Jump to content
Sign in to follow this  

Calling PDH.DLL

Recommended Posts


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


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)

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)

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.