D
David Lindgren
Hello!
I am using some code to find out the logical harddrive's serial number. The
code I use is the one you see below. By some reason this code takes quite
some time to execute. How come? Is there a faster way to do it?
Thanks for your help.
/David.
SelectQuery query = new SelectQuery("Win32_Logicaldisk");
ManagementObjectSearcher search = new ManagementObjectSearcher(query);
foreach (ManagementObject info in search.Get())
{
object obj = null;
try
{
obj = info["DriveType"] ;
if (obj != null && System.Convert.ToUInt32(obj) != 3)
continue;
obj = info["Volumeserialnumber"];
if (obj != null)
return obj.ToString();
}
catch (System.Exception e)
{
}
}
I am using some code to find out the logical harddrive's serial number. The
code I use is the one you see below. By some reason this code takes quite
some time to execute. How come? Is there a faster way to do it?
Thanks for your help.
/David.
SelectQuery query = new SelectQuery("Win32_Logicaldisk");
ManagementObjectSearcher search = new ManagementObjectSearcher(query);
foreach (ManagementObject info in search.Get())
{
object obj = null;
try
{
obj = info["DriveType"] ;
if (obj != null && System.Convert.ToUInt32(obj) != 3)
continue;
obj = info["Volumeserialnumber"];
if (obj != null)
return obj.ToString();
}
catch (System.Exception e)
{
}
}