For now I have worked around this by creating a function:
function GetDirSize(const DirName: string): Int64;
var
FindRec: TFindRec;
FilePath: string;
Size: Int64;
begin
result := 0;
if FindFirst(AddBackslash(DirName) + '*', FindRec) then
try
repeat
if (FindRec.Name <> '.') and (FindRec.Name <> '..') then
begin
FilePath := AddBackslash(DirName) + FindRec.Name;
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then
Size := GetDirSize(FilePath)
else
Size := (Int64(FindRec.SizeHigh) shl 32) + FindRec.SizeLow;
result := result + Size;
end;
until not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end;
I use this in CurStepChanged at ssPostInstall time:
procedure CurStepChanged(CurStep: TSetupStep);
var
Size: Int64;
RootKey: Integer;
SubKeyName: string;
begin
if CurStep = ssPostInstall then
begin
Size := GetDirSize(ExpandConstant('{app}'));
if Size > 0 then
begin
Size := Round(Size / 1024);
if IsAdminInstallMode() then
RootKey := HKLM
else
RootKey := HKCU;
SubKeyName := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#AppID}_is1';
RegWriteDWORDValue(RootKey, SubKeyName, 'EstimatedSize', Size);
end;
end;
end;
It would be "nice to have" if I didn't have to do the extra steps.