WMI Win32_DiskDrivePhysicalMedia
-
Based on articles from this site: http://www.codeproject.com/system/UsingWMI.asp http://www.codeproject.com/system/Using\_WMI\_in\_Visual\_C\_\_.asp I've learned how to get information from a Win32_* class. First step: Service->ExecQuery(L"WQL", L"SELECT * FROM Win32_BaseBoard",WBEM_FLAG_FORWARD_ONLY,NULL, &enumerator); And later second step: obj->Get(L"SerialNumber", 0, &var, 0, 0); However, I don't know how to do it from class Win32_DiskDrivePhysicalMedia. The first step works of course, but I'm not sure how to specify the Antecedent or Dependent. I tried this: hf = obj->Get(L"Antecedent.SerialNumber", 0, &var, 0, 0); But it doesn't work.
-
Based on articles from this site: http://www.codeproject.com/system/UsingWMI.asp http://www.codeproject.com/system/Using\_WMI\_in\_Visual\_C\_\_.asp I've learned how to get information from a Win32_* class. First step: Service->ExecQuery(L"WQL", L"SELECT * FROM Win32_BaseBoard",WBEM_FLAG_FORWARD_ONLY,NULL, &enumerator); And later second step: obj->Get(L"SerialNumber", 0, &var, 0, 0); However, I don't know how to do it from class Win32_DiskDrivePhysicalMedia. The first step works of course, but I'm not sure how to specify the Antecedent or Dependent. I tried this: hf = obj->Get(L"Antecedent.SerialNumber", 0, &var, 0, 0); But it doesn't work.
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