Why does Win32_Logicaldisk accessing take so long time?

  • Thread starter Thread starter David Lindgren
  • Start date Start date
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 guess you are running this on w2k, which has a bug related to floppy drive
not ready handling in WMI.
So I would suggest you try to refine your query to include the drive letter.

Willy.
 
Back
Top