有些机器下读取不到硬盘序列号,请教高手怎么写能在xp、windows server2003、windows7下都可以读取到硬盘序列号,
现在在有些xp下读取不到,在windows server2003下读取不到,读取到的都是空的。 Key = "Win32_PhysicalMedia";
String HDid;
ManagementClass cimobject = new ManagementClass(Key);
ManagementObjectCollection moc = cimobject.GetInstances();
foreach (ManagementObject mo in moc)
{
foreach (PropertyData PC in mo.Properties)
{
string temp1 = PC.Value as string;
if (!string.IsNullOrEmpty(temp1))
{
temp1 = temp1.Trim();
Console.WriteLine("name:[" + PC.Name + "] value:[" + temp1+ "] value len:" + temp1.Length.ToString());
}
}
}
现在在有些xp下读取不到,在windows server2003下读取不到,读取到的都是空的。 Key = "Win32_PhysicalMedia";
String HDid;
ManagementClass cimobject = new ManagementClass(Key);
ManagementObjectCollection moc = cimobject.GetInstances();
foreach (ManagementObject mo in moc)
{
foreach (PropertyData PC in mo.Properties)
{
string temp1 = PC.Value as string;
if (!string.IsNullOrEmpty(temp1))
{
temp1 = temp1.Trim();
Console.WriteLine("name:[" + PC.Name + "] value:[" + temp1+ "] value len:" + temp1.Length.ToString());
}
}
}
这到底是谁的问题呢?
"在同一机器上的xp系统下,用C++能获取到硬盘序列号,用C#获取的值确是空的
这到底是谁的问题呢?"
-----------------------------------------
能把两种代码都贴出来吗?