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

  • SEARCH
  • Home
  • 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 6940291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:44:00+00:00 2026-05-27T12:44:00+00:00

Further to this question and this one that I asked more recently but without

  • 0

Further to this question and this one that I asked more recently but without the correct specifics…and lastly this one that I asked at the Free Pascal forum specifically….

Can anyone provide me with guidance, examples or a link to something somewhere that explains how to call a list of the physically attached hard disks using Free Pascal, or, failing that, Delphi, regardless of whether the disks have been mounted by the operating system or not? An example is shown in the screenshot of what I am trying to achive (what is shown in this screenshot is by another software product). So pulling a list of logical volumes (C:\, E:\ etc) is not what I am trying to do. And if the disk has a filesystem that the operating system cannot mount, I still want to see the physical disk listed.

I stress that C\C++\C Sharp examples are plentifull but not what I am after. I need primarily Free Pascal example, or, failing that, Delphi.

enter image description here

  • 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-05-27T12:44:01+00:00Added an answer on May 27, 2026 at 12:44 pm

    Try the Win32_DiskDrive WMI class, check this sample code

    {$mode objfpc}{$H+}
    uses
      SysUtils,ActiveX,ComObj,Variants;
    {$R *.res}
    
    // The Win32_DiskDrive class represents a physical disk drive as seen by a computer running the Win32 operating system. Any interface to a Win32 physical disk drive is a descendent (or member) of this class. The features of the disk drive seen through this object correspond to the logical and management characteristics of the drive. In some cases, this may not reflect the actual physical characteristics of the device. Any object based on another logical device would not be a member of this class.
    // Example: IDE Fixed Disk.
    
    procedure  GetWin32_DiskDriveInfo;
    const
      WbemUser            ='';
      WbemPassword        ='';
      WbemComputer        ='localhost';
      wbemFlagForwardOnly = $00000020;
    var
      FSWbemLocator : OLEVariant;
      FWMIService   : OLEVariant;
      FWbemObjectSet: OLEVariant;
      FWbemObject   : Variant;
      oEnum         : IEnumvariant;
      sValue        : string;
    begin;
      FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
      FWMIService   := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
      FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_DiskDrive','WQL',wbemFlagForwardOnly);
      oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
      while oEnum.Next(1, FWbemObject, nil) = 0 do
      begin
        sValue:= FWbemObject.Properties_.Item('Caption').Value;
        Writeln(Format('Caption        %s',[sValue]));// String
        sValue:= FWbemObject.Properties_.Item('DeviceID').Value;
        Writeln(Format('DeviceID       %s',[sValue]));// String
        sValue:= FWbemObject.Properties_.Item('Model').Value;
        Writeln(Format('Model          %s',[sValue]));// String
        sValue:= FWbemObject.Properties_.Item('Partitions').Value;
        Writeln(Format('Partitions     %s',[sValue]));// Uint32
        sValue:= FWbemObject.Properties_.Item('PNPDeviceID').Value;
        Writeln(Format('PNPDeviceID    %s',[sValue]));// String
        sValue:= FormatFloat('#,', FWbemObject.Properties_.Item('Size').Value / (1024*1024));
        Writeln(Format('Size           %s mb',[sValue]));// Uint64
    
        Writeln;
        FWbemObject:= Unassigned;
      end;
    end;
    
    begin
      try
        GetWin32_DiskDriveInfo;
      except
        on E:EOleException do
            Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
        on E:Exception do
            Writeln(E.Classname, ':', E.Message);
      end;
      Writeln('Press Enter to exit');
      Readln;
    end.    
    

    After of running this code you will get a output like this

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked a question similar to this one a couple of weeks ago, but
I was recently asked this question in one of my telephonic interview. There is
I know that this question is being asked before but I did not get
I guess this question that would have already been asked here. I searched but
This question follows on from a previous question, that has raised a further issue.
I re-asked this question here because the people at ServerFault deemed that this is
I am taking a prior question one step further (see this question ), I
Further to this question: Algorithm for determining a file’s identity Recap : I'm looking
N.B THIS QUESTION HAS BEEN UPDATED, READ FURTHER DOWN Hi, I want to create
since I couldn't find an answer to this question I researched a bit further

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.