C# 在windows上获取ID
我有一个我无法解决的错误,甚至连搜索互联网都不行。 我的代码: 我不知道是什么错误。如果你能帮我,我不太懂这门语言。 非常感谢您的帮助。试试换衣服C# 在windows上获取ID,c#,C#,我有一个我无法解决的错误,甚至连搜索互联网都不行。 我的代码: 我不知道是什么错误。如果你能帮我,我不太懂这门语言。 非常感谢您的帮助。试试换衣服 using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator()) { while (enumerator2.MoveNext()) { if (enumerator
using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
{
while (enumerator2.MoveNext())
{
if (enumerator2.Current.Type == CimType.String)
{
flag = true;
}
}
}
到
首先,必须删除“using”,因为GetEnumerator()不返回一次性对象;其次,使用“managementClass.Properties.GetEnumerator()”而不是“managementClass.Properties.GetEnumerator()”错误是什么?你想干什么?你能把一个文件放在一起让其他人尝试编译吗?请发布错误。最好是整个堆栈跟踪。什么是错误?你能帮我收集电脑的id吗?。以一个程序的代码为例,但它不能让我获得所有的id,并且在程序中,它引导我是的。
using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
// using (ManagementObjectCollection.ManagementObjectEnumerator enumerator2 = disks.GetEnumerator())
using (PropertyDataCollection.PropertyDataEnumerator enumerator2 = ManagementClass.Properties.GetEnumerator())
{
while (enumerator2.MoveNext())
{
if (enumerator2.Current.Type == CimType.String)
{
flag = true;
}
}
}
PropertyDataCollection.PropertyDataEnumerator enumerator2 = managementClass.Properties.GetEnumerator();
while (enumerator2.MoveNext())
{
if (enumerator2.Current.Type == CimType.String)
{
flag = true;
}
}