|
|
|
|
|
Dicas
|
|
Visual Basic (ActiveX/Controles/DLL)
|
|
|
Título da Dica: Detectando a versão do DIRECTX com o INNO SETUP
|
|
|
|
Postada em 15/5/2006 por ¨Hennyere¨
[Setup] AppName=DirectX AppVerName=DirectX DefaultDirName={pf}DirectX DisableStartupPrompt=true Uninstallable=false DisableDirPage=true OutputBaseFilename=DirectX CreateAppDir=false DisableProgramGroupPage=true
[Code]
procedure DecodeVersion( verstr: String; var verint: array of Integer ); var i,p: Integer; s: string; begin // initialize array verint := [0,0,0,0]; i := 0; while ( (Length(verstr) > 0) and (i < 4) ) do begin p := pos('.', verstr); if p > 0 then begin if p = 1 then s:= '0' else s:= Copy( verstr, 1, p - 1 ); verint := StrToInt(s); i := i + 1; verstr := Copy( verstr, p+1, Length(verstr)); end else begin verint := StrToInt( verstr ); verstr := ''; end; end;
end;
// This function compares version string // return -1 if ver1 < ver2 // return 0 if ver1 = ver2 // return 1 if ver1 > ver2 function CompareVersion( ver1, ver2: String ) : Integer; var verint1, verint2: array of Integer; i: integer; begin
SetArrayLength( verint1, 4 ); DecodeVersion( ver1, verint1 );
SetArrayLength( verint2, 4 ); DecodeVersion( ver2, verint2 );
Result := 0; i := 0; while ( (Result = 0) and ( i < 4 ) ) do begin if verint1 > verint2 then Result := 1 else if verint1 < verint2 then Result := -1 else Result := 0;
i := i + 1; end;
end;
// DirectX version is stored in registry as 4.majorversion.minorversion // DirectX 8.0 is 4.8.0 // DirectX 8.1 is 4.8.1 // DirectX 9.0 is 4.9.0
function GetDirectXVersion(): String; var sVersion: String; begin sVersion := '';
RegQueryStringValue( HKLM, 'SOFTWAREMicrosoftDirectX', 'Version', sVersion );
Result := sVersion; end;
function InitializeSetup(): Boolean; begin // in this case program needs at least directx 8.0 if CompareVersion( GetDirectXVersion(), '4.8.0') < 0 then begin Result := MsgBox('DirectX 8 not found. The 3d test will not run and games may not perform optimally. Do you wish to continue?', mbConfirmation, MB_YESNO) = idYes; if Result = False then MsgBox('Please upgrade your DirectX Version at http://www.microsoft.com/directx', mbInformation, MB_OK); end else Result := true; end;
|
|
|
|
|