Hello, it took me a while to figure it out how this class works. Here is a sample in Managed C++:
ManagementObjectCollection ^c = query("Win32\_DiskDrivePhysicalMedia");
for each(ManagementObject ^o in c)
{
DeviceInfo ^device = gcnew DeviceInfo();
ManagementObject ^media = gcnew ManagementObject(o\["Antecedent"\]->ToString());
ManagementObject ^disk = gcnew ManagementObject(o\["Dependent"\]->ToString());
Object ^temp = disk\["Manufacturer"\];
if(temp) device->manufacturer = temp->ToString();
temp = disk\["Model"\];
if(temp) device->model = temp->ToString();
temp = media\["SerialNumber"\];
if(temp) device->serial = temp->ToString();
list\_->Add(device);
}
The class Win32_DiskDrivePhysicalMedia only contains references to the Physical Media and Disk Drive objects. You must, then, instatiate both objects to access their properties individually. Regards, Paulo