Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
Re: Versionsinformationen einer EXE- oder DLL-Datei abfragen
27. Jul 2006, 21:08
Ich würde es so machen:
Delphi-Quellcode:
function GetVersion(FileName: string; var Major, Minor, Release, Build: DWORD): DWORD;
var
VerInfoSize, VerValueSize, Dummy: DWord;
VerInfo : Pointer;
VerValue : PVSFixedFileInfo;
err : DWORD;
begin
err := 0;
VerInfoSize := GetFileVersionInfoSize(PChar(FileName), Dummy);
if VerInfoSize <> 0 then
begin
GetMem(VerInfo, VerInfoSize);
try
GetFileVersionInfo(PChar(FileName), 0, VerInfoSize, VerInfo);
if VerInfo <> nil then
begin
if VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize) then
begin
with VerValue^ do
begin
Major := dwFileVersionMS shr 16;
Minor := dwFileVersionMS and $FFFF;
Release := dwFileVersionLS shr 16;
Build := dwFileVersionLS and $FFFF;
end;
end
else
err := GetLastError;
end;
finally
FreeMem(VerInfo, VerInfoSize);
end;
end
else
err := GetLastError;
result := err;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Major, Minor, Release, Build: DWORD;
err: DWORD;
s: String;
begin
err := GetVersion(ParamStr(0), Major, Minor, Release, Build);
if err <> 0 then
s := SysErrorMessage(err)
else
s := Format('%d.%d.%d.%d', [major, Minor, Release, Build]);
ShowMessage(s);
end;
Michael Ein Teil meines Codes würde euch verunsichern.
|
|
Zitat
|