views:

38

answers:

1

I'm detecting the insertion of memory cards (removable media). Can I get information about the inserted media - type, manufacturer, etc?

+1  A: 

You ought to be able to use WMI to query the Win32_PhysicalMedia type and get the information you want.

Here is a basic code example of how to do a general query on the class:

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

foreach (ManagementObject wmiObject in searcher.Get())
{
    if (wmiObject["Manufacturer"] == null)
        Console.WriteLine("Unknown");
    else
        Console.WriteLine(wmiObject["Manufacturer"].ToString());
}
Nick
Thanks Nick, I know how to use WMI in .NET :) Unfortunately, the class didn't expose any information regarding the memory card.
Sphynx
@John - What about Win32_PhysicalMemory?
Nick