Re: Can't get IWbemConfigureRefresher::AddObjectByPath to work with Win32_PerfRawData_PerfProc_Process.IDProcess
- From: robert@xxxxxxxxxxx
- Date: 1 Sep 2006 06:23:25 -0700
OK following your suggestion I've formatted the string, wstr, in the
code snippet above as
wsprintfW(wstr, L"Win32_PerfRawData_PerfProc_Process.IDProcess=\"%u\"",
pid);
where pid is the processID that I'm interested in. However, using this
string AddObjectByPath still returns an HRESULT of
WBEM_E_CRITICAL_ERROR. It does seem to work if instead of querying for
the processID I ask for a specific process name, as in
wsprintfW(wstr,
L"Win32_PerfRawData_PerfProc_Process.Name=\"Notepad\"");
where we assume Notepad is running. But I want to call AddObjectByPath
with Win32_PerfRawData_PerfProc_Process.IDProcess for a specific
process ID.
Does anyone know what I'm doing wrong?
Thanks,
Rob
Manbinder Pal Singh [MSFT] wrote:
When you do something like this
wmic process where Handle='784' get __Path
you will get __path for that process whose handle is 784.
You can give this __Path in the below method.
The Path generally looks like this
\\MANI-XP2\ROOT\CIMV2:Win32_Process.Handle="784"
and to be more generic
\\machinename\root\namespace:win32_class.keyname="keyvalue"
There can be more keys also in a class.
Hope this helps
Thanks,
Manbinder Pal Singh
This posting is provided "AS IS" with no warranties, and confers no rights.
<robert@xxxxxxxxxxx> wrote in message
news:1156927253.578123.299410@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sorry but I don't get it. Would you be a bit more explicit and tell me
how to construct the string, say for a process with an ID of 12345,
that I can use in the AddObjectByPath method in this case?
Thanks,
Rob
Manbinder Pal Singh [MSFT] wrote:
When you see the PATH property of an instance of win32_process class you
should be able to see the format in which you need to pass t his.
Thanks,
Manbinder Pal Singh
This posting is provided "AS IS" with no warranties, and confers no
rights.
<robert@xxxxxxxxxxx> wrote in message
news:1155821318.210648.156790@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OK I'll rephrase my question if it makes it more clear. What is the
proper syntax for calling the IWbemConfigureRefresher::AddObjectByPath
method when specifying a particular process ID for the object path
"Win32_PerfRawData_PerfProc_Process.IDProcess"?
Anyone out there with an answer?
Rob
robert@xxxxxxxxxxx wrote:
Hi all,
I want to monitor my program's consumption of CPU processing power. I
only found some vbscript examples in the MSDN on how to use the
Win32_PerfRawData_PerfProc_Process class as an object path argument in
the interface method, IWbemConfigureRefresher::AddObjectByPath. So
what
I'm looking for is a C++ example on how to get the following code
snippet to work:
DWORD pid = GetCurrentProcessId();
wchar_t wstr[123];
wsprintfW(wstr, L"Win32_PerfRawData_PerfProc_Process.IDProcess =
<%u>", pid);
hr = pConfig->AddObjectByPath(pNameSpace, wstr, 0, NULL,
&pthisprocess, &lId);
I guess the syntax of the object path is wrong as I keep getting
HRESULTS of invalid path or access violations depending on how I tweak
the string.
Anybody got a working C++ code example on how to call this method?
Thanks,
Rob
.
- Follow-Ups:
- Re: Can't get IWbemConfigureRefresher::AddObjectByPath to work with Win32_PerfRawData_PerfProc_Process.IDProcess
- From: Manbinder Pal Singh [MSFT]
- Re: Can't get IWbemConfigureRefresher::AddObjectByPath to work with Win32_PerfRawData_PerfProc_Process.IDProcess
- Prev by Date: Re: Can't get IWbemConfigureRefresher::AddObjectByPath to work with Win32_PerfRawData_PerfProc_Process.IDProcess
- Next by Date: Re: Creating Shares Remotely
- Previous by thread: Re: Can't get IWbemConfigureRefresher::AddObjectByPath to work with Win32_PerfRawData_PerfProc_Process.IDProcess
- Next by thread: Re: Can't get IWbemConfigureRefresher::AddObjectByPath to work with Win32_PerfRawData_PerfProc_Process.IDProcess
- Index(es):
Relevant Pages
|