Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WMI Win32_DiskDrivePhysicalMedia

WMI Win32_DiskDrivePhysicalMedia

Scheduled Pinned Locked Moved C / C++ / MFC
comtutoriallearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dene99970
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • D dene99970

      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.

      P Offline
      P Offline
      ppnht
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups