Solved

Getting list of HD's on the current computer

Posted on 2001-09-10
3
199 Views
Last Modified: 2010-04-06
I want to create a combo box that allow the user to select a HD from their machine. To do this, I need to know all of the HD's mounted/mapped on their machine. How do I get this list?

Thanks for the help,
chmod101
0
Comment
Question by:chmod101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
DrDelphi earned 75 total points
ID: 6471020
I have a perfect example of this on my website:

http://www.drdelphi.com/delphi/right/tips/diskinfo.htm

Good luck!!
0
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6471478
Here is another example:

To use it just drop a ComboBox on a form and put the following code in theForms OnCreate event:

procedure TForm1.FormCreate(Sender: TObject);
var
  Buff : array[0..110] of Char;
  P : PChar;
  S : string;
begin
  FillChar(Buff, SizeOf(Buff), #0);
  GetLogicalDriveStrings(110, Buff);
  P := Buff;
  while P^ <> #0 do
  begin
    S := string(P);
    P := StrEnd(P) + 1;
    ComboBox1.Items.Add(S);
  end;
  ComboBox1.ItemIndex := 0;
end;

Cheers,

Alan
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6471653
Hello

 The GetDriveType  function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.  

  Add ListBox and button to the form, and in the Button click event added this code, this code will show all the drives in your computer and it's type, if you want only to show the HardDisk, add only on the list the  drvType DRIVE_FIXED

procedure TForm1.Button1Click(Sender: TObject);
var
  x,
  DrvType   : Integer;
  DrvLetter,
  DrvString : String;
begin
  for x := Ord('A') to Ord('Z') do
  begin
    DrvLetter := Chr(x)+':\';
    DrvType := GetDriveType(pChar(DrvLetter));
    case DrvType of
      0,1               : DrvString := '';
      DRIVE_REMOVABLE      : DrvString := 'Removable';
      DRIVE_FIXED     : DrvString := 'Fixed';
      DRIVE_REMOTE     : DrvString := 'Network';
      DRIVE_CDROM     : DrvString := 'CD-ROM';
      DRIVE_RAMDISK     : DrvString := 'RAM disk';
    end;
    if DrvString <> '' then
      Listbox1.Items.Add(DrvLetter + ' = ' + DrvString);
  end;
end;

Best regards
Mohammed Nasman
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question