Solved

Getting list of HD's on the current computer

Posted on 2001-09-10
3
197 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
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dev Express grid collapse 2 45
Delphi: ForceDirectory plain function 7 31
Performance of SQL statement 37 111
Graphics32 under Delphi 10.1 Berlin 2 66
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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