发信人: CF (随风漂), 信区: BorlandDev
标 题: Diskette In disk drive?
发信站: 哈工大紫丁香 (2002年12月29日21:47:03 星期天), 站内信件
This Delphi Tip checks to see if there is a disk in the disk drive,
first this function sets the errors off so that we don't receive an
error like: "Disk not ready.". Then the function checks the size of
the disk, if this is -1 then the function will result false, and the
disk is not ready.
Code:
function DiskInDrive(Drive: Char): Boolean;
var
ErrorMode: word;
begin
{ make it upper case }
if Drive in ['a'..'z'] then Dec(Drive, $20);
{ make sure it's a letter }
if not (Drive in ['A'..'Z']) then
raise EConvertError.Create('Not a valid drive ID');
{ turn off critical errors }
ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
try
{ drive 1 = a, 2 = b, 3 = c, etc. }
if DiskSize(Ord(Drive) - $40) = -1 then
Result := False
else
Result := True;
finally
{ restore old error mode }
SetErrorMode(ErrorMode);
end;
end;
This source code is written by Robert Jones.
--
再不学习,你就要......
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 218.10.130.13]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.550毫秒