星期二, 9月 18, 2012

判斷磁碟空間是否小於40M

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;