Solved

Getting list of HD's on the current computer

Posted on 2001-09-10
3
195 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:mnasman
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now