Reputation: 3440
I am writing an C# plug-in for an auditing application, which need to fetch a list of 32 bit applications running inside a 64-bit OS. I got stuck up at this point on how to identify a 32-bit process.
Please help me.
Upvotes: 4
Views: 1805
Reputation: 19070
You can use the IsWow64Process
windows API call to determine if a process is running under 32bit emulation on a 64bit OS.
Here is the pinvoke link
Update: I benchmarked this a little bit, with the following results:
Process.GetProcesses()
takes the majority of the time with approx. 12ms on my laptop having 93 processes runningIsWow64Process
call took approx. 0.1ms per process on the same laptop.Basically: If you can cope with the fact that the process might go away after you obtained the list and before you managed to query it then using the pinvoke way seems faster and snappier to me than using WMI. Although WMI might be the less intrusive way (from a process standpoint of view).
Upvotes: 2
Reputation: 14874
Take a look at http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/491ea0b3-3e5b-4fa2-a2c3-2f1e485aed0c/.
I think it's possible with WMI.
Upvotes: 2