How to get methods from WMI

点点圈 提交于 2019-12-13 20:01:14

问题


tl;dr What should I SELECT instead of * in order to get the methods?

More info:

Here's an example:

using (var s = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM someClass"))
    foreach (var obj in s.Get())

If I just ask for one property it's not enough - I get an exception when trying obj.InvokeMethod(...);.

If I ask for * it is enough but I rather avoid this if possible.

I don't see any property for getting the methods (-Disable, Enable,...) in the docs for WMI classes. And if it's not on the list - how come * works? Isn't it just supposed to ask for all of those on the list?

EDIT

Someone suggested using ManagementClass instead of ManagementObjectSearcher. Does this load all properties like *? (If not, that's a good answer. Though in my actual case I need a property besides the ability to call a method. And my theoretical questions remains - is * more than just all.)

来源:https://stackoverflow.com/questions/49798851/how-to-get-methods-from-wmi

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