News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HDD activity monitor

Started by MichaelW, March 11, 2006, 09:05:33 AM

Previous topic - Next topic

MichaelW

The attachment is an HDD activity monitor app that uses the Performance Data Helper (PDH) DLL functions to monitor disk read/write activity. The app uses an invisible window to handle the messages, and displays an icon in the taskbar status area (AKA system tray). I modeled the icon, tooltip, and popup menu code after Iczelion's Win32 Assembly Tutorial part 23, correcting a problem with the menu not closing when the user clicks outside the menu. In the course of doing this I discovered that the status area does not display some icons correctly (even 16x16x4bpp icons), and that it is difficult to eliminate flicker in animated icons. I tested under Windows 2000 only.

MSDN: Performance Monitoring, Performance Data

MSDN: Using the Taskbar

EDIT: After 42 downloads I replaced the attachment with a version that derives the object and counter names from the index values. This should correct the problems with localized languages other than English. I wonder why Microsoft did not provide for localization of the instance name (in this case '_Total').


[attachment deleted by admin]
eschew obfuscation

skywalker

Quote from: MichaelW on March 11, 2006, 09:05:33 AM
The attachment is an HDD activity monitor app that uses the Performance Data Helper (PDH) DLL functions to monitor disk read/write activity. The app uses an invisible window to


It works great under XP SP2.


Mark Jones

This is great Michael, thanks! :bg
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Vortex

The application fails on my Win XP HE Sp 2 and displays a message box saying :
QuotePdhAddCounter failed

MichaelW

Hi Vortex,

Thanks for testing. I'm not sure what the problem could be, and I currently have no way to test under anything but Windows 2000 SP4. The attachment is a version that includes some additional PDH constants and reports some additional information. Hopefully, this will make it possible to identify the problem.

MSDN: PdhGetDllVersion

MSDN: Checking PDH Interface Return Values



[attachment deleted by admin]
eschew obfuscation

PBrennick


It is working well on my machine, this is a pretty cool idea!
Paul
The GeneSys Project is available from:
The Repository or My crappy website

PBrennick

Erol,

I ran MichaelW's debug version on my WinXP HE Sp2, I got the following results,

00000503 is the version of pdh.dll

Counter Path
\\GeneSys\PhysicalDisk(_Total) %Disk Time

Paul
The GeneSys Project is available from:
The Repository or My crappy website

farrier

MichaelW,

As Khan's son would say to his father: "Yours' is a superior method!"

I've been playing with it today.  I have not yet found a list of the objects and counter, or an explaination of them.  But I did write the attached program--FASM syntax--to show a list of those available on the users machine.  Quite simple.

In my research, I found a note that PDH was available and usable on machines on which the Platform SDK was installed!

Thanks,

farrier


[attachment deleted by admin]
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

MichaelW

farrier,

Thanks for the code. I now have an incentive to finish the PDH include file for MASM that I recently stopped working on.

According to this 1998 arcticle PDH.dll is available only with the PSDK.

But according to this and this PDH.dll shipped with Windows 2000.

And according to the DLL Help Database it shipped with all versions of Windows after Windows 2000, including Windows XP SP2.

eschew obfuscation

farrier

MichaelW,

I think that is the very article I had in mind when I posted.  Thanks for the other links!  I'll play some more with this.

Again, thanks for the original post, I'd never seen this before, or never took notice of it.

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

BytePtr

Nice work Michael  :U
XP Pro (no SP's), no problems found, works like a charm.

Timbo

Michael,

XP Pro SP2: flawless execution.

Vortex:

It is possible to disable disk performance monitoring on 2K/XP workstations.  Is it possible you have done this and neglected this detail in your recollection?

Regards.

Tim

Phoenix

Michael,

doesn't work for me, too --> Win XP SP 2, german language.

AFAIK, the names of the counters are stored in localized language: % Disk Time in english (US) is Zeit (%) in german (on my system). I had similar problems when i tried to use pdh.dll to retrieve CPU performance.

Try PdhLookupPerfNameByIndex, the index seems to be the same in each language (200 for % Disk Time).

;-- Retrieve performance object name by index: "% Processor Time"
mov dwBufferSize,MAX_PATH
Invoke GlobalAlloc,GPTR,dwBufferSize
mov pcpe.szCounterName,eax
Invoke PdhLookupPerfNameByIndex,pcpe.szMachineName,6,pcpe.szCounterName, ADDR dwBufferSize


This one solved my problem.

Regards, Phoenix

MichaelW

Thanks Phoenix,

I recall seeing where you used index values in your CPULoad_pdh.asm source, but I failed to recognize your reason for doing so. When I started coding this I could not find a table of index values, so I selected the path of least resistance. Time for an international version.


eschew obfuscation

Phoenix

Michael,

in attached file is a list with indexes. Not well formatted, but it helped me....

Regards, Phoenix

[attachment deleted by admin]