杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2579|回复: 0

安装空间不足屏蔽下一步按钮

[复制链接]
发表于 2017-3-6 18:46:13 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. ; 脚本用 Inno Setup 脚本向导 生成。
  2. ; 查阅文档获取创建 INNO SETUP 脚本文件的详细资料!

  3. #define MyAppName "我的程序"
  4. #define MyAppVersion "1.5"
  5. #define MyAppPublisher "我的公司"
  6. #define MyAppURL "http://www.example.com/"
  7. #define MyAppExeName "MyProg.exe"

  8. #define NeedSize "60000"
  9. #define AfterSize "5871"
  10. #define NeedMem "512"
  11. #define Color "000000"



  12. [Setup]
  13. ; 注意: AppId 的值是唯一识别这个程序的标志。
  14. ; 不要在其他程序中使用相同的 AppId 值。
  15. ; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
  16. AppId={{86EB5FFA-D719-4B91-AD87-25AAFCEE7B3F}
  17. AppName={#MyAppName}
  18. AppVersion={#MyAppVersion}
  19. ;AppVerName={#MyAppName} {#MyAppVersion}
  20. AppPublisher={#MyAppPublisher}
  21. AppPublisherURL={#MyAppURL}
  22. AppSupportURL={#MyAppURL}
  23. AppUpdatesURL={#MyAppURL}
  24. DefaultDirName={pf}{#MyAppName}
  25. DefaultGroupName={#MyAppName}
  26. OutputBaseFilename=setup
  27. Compression=lzma
  28. SolidCompression=yes

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

  31. [Tasks]
  32. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

  33. [Files]
  34. Source: "D:Program FilesInno Setup 5ExamplesMyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
  35. ; 注意: 不要在任何共享的系统文件使用 "Flags: ignoreversion"

  36. [Icons]
  37. Name: "{group}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"
  38. Name: "{commondesktop}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: desktopicon

  39. [Run]
  40. Filename: "{app}{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

  41. [CustomMessages]
  42. FreeSpace=剩余空间
  43. NeedSpace=安装所需
  44. AfterInstallSpace=当前分区可用空间
  45. TotalSpace=当前分区总容量


  46. [code]
  47. var
  48. NeedSpaceLabel, FreeSpaceLabel,TotalSpaceLabel,DirEditLabel: TLabel;
  49.   FreeMB, TotalMB: Cardinal;
  50.   SizeInt, AfterInt: Longint;

  51. //procedure DirChange(Sender: TObject);
  52. //var
  53. // CurrentDisk: String;
  54. //begin
  55. //CurrentDisk:=ExtractFileDrive(WizardForm.DirEdit.Text);
  56. //  DirEditLabel.Caption:=MinimizePathName(WizardForm.DirEdit.Text, DirEditLabel.Font, DirEditLabel.Width);
  57. //end;

  58. Function NumToStr(Float: Extended): String;
  59. Begin
  60.   Result:= Format('%.2n', [Float]); StringChange(Result, ',', ',');
  61.   while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = ',')) and (Pos(',', Result) > 0) do
  62.   SetLength(Result, Length(Result)-1);
  63. End;

  64. function CompareNum(FirstNum, SecondNum: Integer): Boolean;
  65. begin
  66. if FirstNum < SecondNum then Result:= False else Result:= True;
  67. end;

  68. Function MbOrTb(Byte: Extended): String;
  69. begin
  70. if Byte < 1024 then Result:= NumToStr(Byte) + 'TB' else
  71.   if Byte/1024 < 1024 then Result:= NumToStr(round(Byte/1024*100)/100) + ' GB' else
  72.      Result:= NumToStr(round((Byte/(1024*1024))*100)/100) + ' MB'
  73. end;

  74. procedure DirEditOnChange(Sender: TObject);
  75. var Drive: String;
  76. begin
  77. // DirEditLabel.Caption:=MinimizePathName(WizardForm.DirEdit.Text, DirEditLabel.Font, DirEditLabel.Width);
  78.   Drive:= ExtractFileDrive(WizardForm.DirEdit.Text);
  79.   GetSpaceOnDisk(Drive, True, FreeMB, TotalMB);
  80.     TotalSpaceLabel.Caption:= ExpandConstant('{cm:TotalSpace} ')+MbOrTb(TotalMB);
  81.     FreeSpaceLabel.Caption:= ExpandConstant('{cm:FreeSpace} ') + MbOrTB(FreeMb) + ' (' + IntToStr((FreeMb*100) div TotalMB) + ' %)';
  82.     NeedSpaceLabel.Caption := ExpandConstant('{cm:NeedSpace} ') + MbOrTb(SizeInt)
  83.     if (FreeMB>{#NeedSize}) then FreeSpaceLabel.Font.Color:=${#Color} else FreeSpaceLabel.Font.Color:=$0000FF;
  84. //if WizardForm.CurPageID = wpSelectDir then begin
  85. //if  (FreeMB>{#NeedSize}) then begin
  86.   WizardForm.NextButton.Enabled:= (FreeMB>{#NeedSize});
  87.   //BtnSetEnabled(hNextBtn, True);
  88. //  WizardForm.NextButton.Enabled:=True;
  89. //end else begin
  90. //  WizardForm.NextButton.Enabled:= (FreeMB>{#NeedSize});
  91.   //BtnSetEnabled(hNextBtn, False);
  92. //    WizardForm.NextButton.Enabled:=False;
  93. //end;
  94. //end;
  95. end;

  96. procedure CurPageChanged(CurPageID: Integer);
  97. begin
  98.   if WizardForm.CurPageID = wpSelectDir then
  99.     WizardForm.NextButton.Enabled:= (FreeMB>{#NeedSize});
  100. end;


  101. procedure NeedSpace;
  102. begin
  103. WizardForm.DiskSpaceLabel.Hide;
  104. AfterInt:= {#AfterSize}
  105. SizeInt:= {#NeedSize}

  106. TotalSpaceLabel:= TLabel.Create(WizardForm);
  107. TotalSpaceLabel.Transparent:=true;
  108. TotalSpaceLabel.Font.Name:='Arial';
  109. TotalSpaceLabel.Font.Size:= 10;
  110. TotalSpaceLabel.Font.Color:=${#Color};
  111. //TotalSpaceLabel.SetBounds(ScaleX(253),ScaleY(260), ScaleX(209), ScaleY(13));
  112. TotalSpaceLabel.SetBounds(ScaleX(0),ScaleY(159), ScaleX(209), ScaleY(13));
  113. TotalSpaceLabel.Parent:= WizardForm.SelectDirPage;
  114. //TotalSpaceLabel.Parent:= WizardForm;
  115. TotalSpaceLabel.Font.Style := [fsBold];

  116. FreeSpaceLabel := TLabel.Create(WizardForm);
  117. //FreeSpaceLabel.SetBounds(ScaleX(253), ScaleY(276), ScaleX(209), ScaleY(13))
  118. FreeSpaceLabel.SetBounds(ScaleX(0), ScaleY(179), ScaleX(209), ScaleY(13))
  119. //FreeSpaceLabel.Parent := WizardForm;
  120. FreeSpaceLabel.Parent:= WizardForm.SelectDirPage;
  121. FreeSpaceLabel.Font.Name:='Arial';
  122. FreeSpaceLabel.Font.Size:= 10;
  123. FreeSpaceLabel.Font.Color:=${#Color};
  124. FreeSpaceLabel.Transparent:=true;
  125. FreeSpaceLabel.Font.Style := [fsBold];

  126. NeedSpaceLabel := TLabel.Create(WizardForm);
  127. //NeedSpaceLabel.SetBounds(ScaleX(253), ScaleY(292), ScaleX(209), ScaleY(13))
  128. NeedSpaceLabel.SetBounds(ScaleX(0), ScaleY(199), ScaleX(209), ScaleY(13))
  129. //NeedSpaceLabel.Parent := WizardForm;
  130. NeedSpaceLabel.Parent:= WizardForm.SelectDirPage;
  131. NeedSpaceLabel.Font.Name:='Arial';
  132. NeedSpaceLabel.Font.Size:= 10;
  133. NeedSpaceLabel.Font.Color:=${#Color};
  134. NeedSpaceLabel.Transparent:=true;
  135. NeedSpaceLabel.Font.Style:= [fsBold];

  136. WizardForm.DirEdit.OnChange:= @DirEditOnChange;
  137. WizardForm.DirEdit.Text:= WizardForm.DirEdit.Text + #0;
  138. end;

  139. procedure InitializeWizard();
  140. begin
  141.     NeedSpace;
  142. end;
复制代码
48_377_37226a63aa28fcb.gif
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-7 16:06 , Processed in 0.111365 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表