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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/performance_data.asp)
MSDN: Using the Taskbar (http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/taskbar.asp?frame=true#tbnotify_Using)
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]
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.
This is great Michael, thanks! :bg
The application fails on my Win XP HE Sp 2 and displays a message box saying :
QuotePdhAddCounter failed
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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/pdhgetdllversion.asp)
MSDN: Checking PDH Interface Return Values (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/checking_pdh_interface_return_values.asp)
[attachment deleted by admin]
It is working well on my machine, this is a pretty cool idea!
Paul
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
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]
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 (http://www.microsoft.com/msj/0598/hood0598.aspx) PDH.dll is available only with the PSDK.
But according to this (http://www.microsoft.com/Downloads/details.aspx?displaylang=en&FamilyID=5D46AFD4-DA0C-4B8E-B202-374F3DFD3D5D) and this (http://support.microsoft.com/default.aspx?scid=kb;en-us;Q284996) PDH.dll shipped with Windows 2000.
And according to the DLL Help Database (http://support.microsoft.com/dllhelp/) it shipped with all versions of Windows after Windows 2000, including Windows XP SP2.
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
Nice work Michael :U
XP Pro (no SP's), no problems found, works like a charm.
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
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
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.
Michael,
in attached file is a list with indexes. Not well formatted, but it helped me....
Regards, Phoenix
[attachment deleted by admin]
Michael,
It works great on my work machine running Windows 2000.
I get the same error as Vortex on my home machine with XP Pro and SP2. The pdh.dll version is 00000503 and the error code returned is:
C0000BB8
I also don't see the PhysicalDisk counter in the app that farrier posted.
C0000BB8 is PDH_CSTATUS_NO_OBJECT, "The specified machine was found, but no matching performance object was found on that machine."
I have updated the original attachment with a modified version that should work OK with localized languages other than English.
Works like a charm :U
Phoenix,
Thanks for the list of Index numbers. Where did you get that list, or did you construct it?
MichaelW,
In your latest 'Multi-Lingual' program, you use the proper index number to retrieve the corresponding string for the index. You do that for the:
objectName originally PhysicalDisk
counterName originally % Disk Time
But you leave the
instanceName originally _Total
as is. Would not this normally be translated into the local language? Or does the underscore imply a Global/Total value? It seems that this 'instance' has either this _Global/_Total value and then values specific to hardware or software installed on the particular machine.
Thanks for your help with this subject!!
farrier
Microsoft apparently does not translate the instance names. If I pass the instance name '_Total' to PdhLookupPerfIndexByName it returns PDH_STRING_NOT_FOUND, and an index value of zero. For an index value of zero PdhLookupPerfNameByIndex returns zero, which is ERROR_SUCCESS, but the returned string has a length of zero. This all seems kind of sloppy to me, because while some instance names might be reasonably universal, '_Total' is not.
Hi MichaelW,
Many thanks for the new upload, it works fine on my Win XP HE Sp2 :U
Farrier,
this list is a direct copy from the registry. You will find the list of counters (and help) here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009
and there is an additional entry for your local language, i. e. for german:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\007
It took me some time to recall where i found this information, i could have posted the key directly... :red
Regards, Phoenix
Edit:
Additional location: C:\WINDOWS\system32\PerfStringBackup.INI --> [PerfStrings_007] and [PerfStrings_009]
Very nice :U
Works great (XP Pro SP2).