Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Check if removable drive is empty or not

Posted on 1998-03-26
8
Medium Priority
?
242 Views
Last Modified: 2010-04-06
Hi,
I have a jazz drive.
How can i check if it is empty or not ?
It's a removable drive.
Your solution should work, under 95 and NT
Thanks
0
Comment
Question by:jeurk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Expert Comment

by:Socrates050697
ID: 1360911
Never used a Jazz Drive but if it has a drive letter, then can''t you use the same code as I just gave you for a floppy drive, but changing the drive letter - as in :


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


    Socrates
0
 
LVL 1

Expert Comment

by:pjdb
ID: 1360912
I would put it inside a try / except / end just to make sure about exception if there is no drive or is the drive is not formatted (or corrupted).

JDB
0
 
LVL 4

Expert Comment

by:itamar
ID: 1360913
Hi all,

What if the disk is empty (but in the driver) ? I think FileExists will return false.

Perhaps a better solution could be:
Drive := 1  // 0 = Current, 1 = A, 2 = B, etc.
if DiskSize(Drive)>0 then
  begin
    Label1.Caption := '(disk in drive)'
   end
else
   begin
      Label1.Caption := '(no disk in drive or disk not formatted)'
end;

IHTH,
Itamar
0
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!

 
LVL 1

Accepted Solution

by:
pjdb earned 150 total points
ID: 1360914
Same as on the other thread :

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;      {DiskInDrive}

It work with NT and Win 95 without raising some message(s)

JDB
0
 
LVL 4

Expert Comment

by:itamar
ID: 1360915
Hummm,

I see that pjdb took my comment, elaborate it a little and placed as an answer .....
Not a very good conduct....
Let's hear smth from jeurk.

And just another what if...

What if the disk is unformatted. The proposed function (and my comment itself) will give a result of false, what is not absolutely right. The drive is not fisically empty.

Perhaps it is critical to jeurk's usage, so let's hear from him.

Bye,
Itamar
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360916
Like I sayd in the other thread I'll check the things out.
About the unformatted thing, itamar, I does not really matter,
but for sure if you know how to detect if the drive is unformatted
You will earn some points;

Jeurk
0
 
LVL 1

Expert Comment

by:pjdb
ID: 1360917
Sorry itamar to have token your answer but i've post only 2 minutes after you. In fact when i've load the page there was no answer (i was probably seeking my code when you post it). Moreover, your code does not work under NT (it raise an error on floppies).

Jeurk can evaluate know will have points (i wont send any more message on this thread)

JDB



0
 
LVL 4

Author Comment

by:jeurk
ID: 1360918
Hi,
Let's say I'll give those points out, so that we close the thead.
Sorry itamar, but u won't get a point for that question.
What can I say ? It's true that your answer is near of pjdb's,
but it's true that it raises an error under NT.
Don't take it personnel, please.
I you don't like that, let me know and I'll make  a thead just for you
and I'll grant you 50 points too. I don't wan you to be sad about that, ok ?

Jeurk.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 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