Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

List of CD-ROM Drives

Posted on 2003-02-18
1
Medium Priority
?
202 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
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

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

569 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