Board index » delphi » Drive ready / Disk in drive - How?

Drive ready / Disk in drive - How?

Using Delphi 1 and Windows for Workgroups, how can I find out if there
is a CD in the CD-Rom drive?

All help gratfully received.....!

TIA

Dennis....

 

Re:Drive ready / Disk in drive - How?


You would have to mimic all of what M$ did to do what 95 does. Your app
would always have to be active to catch when the drive was closed.

Dennis Hartley <denn...@liv.ac.uk> wrote in article
<3398330c.2708...@news.liv.ac.uk>...

Quote
> Using Delphi 1 and Windows for Workgroups, how can I find out if there
> is a CD in the CD-Rom drive?

> All help gratfully received.....!

> TIA

> Dennis....

Re:Drive ready / Disk in drive - How?


Or you could try this function:

function DiskExists(Drive: Char): Boolean;
var
ErrorMode: Word;
begin
Drive := UpCase(Drive);
{ Make sure drive is a valid letter }
if not (Drive in ['A'..'Z']) then
raise EConvertError.Create('Not a valid drive letter');
{ Turn off critical errors }
ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
try
Application.ProcessMessages;
Result := (DiskSize(Ord(Drive) - Ord('A') + 1) <> -1);
finally
{ Restore the old error mode }
SetErrorMode(ErrorMode);
Application.ProcessMessages;
end;
end;

--
David S. Becker
ADP Dealer Services (Plaza R&D)
d...@plaza.ds.adp.com
(503)402-3236
 marone wrote in article <01bc76ed$a675dc80$7e52f0c7@marone>...

Quote
>You would have to mimic all of what M$ did to do what 95 does. Your app
>would always have to be active to catch when the drive was closed.

>Dennis Hartley <denn...@liv.ac.uk> wrote in article
><3398330c.2708...@news.liv.ac.uk>...
>> Using Delphi 1 and Windows for Workgroups, how can I find out if there
>> is a CD in the CD-Rom drive?

>> All help gratfully received.....!

>> TIA

>> Dennis....

Other Threads