Solved

Getting list of HD's on the current computer

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

687 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