У меня есть ошибка, которую я не могу решить, даже не ища inte rnet. Мой код:
public static void GetClasses(ref List<ListViewItem> items)
{
ManagementPath path = new ManagementPath(string.Format("\\\\{0}\\ROOT\\CIMV2", SystemInformation.ComputerName.ToUpperInvariant()));
ConnectionOptions options = new ConnectionOptions
{
EnablePrivileges = true,
Impersonation = ImpersonationLevel.Impersonate,
Authentication = AuthenticationLevel.Default,
Username = null,
SecurePassword = null
};
ManagementScope managementScope = new ManagementScope(path, options);
managementScope.Connect();
ObjectGetOptions options2 = new ObjectGetOptions();
new ManagementScope(new ManagementObject(managementScope, path, options2).Path, options);
ObjectQuery query = new ObjectQuery("SELECT * FROM meta_class WHERE __Class LIKE \"%%%\" AND NOT __Class LIKE \"[_][_]%\" AND NOT __Class LIKE \"Win32_Perf%\" AND NOT __Class LIKE \"MSFT[_]%\"");
EnumerationOptions options3 = new EnumerationOptions
{
EnumerateDeep = true,
UseAmendedQualifiers = true
};
ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(managementScope, query, options3);
new List<WMIClass>();
foreach (ManagementClass managementClass in from ManagementClass currentClass in managementObjectSearcher.Get()
orderby currentClass.ClassPath.ClassName
select currentClass)
{
bool flag = false;
// using (ManagementObjectCollection.ManagementObjectEnumerator enumerator2 = disks.GetEnumerator())
using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
{
while (enumerator2.MoveNext())
{
if (enumerator2.Current.Type == CimType.String)
{
flag = true;
}
}
}
if (flag)
{
WMIClass wmiclass = new WMIClass(managementClass);
ListViewItem listViewItem = new ListViewItem
{
Name = wmiclass.DisplayName,
Text = wmiclass.DisplayName,
ToolTipText = wmiclass.Description,
Tag = wmiclass
};
listViewItem.SubItems.Add(wmiclass.Description);
items.Add(listViewItem);
}
}
}
Строка ошибки:
using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
// using (ManagementObjectCollection.ManagementObjectEnumerator enumerator2 = disks.GetEnumerator())
Я не знаю, в чем ошибка. Если вы можете мне помочь, пожалуйста, я не очень хорошо понимаю язык. Буду очень признателен за вашу помощь.