procedure TForm1.Button1Click(Sender: TObject); var btWorkDrive: Byte; DiskFreeSize: Int64; begin //硬碟空間不夠,小於5m則跳出不存囉 btWorkDrive := Ord(UpperCase('C:\test\')[1])-64; //g_sTempPath DiskFreeSize := DiskFree(btWorkDrive); if (DiskFreeSize<>-1) and ((DiskFreeSize div (1024*1024)){MB}<40) then Exit; end;