Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:45:06+00:00 2026-06-10T22:45:06+00:00

I already have a long working on an application that can read information from

  • 0

I already have a long working on an application that can read information from Micro, some (most) failed more still missing some, I’m working with WMI and Delphi.
The problem I’m facing is that I need to be listed units which belong to each HD, for example: HD1 has drive C:, D: and so on.

thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:45:08+00:00Added an answer on June 10, 2026 at 10:45 pm

    To correlate the Logical Drives and Physical Disks you must use the Win32_DiskDrive class and the Win32_DiskDriveToDiskPartition, Win32_LogicalDiskToPartition ASSOCIATORS classes.

    Try this sample.

    {$APPTYPE CONSOLE}
    
    uses
      SysUtils,
      ActiveX,
      ComObj,
      Variants;
    
    
    function ListDrives : string;
    var
      FSWbemLocator  : OLEVariant;
      objWMIService  : OLEVariant;
      colDiskDrives  : OLEVariant;
      colLogicalDisks: OLEVariant;
      colPartitions  : OLEVariant;
      objdiskDrive   : OLEVariant;
      objPartition   : OLEVariant;
      objLogicalDisk : OLEVariant;
      oEnumDiskDrive : IEnumvariant;
      oEnumPartition : IEnumvariant;
      oEnumLogical   : IEnumvariant;
      iValue         : LongWord;
      DeviceID       : string;
    begin;
      Result:='';
      FSWbemLocator   := CreateOleObject('WbemScripting.SWbemLocator');
      objWMIService   := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', '', '');
      colDiskDrives   := objWMIService.ExecQuery('SELECT DeviceID FROM Win32_DiskDrive');
      oEnumDiskDrive  := IUnknown(colDiskDrives._NewEnum) as IEnumVariant;
      while oEnumDiskDrive.Next(1, objdiskDrive, iValue) = 0 do
       begin
          Writeln(Format('DeviceID %s',[string(objdiskDrive.DeviceID)]));
          //Escape the `\` chars in the DeviceID value because the '\' is a reserved character in WMI.
          DeviceID        := StringReplace(objdiskDrive.DeviceID,'\','\\',[rfReplaceAll]); 
          //link the Win32_DiskDrive class with the Win32_DiskDriveToDiskPartition class
          colPartitions   := objWMIService.ExecQuery(Format('ASSOCIATORS OF {Win32_DiskDrive.DeviceID="%s"} WHERE AssocClass = Win32_DiskDriveToDiskPartition',[DeviceID]));
          oEnumPartition  := IUnknown(colPartitions._NewEnum) as IEnumVariant;
          while oEnumPartition.Next(1, objPartition, iValue) = 0 do
          begin
           if not VarIsNull(objPartition.DeviceID) then
           begin
            Writeln(Format('   Partition %s',[string(objPartition.DeviceID)]));
            //link the Win32_DiskPartition class with theWin32_LogicalDiskToPartition class.
            colLogicalDisks := objWMIService.ExecQuery('ASSOCIATORS OF {Win32_DiskPartition.DeviceID="'+VarToStr(objPartition.DeviceID)+'"} WHERE AssocClass = Win32_LogicalDiskToPartition'); 
            oEnumLogical  := IUnknown(colLogicalDisks._NewEnum) as IEnumVariant;
              while oEnumLogical.Next(1, objLogicalDisk, iValue) = 0 do
              begin
                  Writeln(Format('     Logical Disk %s',[string(objLogicalDisk.DeviceID)]));
                  objLogicalDisk:=Unassigned;
              end;
           end;
           objPartition:=Unassigned;
          end;
           objdiskDrive:=Unassigned;
       end;
    end;
    
    begin
     try
        CoInitialize(nil);
        try
          ListDrives;
        finally
          CoUninitialize;
        end;
     except
        on E:Exception do
            Writeln(E.Classname, ':', E.Message);
      end;
      Readln;
    end.
    

    This will output something like so

    DeviceID \\.\PHYSICALDRIVE0
       Partition Disk #0, Partition #0
         Logical Disk F:
    DeviceID \\.\PHYSICALDRIVE1
       Partition Disk #1, Partition #0
         Logical Disk C:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I do that? I already have the code I'm working on but
I already have an enterprise Java EE application. I want expose some of the
I am working on an application that involves some gis stuff. There would be
I already have Java code to display and process data from a database. I
I already have an iPhone application (version 1.0) available in the App Store and
I already have an application built in asp.net 3.5 and now I want to
I've been working on an application that has no discernable data access layer, so
I'm writing a Java application that will run for a long time (essentially, it
I used to have a small chat app(which was almost working), that uses PHP,
Long ago I have learned sql and within the last years of application development

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.