• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

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.
0
jeurk
Asked:
jeurk
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now