开发者

NetworkInformation.IPGlobalProperties vs. WMI for Ipaddresses, dns-servers, dhcp etc

开发者 https://www.devze.com 2023-03-22 04:16 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消