View Single Post
  #16  
Old 04-07-2017, 15:52
JRD!'s Avatar
JRD! JRD! is offline
Registered User
 
Join Date: Sep 2015
Location: Matrix
Posts: 274
Thanks: 225
Thanked 600 Times in 168 Posts
JRD! is on a distinguished road
Code:
#define MyAppName "MyApp"
#define MyAppVersion "1.0"

[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={code:GetMaxFreeSpace}\{#MyAppName}

[Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"

[ Code]
#ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif

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

function GetMaxFreeSpace(S: String): 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;
__________________
Practice makes perfect.
Reply With Quote
The Following User Says Thank You to JRD! For This Useful Post:
Chayan Manna (04-07-2017)
Sponsored Links