我正在使用 Inno Setup 创建一个安装程序,我的问题是:
如何添加自定义文本标签,例如:“当前驱动器中的空间:XXX Mb”以及该向导页面上所需的空间数量:
如果你能帮助我,那就太好了。 :)
GetSpaceOnDisk64
查询可用磁盘空间:
var
FreeDiskSpaceLabel: TNewStaticText;
procedure UpdateDiskSpaceLabel;
var
Path, Path2: string;
Free, Total: Int64;
FreeGB: Extended;
S: string;
begin
Path := WizardDirValue;
// Installation path will be typically absent,
// so find the first parent path that really exists
while not DirExists(Path) do
begin
Path2 := RemoveBackslash(ExtractFilePath(RemoveBackslash(Path)));
if (Path2 = '') or (Path2 = Path) then break;
Path := Path2;
end;
if GetSpaceOnDisk64(Path, Free, Total) then
begin
FreeGB := Extended(Free) / (1024*1024*1024);
S := Format('There is %.1n GB free space on selected drive.', [FreeGB]);
end
else
begin
S := 'Error querying free space on selected drive';
end;
FreeDiskSpaceLabel.Caption := S;
end;
procedure DirEditChange(Sender: TObject);
begin
UpdateDiskSpaceLabel;
end;
procedure InitializeWizard();
begin
FreeDiskSpaceLabel := TNewStaticText.Create(WizardForm);
FreeDiskSpaceLabel.Parent := WizardForm.DiskSpaceLabel.Parent;
FreeDiskSpaceLabel.Top :=
WizardForm.DiskSpaceLabel.Top - WizardForm.DiskSpaceLabel.Height -
ScaleY(8);
FreeDiskSpaceLabel.Left := WizardForm.DiskSpaceLabel.Left;
WizardForm.DirEdit.OnChange := @DirEditChange;
// Update for default/previous path
UpdateDiskSpaceLabel;
end;