WMI vs Windows APIs

混江龙づ霸主 提交于 2020-01-12 07:35:07

问题


There are any advantages or disadvantages of using the WMI instead of Windows API to access to the information of the system? as speed, additional permissions, memory usage.

or depends on the WMI class and how the WMI implements the access to the information?


回答1:


The main disadvantage of WMI is speed, it is slow to query data and if you are trying to use it during start up it can delay you starting as the WMI service takes a long time to come up.

However, WMI information is richer, as in you need to sometimes make several API calls to get the same amount, some information is a lot easier to get at and the filtering syntax can dramatically reduce the amount code you have to write.

If speed isn't a massive issue, I would always lean towards WMI.




回答2:


Disadvantage: Speed
Advantage: Wraps the native API, so as API calls change, unless the WMI changed also you will (might) get the benefits. It will also save you some coding.




回答3:


And richer data. Since programmers can write their own WMI providers, you can get data from third party software. That's what Microsoft is doing in their security center interface-getting data from third-party antivirus and firewall softwares.




回答4:


Advantage of WMI: Can get info about remote machines as easily as current machine




回答5:


And impersonation!
You may have your program run with a non-proviledged user, but access a remote machine by specifying credentials.



来源:https://stackoverflow.com/questions/1713389/wmi-vs-windows-apis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!