Hewijnabob Posted May 7, 2010 Share Posted May 7, 2010 I am having some trouble gathering performance data using the PDH.dll. I have read many many posts from Acend4nt (this is mostly borrowed from his work) and I have checked out Monoceres DLL PDF. I have also read the MSDN information for how to use it, but I am a little lost. I am trying to get performance sample values via the "PdhGetFormattedCounterValue" call. I don't seem to be getting them either via the direct return, or in the struct (which is where I think they should be coming from.) I partially built the struct to match the definition, but I am not sure if I need to do that or not. I also don't know how to handle the union portion of the struct. Please take a look at the code and point me in the right direction if you can. I embedded links to MSDN for the functions.Original PDH.au3 Link to comment Share on other sites More sharing options...
Ascend4nt Posted May 9, 2010 Share Posted May 9, 2010 I decided to upload the current Work-In-Progress version of my PDH Performance Counters project. See the link in my signature.. or heck:http://www.autoitscript.com/forum/index.php?showtopic=90736 My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Hewijnabob Posted May 10, 2010 Author Share Posted May 10, 2010 I decided to upload the current Work-In-Progress version of my PDH Performance Counters project. See the link in my signature.. or heck:http://www.autoitscript.com/forum/index.php?showtopic=90736You just made my day! Thank you! Link to comment Share on other sites More sharing options...
Ascend4nt Posted May 10, 2010 Share Posted May 10, 2010 Your welcome I hate Unions, especially ones containing structs withing structs within structs etc.. drives me crazy. And now with x64, everything needs to be rechecked and recalculated, and padding needs to be reconsidered.. grr.. In this particular structure (PDH_COUNTER_INFO) which you just gotta love, I've recalculated the info for x64 mode. Instead of 'PDH_COUNTER_PATH_ELEMENTS' being the largest element of the union (in 32-bit mode), in 64-bit mode its now 'PDH_DATA_ITEM_PATH_ELEMENTS' (or the embedded 'struct' definition in the union, which contains the same datatypes). I have to check for x64 mode now and adjust the Structure string appropriately. And now I'm finding more x64 issues to sort out. Fun! My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
wolf9228 Posted May 10, 2010 Share Posted May 10, 2010 I am having some trouble gathering performance data using the PDH.dll. I have read many many posts from Acend4nt (this is mostly borrowed from his work) and I have checked out Monoceres DLL PDF. I have also read the MSDN information for how to use it, but I am a little lost. I am trying to get performance sample values via the "PdhGetFormattedCounterValue" call. I don't seem to be getting them either via the direct return, or in the struct (which is where I think they should be coming from.) I partially built the struct to match the definition, but I am not sure if I need to do that or not. I also don't know how to handle the union portion of the struct. Please take a look at the code and point me in the right direction if you can. I embedded links to MSDN for the functions. typedef struct _PDH_FMT_COUNTERVALUE { DWORD CStatus; union { LONG longValue; double doubleValue; LONGLONG largeValue; LPCSTR AnsiStringValue; LPCWSTR WideStringValue; } ; } PDH_FMT_COUNTERVALUE, *PPDH_FMT_COUNTERVALUE; C ++ SizeOf(PDH_FMT_COUNTERVALUE) = 16 BYTE DWORD = 4 BYTE union = 16 - 4 = 12 $Tag_PDH_FMT_COUNTERVALUE = "DWORD CStatus;BYTE union[12]" $PDH_FMT_COUNTERVALUE = DllStructCreate($Tag_PDH_FMT_COUNTERVALUE) $PPDH_FMT_COUNTERVALUE = DllStructGetPtr($PDH_FMT_COUNTERVALUE) $CStatus = DllStructGetData($PDH_FMT_COUNTERVALUE,"CStatus") $union = DllStructCreate("BYTE union[12]",DllStructGetPtr($PDH_FMT_COUNTERVALUE,2)) $union Data To Autoit Operators Compared Operators Compared in Different Languages http://msdn.microsoft.com/en-us/library/2hxce09y%28VS.71%29.aspx ; C ++ SizeOf(PDH_FMT_COUNTERVALUE) = 16 BYTE ;DWORD = 4 BYTE ; union = 16 - 4 = 12 $Tag_PDH_FMT_COUNTERVALUE = "DWORD CStatus;BYTE union[12]" $PDH_FMT_COUNTERVALUE = DllStructCreate($Tag_PDH_FMT_COUNTERVALUE) $PPDH_FMT_COUNTERVALUE = DllStructGetPtr($PDH_FMT_COUNTERVALUE) $CStatus = DllStructGetData($PDH_FMT_COUNTERVALUE,"CStatus") $union = DllStructCreate("BYTE union[12]",DllStructGetPtr($PDH_FMT_COUNTERVALUE,2)) ;$union Data To autoit Operators Compared ;Operators Compared in Different Languages ;http://msdn.microsoft.com/en-us/library/2hxce09y%28VS.71%29.aspx صرح السماء كان هنا Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now