How to get hard disk serials?

i used this code to get hard disk serials:
private void getSeriaHardDisk()
{
string lsSerial="";

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");

int i = 0;
foreach(ManagementObject wmi_HD in searcher.Get())
{
if (wmi_HD["SerialNumber"] == null)
lsSerial = "None";
else
lsSerial = wmi_HD["SerialNumber"].ToString().Trim();
++i;
}
}
it runs normally on winxp sp1 but error on winxp sp2 and window2000.can you help me?

[541 byte] By [namnguyen] at [2007-12-16]
# 1
I ran this code on Windows XP Pro SP2 just fine. The question is, where are you executing this code? Are you executing it from a network share or in another local other than from off of one of your local disk drives? I don't know this for sure, but I would imagine these classes need reflection permission and/or unmanaged code execution permission. If you are executing from a network share or something of that nature, you are sure to have your permission set limited.

What exception are you getting?

TobinTitus at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...