×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

using PdhExpandCounterPath On XP-SP2

using PdhExpandCounterPath On XP-SP2

using PdhExpandCounterPath On XP-SP2

(OP)
Question originally submitted on VisualBasic(Microsoft)Win32API forum

I use the ProcessList function below to retrieve a list of all processes called E2eDgCnx.

Up until now, this has performed adequately but we are about to implement XP SP2 and in testing this now fails.

CODE

Public Declare Function PdhExpandCounterPath Lib "Pdh.Dll" Alias "PdhExpandCounterPathA" (ByVal szWildCardPath As String, ByVal mszExpandedPathList As String, pcchPathListLength As Long) As Long

Public Function ProcessList()As String

Dim lngReturnValue As Long, lngBufferLen As Long
Dim strSearchPath As String, strExpandedPath As String

lngBufferLen = 8192
strExpandedPath = String(lngBufferLen, vbNullChar)
strSearchPath = "\Process(E2eDgCnx)\% Processor Time"

lngReturnValue = PdhExpandCounterPath(strSearchPath, strExpandedPath, lngBufferLen)

ProcessList = Left(strExpandedPath, lngBufferLen)

End Sub

I've carried out some testing using multiple copies of Notepad as the target
ie. strSearchPath = "\Process(notepad)\% Processor Time" and found

pre-SP2 returns
\Process(notepad)\% Processor Time
repeated in chronological order for each instance of notepad (or nothing if notepad is not running)

SP2 returns the single result
\\ComputerName\Process(notepad)\% Processor Time
regardless of the number of notepads running (and even if notepad is not running)

If I try strSearchPath = "\Process(*)\% Processor Time" and then filter the results for "(notepad"

Pre-SP2 again returns
\Process(notepad)\% Processor Time
repeated for each instance of notepad (or nothing if notepad is not running) in chronological order of notepad launches

SP2 returns
...
\\ComputerName\Process(notepad#2)\% Processor Time
\\ComputerName\Process(notepad#1)\% Processor Time
\\ComputerName\Process(notepad)\% Processor Time
in reverse chronological order of notepad launches
or nothing if notepad is not running

I don't really want have to double up my functions to cater for different service packs so can anyone advise how to retieve the required data in chronological order.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close