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.
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.
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.