加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 09:33:52 所属栏目:大数据 来源:网络整理
导读:特别是,我想检查一下PC上安装的RAM量.如果它小于1GB,我想在安装之前/期间显示警告信息…… 解决方法 我会在设置开始时亲自进行此检查,以免让用户通过安装向导失望.为此,我将在向导实际显示为以下脚本中使用的向导之前显示警告.当内存低于机器上检测到的物理
特别是,我想检查一下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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读