Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.432 Beiträge
 
Delphi 7 Professional
 
#8

AW: Herausfinden welche Firebird 3.0 32Bit- oder 64Bit Version installiert ist

  Alt 20. Mai 2021, 14:50
Nur zum Spaß. Könnte man das so machen?
Delphi-Quellcode:
program CheckBitVersion;

{$APPTYPE CONSOLE}

uses
  SysUtils, Classes;

function IsExe64Bit(s : String) : Integer;
var
  fs : TFileStream;
  buffer : Array [0..4095] Of Char;
  i : Integer;
begin
  Result := -1;
  fs := TFileStream.Create(s,fmOpenRead);
  Try
    fs.Read(buffer,SizeOf(Buffer));
    for i := Low(Buffer) to High(Buffer) - 5 do begin
      if (Buffer[i] = 'P') and (Buffer[i + 1] = 'E') then begin
        case Buffer[i + 4] of
          'D' : Result := 64;
          'L' : Result := 32;
        end;
        break;
      end;
    end;
  finally
    fs.Free;
  end;
end;

begin
  Write(ExtractFileName(ParamStr(1)),': ');
  if FileExists(ParamStr(1)) then begin
    ExitCode := IsExe64Bit(ParamStr(1));
    case ExitCode of
      64 : Write('64-Bit');
      32 : Write('32-Bit');
    else
      Write('unbekanntes Format');
    end;
    WriteLn(' (',ExtractFilePath(ParamStr(1)),')');
  end else begin
    WriteLn('existiert nicht');
    ExitCode := -2;
  end;
end.
Aufruf z. B.:
Code:
for %i in (c:\Firebird\*.exe) do @CheckBitVersion.exe %i
Ausgabe z. B.:
Code:
fbguard.exe: 32-Bit
fbsvcmgr.exe: 32-Bit
fbtracemgr.exe: 32-Bit
fb_lock_print.exe: 32-Bit
firebird.exe: 32-Bit
gbak.exe: 32-Bit
gfix.exe: 32-Bit
gpre.exe: 32-Bit
gsec.exe: 32-Bit
gsplit.exe: 32-Bit
gstat.exe: 32-Bit
instclient.exe: 32-Bit
instreg.exe: 32-Bit
instsvc.exe: 32-Bit
isql.exe: 32-Bit
nbackup.exe: 32-Bit
qli.exe: 32-Bit
unins000.exe: 32-Bit
Oder:
Code:
for %i in (c:\Firebird\*.dll) do @CheckBitVersion.exe %i
fbclient.dll: 32-Bit
fbrmclib.dll: 32-Bit
ib_util.dll: 32-Bit
icudt52.dll: 32-Bit
icuin52.dll: 32-Bit
icuuc52.dll: 32-Bit
msvcp100.dll: 32-Bit
msvcr100.dll: 32-Bit
zlib1.dll: 32-Bit
Oder:
Code:
c:\>CheckBitVersion.exe c:\Firebird\firebird.exe
firebird.exe: 32-Bit

c:\>echo %Errorlevel%
32
Und wenn man ein ganzes Laufwerk abgrasen will z. B. sowas:
Code:
for /F "delims=?" %i in ('dir c:\fbclient.dll /b /s') do @CheckBitVersion.exe "%i"
Kann dann aber auch mal ein bisserl dauern

Geändert von Delphi.Narium (20. Mai 2021 um 17:28 Uhr) Grund: Schreibfehler ...
  Mit Zitat antworten Zitat