Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • 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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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