inno-setup - Inno Setup - 如何在安装之前/期间检查系统规范?

标签 inno-setup ram minimum-requirements

特别是,我想检查 PC 上安装的 RAM 量。如果它小于 1GB,我想在安装之前/期间显示一条警告消息......

最佳答案

我会亲自在安装开始时进行此检查,以免让用户通过安装向导感到失望。为此,我将在向导实际显示为它在以下脚本中使用之前显示警告。当内存低于机器上检测到的 1073,741.824 B (1GB) 物理内存时,它应该警告用户。如果用户不同意警告,则设置终止;如果实际物理内存超过上述数量或用户接受警告,则设置过程将继续:

[Code]
type
  { the following mapping of the DWORDLONG data type is wrong; }
  { the correct type is a 64-bit unsigned integer which is not }
  { available in InnoSetup Pascal Script at this time, so max. }
  { values of the following fields will be limited to quite a }
  { big reserve of 8589,934.592 GB of RAM; I hope enough for }
  { the next versions of Windows :-) }
  DWORDLONG = Int64;
  TMemoryStatusEx = record
    dwLength: DWORD;
    dwMemoryLoad: DWORD;
    ullTotalPhys: DWORDLONG;
    ullAvailPhys: DWORDLONG;
    ullTotalPageFile: DWORDLONG;
    ullAvailPageFile: DWORDLONG;
    ullTotalVirtual: DWORDLONG;
    ullAvailVirtual: DWORDLONG;
    ullAvailExtendedVirtual: DWORDLONG;
  end;

function GlobalMemoryStatusEx(var lpBuffer: TMemoryStatusEx): BOOL;
  external 'GlobalMemoryStatusEx@kernel32.dll stdcall';

function InitializeSetup: Boolean;
var
  MemoryStatus: TMemoryStatusEx;
begin
  { allow the installation (even if the GlobalMemoryStatusEx call fails) }
  Result := True;
  { that's the requirement of the function call; you must set the size }
  { of the passed structure in bytes }
  MemoryStatus.dwLength := SizeOf(MemoryStatus);
  { if the GlobalMemoryStatusEx function call succeed, then... }
  if GlobalMemoryStatusEx(MemoryStatus) then
  begin
    MsgBox(Int64ToStr(MemoryStatus.ullTotalPhys), mbInformation, MB_OK);

    { if the amount of actual physical memory in bytes is less than }
    { 1073,741.824 B (1 GB), then show a warning message and according }
    { to user's decision abort the installation }
    if MemoryStatus.ullTotalPhys < 1073741824 then
    begin
      if MsgBox('You have less than 1GB of physical memory available. ' +
        'Are you sure you want to continue with the installation ?', 
        mbConfirmation, MB_YESNO) = IDNO
      then
        Result := False;
    end;
  end;
end;

关于inno-setup - Inno Setup - 如何在安装之前/期间检查系统规范?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17026867/

相关文章:

inno-setup - 防止 Inno Setup 在卸载时删除一些文件

inno-setup - Inno Setup - 从 .Net 4.5 位置运行 InstallUtil

c - 如何使用连续的 malloc 函数调用增加 C 程序的内存 (RAM)

jsf - JSF 2.2 所需的最低 Tomcat 版本

inno-setup - 创新设置: Disable finish page

inno-setup - 安装文件名是否可以从可执行文件版本号导出?

python - 我可以通过Python手动访问特定的内存地址吗

c - 地址转换示例

ios - iOS 2020年4月30日(延长至6月30日)2020年要求-iOS 13 SDK,全屏设计,启动Storyboard,Swift3