gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:36:34 24 4
gpt4 key购买 nike

特别是,我想检查 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com