Reputation: 26981
Does System.Diagnostic get its data by querying the WMI or by other means? Is WMI querying the most basic way all these operations employ to get system information such as running processes, or are there even more direct methods?
Upvotes: 1
Views: 359
Reputation: 2638
No, it doesn't use WMI. It uses direct native API calls via internal classes within the System.Win32 namespace in mscorlib.dll and System.dll. Most classes like PerformanceCounter and EventLog just access the registry which uses native calls to advapi32.dll. Other functionality like getting a process list use calls in winnt.dll or kernel32.dll depending on the version of Windows. You can find more information about the native Win32 calls used here and more detailed information about performance counters here.
You can verify this using dotPeek or Reflector.NET and examining System.Diagnostics in mscorlib.dll and System.dll.
Upvotes: 4
Reputation: 16199
If you want to find out for yourself you can step into the .NET framework source code.
Steps here on how to do it through Visual Studio: http://blogs.microsoft.co.il/blogs/arik/archive/2010/07/12/step-into-net-framework-4-0-source-code.aspx
Upvotes: 1