特别是,我想检查一下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;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。