FileForums

FileForums (https://fileforums.com/index.php)
-   Conversion Tutorials (https://fileforums.com/forumdisplay.php?f=55)
-   -   How to install the directory automatically points to the Max Drive? (https://fileforums.com/showthread.php?t=98337)

JRD! 04-07-2017 15:52

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;


Chayan Manna 04-07-2017 20:08

Quote:

Originally Posted by JRD! (Post 460459)
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;


Thanks.
Will try it. :)


All times are GMT -7. The time now is 23:09.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com