给分吧!<br>1.检测CD-ROM或是其他磁盘是否有过变化。 <br> 最简单的检查CD-ROM或是磁盘是否有过变化的方法是检查其volume号码。你可以简单地运用下面的函数来返回磁盘的volume系列号码GetDiskVolSerialID(′E′),函数代码如下:<br> functionGetDiskVolSerialID(cDriveName:char):DWord;<br> var<br> dwTemp1,dwTemp2:DWord;<br> begin<br> GetVolumeInformation(PChar(cDriveName+′:ι′),<br> Nil,<br> 0,<br> ΝResult,<br> dwTemp2,<br> dwTemp2,<br> Nil,0);<br> end;<br> <br>2.检测驱动器类型 <br>当要知道所选的驱动器属于什么类型时,请看下面的程序<br>var x:integer;<br>driver
char;<br>begin<br>driver:='f:/';<br>x := GetDriveType(driver);<br>Case x of<br>2: Label1.Caption := '该驱动器是可移动驱动器';<br>3: Label1.Caption := '该驱动器是固定驱动器';<br>4: Label1.Caption := '该驱动器是网络驱动器';<br>5: Label1.Caption := '该驱动器是CD-ROM驱动器';<br>6: Label1.Caption := '该驱动器是虚拟驱动器';<br>Else Label1.Caption := '该驱动器无效';<br>End;<br>end;<br><br>3.驱动器容量 <br>要得到驱动器的容量和剩余容量,用下面的程序<br>var<br>driver
char;<br>sec1, byt1, cl1, cl2:longword;<br>begin<br>driver:='c:/';//要显示的驱动器名<br>GetDiskFreeSpace(driver, sec1, byt1, cl1, cl2);<br>cl1 := cl1 * sec1 * byt1;<br>cl2 := cl2 * sec1 * byt1;<br>Label1.Caption := '该驱动器总共容量' + Formatfloat('###,##0',cl2) + '字节';<br>Label2.Caption := '该驱动器可用容量' + Formatfloat('###,##0',cl1) + '字节';<br>end;<br><br>4.检查驱动器是否就绪: <br>下面这个函数可以显示是否就绪。(From Borland)<br><br>function DiskInDrive(Drive: Char): Boolean;<br>var ErrorMode: word;<br>begin<br>{ make it upper case }<br>if Drive in ['a'..'z'] then Dec(Drive, $20);<br>{ make sure it's a letter }<br>if not (Drive in ['A'..'Z']) then<br>raise EConvertError.Create('Not a valid drive ID');<br>{ turn off critical errors }<br>ErrorMode := SetErrorMode(SEM_FailCriticalErrors);<br>try<br>{ drive 1 = a, 2 = b, 3 = c, etc. }<br>if DiskSize(Ord(Drive) - $40) = -1 then<br>Result := False<br>else<br>Result := True;<br>finally<br>{ restore old error mode }<br>SetErrorMode(ErrorMode);<br>end;<br>end;