大富翁里有,自己去查
判断光驱中是否有盘
function TForm1.diskindriv(Drive:char):boolean;
var
Errormode:word;
begin
{ make it upper case}
if Drive in ['a'..'z'] then
dec(drive,$20);
{make sure it is letter}
if not (drive in ['A'..'Z']) then
raise EconvertError.create('not a valid drive?');
{turn off critical error}
Errormode:=SetErrorMode(SEM_FailCriticalErrors);
try
{drive a=1,b=2,and so on}
if disksize(ord(Drive)-$40)=-1 then
result:=false
else
result:=true;
finally
seterrormode(errormode);
end
-------------------------------------
如何检查软驱中的软盘和光驱的光盘是否发生变化。
方法:
只要检查软驱和光驱中的磁盘的序列号发生变化即可!
function GetDiskVolSerialID(cDriveName : char ) : DWord;
var
dwTemp1,
dwTemp2 : DWord;
begin
GetVolumeInformation(
PChar( cDriveName + ':/' ), // address of root directory of the file system
Nil, // address of name of the volume
0, // length of lpVolumeNameBuffer
@Result, // address of volume serial number
dwTemp1, // address of system's maximum filename length
dwTemp2, // address of file system flags
Nil, // address of name of file system
0 // length of lpFileSystemNameBuffer
);
end;