function DateiVersion(dt: string): string;
var
Nullw, InfoSize, FixInfo: Cardinal;
PFixInfo: PVSFixedFileInfo;
Zeiger: Pointer;
begin
Result := '';
Nullw := 0;
InfoSize := GetFileVersionInfoSize(PChar(dt), Nullw);
if InfoSize > 0 then begin
Zeiger := GetMemory(InfoSize);
if assigned(Zeiger) then begin
GetFileVersionInfo(PChar(dt), Nullw, InfoSize, Zeiger);
if VerQueryValue(Zeiger, '\', Pointer(PFixInfo), FixInfo) then begin
Result := Format('%d.%d.%d.%d',
[HiWord(PFixInfo^.dwFileVersionMS),
LoWord(PFixInfo^.dwFileVersionMS),
HiWord(PFixInfo^.dwFileVersionLS),
LoWord(PFixInfo^.dwFileVersionLS)]);
end;
FreeMemory(Zeiger);
end;
end;
end;
function bdeda: string;
var
Reg: TRegistry;
begin
Result := '';
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\SOFTWARE\Borland\Database Engine', false)
then Result := Reg.readString('DllPath');
Reg.CloseKey;
Reg.Free;
end;
function BDE_Version: string;
begin
Result := bdeda;
if Result = '' then exit;
if ansilastchar(Result) <> '\' then Result := Result + '\';
Result := Result + 'idapi32.dll';
if not fileexists(Result) then exit;
Result := DateiVersion(Result);
end;
// Beispielaufruf
procedure TForm1.Button2Click(Sender: TObject);
var s: string;
begin
s := BDE_Version;
if s = '' then showmessage('BDE nicht gefunden.')
else showmessage('BDE-Version: ' + s);
end;