[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Getting list of HD's on the current computer

Posted on 2001-09-10
3
Medium Priority
?
204 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 225 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

656 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