function to verify if a drive exists 
Author Message
 function to verify if a drive exists

Help,

Is there a function in Pascal that will check to see if a drive exists?
I've tried just using the exec function and running a dos command using
the exist variable but there is no way that the program will know that
the drive actually exists.

Please help, THANKS IN ADVANCE!!



Wed, 18 Jun 1902 08:00:00 GMT  
 function to verify if a drive exists

Quote:

>Help,

>Is there a function in pascal that will check to see if a drive exists?
>I've tried just using the exec function and running a dos command using
>the exist variable but there is no way that the program will know that
>the drive actually exists.

Function ValidDrive(C:char):Boolean;
var rg:registers;
    FCB_buff:array[0..37] of byte;
    valid:boolean;
    path:string[3];
Begin
   path:=c+':'+#0;
   rg.ax:=$2900;
   rg.si:=ofs(path[1]);
   rg.ds:=sseg;
   rg.es:=sseg;
   rg.di:=ofs(fcb_buff);
   MsDos(rg);
   Valid:=rg.al<>255;
   if ((upcase(c)='B') and valid) then
       valid:=mem[Seg0040:$10] and (3 shl 6)<>0;
   ValidDrive:=valid;
End;

This just tells if the drive exists, not if it is readable (like if a
floppy is inserted to it). Note the function causes no disk access. Note
that drive B is reported as invalid if there is just one floppy. I
prefer not to get the "insert disk in drive B' messages.

The following tells if the drive is removable.

Function Removable(C:char):Boolean;
var rg:registers;
Begin
   rg.ax:=$4408;
   rg.bl:=Ord(upcase(c))-64;
   MsDos(rg);
   Removable:=(rg.flags and fcarry>0) or (rg.ax=0);
End;

The latter works only on DOS 3.0+

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 function to verify if a drive exists


Quote:
> Help,

> Is there a function in pascal that will check to see if a drive
exists?
> I've tried just using the exec function and running a dos command
using
> the exist variable but there is no way that the program will know that
> the drive actually exists.

> Please help, THANKS IN ADVANCE!!

I know of a simple way, the problem is it pauses to ask you to insert a
drive if you check drives A or B:

...
uses DOS;
...

function DriveExists(drivenumber:byte):boolean;
begin
     DriveExists:=DiskSize(drivenumber)<>-1;
end;

drivenumber corresponds to the drive letter, eg. drive A=1, B=2, etc. I
use this most of the time, but I think I'll use the other method using
interrupts instead!

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to get the names of existing drives in TP

2. CHKDSK, Win NT, and DOS Int21 Function 1Ch Get Drive Data

3. Turbo Pascal 5.5 Large Drive Function/Procedure

4. How to append fields to existing tables, without damageing the existing data

5. **** How to verify and show if a file exist? ****

6. Relation logical drive - physical drive

7. Verify Memory Leak in VCL

8. Pascal program to verify all files in HD-DISK and CD-ROM

9. Somerone, Please help me to verify a abstract data type program

10. Modem hangup and connection verify

11. Help to verify valid source

12. Login Verify/Checker (??)

 

 
Powered by phpBB® Forum Software