Forum > Beginners

Diskfree prevent message for cardreader

<< < (2/2)

AlexTP:
SysUtils does not have GetDiskFreeSpace* !
The CudaText editor uses this code


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function AppDiskGetFreeSpace(const fn: string): Int64;begin  {$ifdef linux}  //this crashes on FreeBSD 12 x64  exit(SysUtils.DiskFree(SysUtils.AddDisk(ExtractFileDir(fn))));  {$endif}   {$ifdef windows}  exit(SysUtils.DiskFree(SysUtils.GetDriveIDFromLetter(ExtractFileDrive(fn))));  {$endif}   //cannot detect  exit(-1);end; 

engkin:
1-This message is from the driver.
2-GetDiskFreeSpaceExA or GetDiskFreeSpaceA are in unit Windows. They both will give the same message due to 1
3-SysUtils.DiskFree will not help because it uses 2 as well

You should check the type of the drive first, and ignore it if it's removable.

GetDriveTypeA

jamie:
This works in windows to get the drive letter names .

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);Var  P:String;  S,I:Integer;  L:TStringList;begin  Memo1.Clear;  S := GetLogicalDriveStrings(0,nil); //Get required character count;  If S <> 0 then   Begin     SetLength(P,S+1);     GetLogicalDriveStrings(S,PChar(P));     L := TStringList.Create;     L.Delimiter :=#0;     L.DelimitedText := P;     Memo1.Lines.Assign(L);     L.Free;   end;end;                                

Navigation

[0] Message Index

[*] Previous page

Go to full version