Inno Setup-如何在安装之前/安装过程中检查系统规格? [英] Inno Setup - How can I check system specs before/during installation?

查看:85
本文介绍了Inno Setup-如何在安装之前/安装过程中检查系统规格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In particular, I'd like to check the amount of RAM installed on the PC. If it's less than 1GB, I'd like to show a warning message before/during the installation...

推荐答案

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

I would personally do this check at the beginning of the setup to not disappoint the user going through the installation wizard. To do this, I would display the warning before the wizard is actually shown as its used in the following script. It should warn the user when the memory is below 1073,741.824 B (1GB) of physical memory detected on the machine. If the user disagree with the warning, the setup is terminated; if there's more than the mentioned amount of actual physical memory or the user accepted the warning, the setup process continues:

[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-如何在安装之前/安装过程中检查系统规格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆