WMI vs Windows APIs

2020-06-16 06:16发布

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?

标签: winapi wmi
5条回答
霸刀☆藐视天下
2楼-- · 2020-06-16 06:22

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.

查看更多
霸刀☆藐视天下
3楼-- · 2020-06-16 06:25

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楼-- · 2020-06-16 06:30

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.

查看更多
Juvenile、少年°
5楼-- · 2020-06-16 06:39

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

查看更多
来,给爷笑一个
6楼-- · 2020-06-16 06:41

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

查看更多
登录 后发表回答