6

特に、PC に搭載されている RAM の量を確認したいと思います。1GB未満の場合、インストール前/インストール中に警告メッセージを表示したいのですが...

4

2 に答える 2

9

インストール ウィザードを実行するユーザーを失望させないように、セットアップの最初にこのチェックを個人的に行います。これを行うには、次のスクリプトで使用されているウィザードが実際に表示される前に、警告を表示します。メモリがマシンで検出された物理メモリの 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;
于 2013-06-10T23:10:21.937 に答える
1

これがお役に立てば幸いです...

#define MyAppName "RAM SIZE"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{5DC352AD-7D20-41C8-9372-B174BDE452CB}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
CreateAppDir=no
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[code]
   procedure initializeWizard;
   var
i,ramsize:integer;
resultcode:integer;
TmpFileName,ExecStdout,tempstr:string;  

   begin
    TmpFileName := ExpandConstant('{tmp}') + '\systeminformation.txt';
    Exec('cmd.exe', '/C systeminfo |find "Total Physical Memory" > "' + TmpFileName + '"', '', SW_HIDE,ewWaitUntilTerminated, ResultCode);
    if LoadStringFromFile(TmpFileName, ExecStdout) then
    begin
    deletefile(TmpFileName);
    ExecStdout:=copy(Execstdout,27,6);
    for   i:=1 to length(Execstdout) do
    begin
    if  ((Execstdout[i]>='0') and (Execstdout[i]<='9'))then
    tempstr:=tempstr+Execstdout[i];
    end; 
    ramsize:=strtoint(tempstr);
    Msgbox('RAM SIZE OF THIS SYSTEM IS : '+tempstr+' MB' ,mbinformation,mb_ok);
    Msgbox('RAM SIZE OF THIS SYSTEM IS : '+inttostr(ramsize)+' MB' ,mbinformation,mb_ok);
     if ramsize<1024 then
     Msgbox('Warning:RAM SIZE IS LESS THAN 1 GB , Do you want to proceed  ',mbinformation,mb_yesno);
     //result is IDYES if you press yes then contiue after check..
     end;

     end;
于 2013-07-06T15:49:55.377 に答える