WMI, C# and processes 
Author Message
 WMI, C# and processes

Hello,

i have to code an application wich is supposed to monitor processes
(creation date, CPU time, etc..) and CPUs ( user time by process, etc.)
for multi-CPUs servers.

I use WMI events to know when a process is created or deleted but i don't
know how to get the id of this process, i can't continue without this id.

could someone help me ?

thanks.
Stphan.



Sat, 25 Dec 2004 18:59:02 GMT  
 WMI, C# and processes
Stephan,

    The Win32_Process class has a ProcessId field that you can query for the
Process Id.

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Hello,

> i have to code an application wich is supposed to monitor processes
> (creation date, CPU time, etc..) and CPUs ( user time by process, etc.)
> for multi-CPUs servers.

> I use WMI events to know when a process is created or deleted but i don't
> know how to get the id of this process, i can't continue without this id.

> could someone help me ?

> thanks.
> Stphan.



Sat, 25 Dec 2004 19:57:08 GMT  
 WMI, C# and processes
I've seen this property and that's what i'm trying to get. In fact when i
launch my testing app, it will show "Process Created !" in a label when i
lauhc notepad for example. But i don't where i can get an handle on the
instance of the Win32_Process class created.

This is the way i did:
Using the WMI extension for VS .NET server explorer, I created a managed
class from Win32_Process and i subscribed to an event wiwh WQL query is :
SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA
"Win32_Process"

this is the method used:
private void CreationEven{*filter*}cher_EventArrived(object sender,
System.Management.EventArrivedEventArgs e)

{

LblRes.Text= "Process Created !";

Quote:
}

maybe i could do something with "System.Management.EventArrivedEventArgs e"
but i don't know what.
I just need the handle of the instance (as you wrote it there is the field
"ProcessID") created or the pid of the process...

Stphan.



Quote:
> Stephan,

>     The Win32_Process class has a ProcessId field that you can query for
the
> Process Id.

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET MVP]



> > Hello,

> > i have to code an application wich is supposed to monitor processes
> > (creation date, CPU time, etc..) and CPUs ( user time by process, etc.)
> > for multi-CPUs servers.

> > I use WMI events to know when a process is created or deleted but i
don't
> > know how to get the id of this process, i can't continue without this
id.

> > could someone help me ?

> > thanks.
> > Stphan.



Sat, 25 Dec 2004 22:03:51 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. WMI - WMI Login Cotrol causes exception when destroying

2. Writing a WMI provider in C#

3. C# and WMI / SNMP

4. SNMP and WMI with C#

5. Checkpoint/Restart- File processing in C#

6. exiting a .NET/C# process

7. How to get AccessibleObject/Control which is not owned by my process in C#(Active Accessibility)

8. Processing C# doc comments

9. How do I create the equivalent to an ActiveX.exe out of process component in C#

10. Out-of-Process exe LocalSever for C#?

11. How to spawn a process using C++ from C#

12. API to start a Process from C#

 

 
Powered by phpBB® Forum Software