Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Valid disk in drive A: ?
This article has not been rated yet. After reading, feel free to leave comments and rate it.
This function returns whether a drive's state = whether it contains
- no disk
- an unformatted disk
- an empty disk
- a disk with files
 | |  | | type
TDriveState = (DSNODISK, DSUNFORMATTEDDISK, DSEMPTYDISK, DSDISK_WITHFILES);
function DriveState (driveletter: Char) : TDriveState;
var
mask: String[6];
sRec: TSearchRec;
oldMode: Cardinal;
retcode: Integer;
begin
oldMode: = SetErrorMode(SEM_FAILCRITICALERRORS);
mask:= '?:\*.*';
mask[1] := driveletter;
retcode := FindFirst (mask, faAnyfile, SRec);
FindClose(SRec);
case retcode of
0: Result := DSDISK_WITHFILES;
-18: Result := DSEMPTYDISK;
-21, -3: Result := DSNODISK;
else
Result := DSUNFORMATTEDDISK;
end;
SetErrorMode(oldMode);
end;
| |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|