WMI使用WBEM_FLAG_FORWARD_ONLY标志调用C# [英] WMI Calls in C# with WBEM_FLAG_FORWARD_ONLY Flag

查看:56
本文介绍了WMI使用WBEM_FLAG_FORWARD_ONLY标志调用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System.Management;

ManagementObjectSearcher searcher = new ManagementObjectSearcher(" SELECT UserName FROM
Win32_ComputerSystem");


                if(searcher!= null)

                {

                    ManagementObjectCollection
collection  = searcher.Get();


}



要释放COM对象。请帮助我们如何在C#中添加Flags或建议任何其他方法
来执行WMI查询。

推荐答案

考虑$的构造函数b $ b ManagementObjectSearcher ,它接受 EnumerationOptions 对象。将 EnumerationOptions
可重绕参数的值设置为 false
https:// docs。 microsoft.com/en-us/dotnet/api/system.management.managementobjectsearcher.-ctor?view=netframework-4.7.2#System_Management_ManagementObjectSearcher__ctor_System_String_System_String_System_Management_EnumerationOptions _

Consider the constructors of ManagementObjectSearcher that takes an EnumerationOptions object. Set the value of rewindable parameter of EnumerationOptions to false: https://docs.microsoft.com/en-us/dotnet/api/system.management.managementobjectsearcher.-ctor?view=netframework-4.7.2#System_Management_ManagementObjectSearcher__ctor_System_String_System_String_System_Management_EnumerationOptions_


这篇关于WMI使用WBEM_FLAG_FORWARD_ONLY标志调用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆