View Single Post
  #5  
Old 03-07-2017, 19:56
Chayan Manna's Avatar
Chayan Manna Chayan Manna is offline
Registered User
 
Join Date: Jun 2016
Location: India
Posts: 82
Thanks: 89
Thanked 114 Times in 37 Posts
Chayan Manna is on a distinguished road
Quote:
Originally Posted by JRD! View Post
Code:
#ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif

function GetDriveType(lpRootPathName: string): UINT;
  external 'GetDriveType{#AW}@kernel32.dll stdcall';

function GetMaxFreeSpaceDrive: String;
var
  i: Integer;
  sDriveRoot: string;
  iLastMax, iNewMax, iTotal: Cardinal;
begin
  iLastMax:=0;
  for i := 1 to 26 do
  begin
    sDriveRoot := Chr(i+64)+':';
    if GetDriveType(sDriveRoot) = 3 then
    begin
      GetSpaceOnDisk(sDriveRoot, True, iNewMax, iTotal);
      if iLastMax < iNewMax then
      begin
        iLastMax := iNewMax;
        Result:=sDriveRoot;
      end;
    end;
  end;
end;
Perfect code !!!!!
Thanks !!!!!
Please can you add a function
That's here:
If the max drive is c then the path will be C:/Programfiles/{#Appname}
Otherwise it will be something else like E:/{#Appname}
Thanks
Reply With Quote