?
Solved

List of CD-ROM Drives

Posted on 2003-02-18
1
Medium Priority
?
201 Views
Last Modified: 2010-04-04
I need some sample Delphi 5 source code that will:

1)  Fill an array of characters with all valid CD-ROM drives

2)  Starting with the lowest drive letter, go to a specified file location and determine if the file is actually there.

3)  If it is there, copy the file to another location specified by the user.

4)  If it is not there, pull up a "Find File" dialog to allow the end-user to find the file themselves.
0
Comment
Question by:Tom Knowlton
[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
1 Comment
 
LVL 21

Accepted Solution

by:
ziolko earned 400 total points
ID: 7979806
procedure TForm1.Button2Click(Sender: TObject);
var msg: string;
begin
  case GetDriveType(PChar(ComboBox1.Text)) of
    0:                  msg:='The drive type cannot be determined.';
    1:                     msg:='The root directory does not exist.';
    DRIVE_REMOVABLE:     msg:='The drive can be removed from the drive.';
    DRIVE_FIXED:     msg:='The disk cannot be removed from the drive.';
    DRIVE_REMOTE:     msg:='The drive is a remote (network) drive.'+#13#10+GetUNC(ComboBox1.Text);
    DRIVE_CDROM:     msg:='The drive is a CD-ROM drive.';
    DRIVE_RAMDISK:     msg:='The drive is a RAM disk.';
  end;
  ShowMessage(msg);
end;

ComboBox1 is filled with drive letters: a:; \c:\; d:\; e:\

if You want list of drive letters:
procedure TForm1.Button1Click(Sender: TObject);
var buff: array[0..MAX_PATH] of Char;
    cnt, lp: Integer;
begin
  combobox1.Items.Clear;
  lp:=0;
  GetLogicalDriveStrings(MAX_PATH,@buff);
  for cnt:=0 to MAX_PATH - 1 do
    if (Ord(buff[cnt]) = 0) then
      begin
        if (Ord(buff[cnt+1]) = 0) then
          begin
            combobox1.Items.Add(Copy(buff,lp,cnt));
            Break;
          end
        else
          begin
            combobox1.Items.Add(Copy(buff,lp,cnt));
            lp:=cnt+2;
            buff[cnt]:=',';
          end;
      end;
end;

ziolko.
0

Featured Post

Technology Partners: 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
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 …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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