NT|D3:check for removable devices without errors ?

Hi,
I'd like to check if there is a disk in A: without trying to destroy the drive (you see what I mean)
A functon that only try to shortly access the drive.
I don't want the msg: no disk in drive , cancel ,ignore ,retry
Any hint ?
If you have an idea under 95 I will be interessed too.
LVL 4
jeurkAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Socrates050697Commented:
use FileExists
e.g

if FileExists('a:\*.*') then
begin
   (disk in drive)
end
else
begin
   (no disk in drive or disk not formatted)
end;

This doesn't bring up the Cancel/Retry/Ignore message box.
I've only tried this in Win95, but I don't see why it wouldn't work under NT.

Socrates
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jeurkAuthor Commented:
I'll check this out befor grading the answer ;)
CU
0
pjdbCommented:
The code raised an error dialog box "No  disk the reader. Please insert a disk in the drive A:" with buttons  "Abort", "Retry" "Ignore" (i've tranlate them from french) under NT 4. However, it work fine for a CD drive.

Sorry :-(

This one work fine with NT

function DiskInDrive(DrvNum:byte):Boolean;
var
  EMode: Word;
begin
  result:=false;
  EMode:=SetErrorMode(SEM_FAILCRITICALERRORS);
  try
    if DiskSize(DrvNum)<>-1 then
          result:=true;
  finally
    SetErrorMode(EMode);
  end;
end;


JDB
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.