Should I prefer one over the other?
Im leani开发者_开发技巧ng heavily towards NetworkInformation.IPGlobalProperties
instead of select * from win32_networkAdapterConfiguration
from WMI if I can verify that all the information I need is available
Use NetworkInformation
if you can and if it can provide everything you want. WMI is a much more generic interface that implements all sorts of things, and is a service that can be stopped or might not be available or even corrupted (it has happened to me a few times). NetworkInformation
I believe is a wrapper around the Win32 APIs so it should almost always work and have no dependencies (besides .NET 3.0+).
Always better to use the simplest and more specific tool that gets the job done.
As far as I know WMI is much slower
精彩评论