如果要运行的exe文件不在光盘上,则终止程序:
if GetDriveType(pchar(ExtractFileDrive(application.ExeName)+':\'))<>DRIVE_CDROM then
application.Terminate;
太简单了 hehe^^
判断应用程序当前启动的盘符是什么类型就可以了!
Function DiskIsCDROM:PChar;
var Drive:Pchar;
i:char;
begin
for i:='A' to 'Z' do
begin
drive:=Pchar(i+':\');
if GetDriveType(Drive)=DRIVE_CDROM then
begin
Result:=drive;
break;
end
else
Result:='0';
end;
end;