반응형
function GetFileVersion(ExePath: String): String;
var
trans : Pointer;
transtring : String;
n, aLen, bLen : DWORD;
Buf : PChar;
Version : PChar;
begin
n := GetFileVersionInfoSize(PChar(ExePath), n);
Buf := AllocMem(n);
try
GetFileVersionInfo(PChar(ExePath), 0, n, Buf);
VerQueryValue(Buf, 'VarFileInfo\Translation', trans, aLen);
transtring := IntToHex(MakeLong(HiWord(Longint(trans^)), LoWord(Longint(trans^))), 8);
VerQueryValue(Buf, PChar('StringFileInfo\' + transtring + '\FileVersion'), Pointer(Version), bLen);
finally
FreeMem(Buf, n);
result := Version;
end;
end;
var
trans : Pointer;
transtring : String;
n, aLen, bLen : DWORD;
Buf : PChar;
Version : PChar;
begin
n := GetFileVersionInfoSize(PChar(ExePath), n);
Buf := AllocMem(n);
try
GetFileVersionInfo(PChar(ExePath), 0, n, Buf);
VerQueryValue(Buf, 'VarFileInfo\Translation', trans, aLen);
transtring := IntToHex(MakeLong(HiWord(Longint(trans^)), LoWord(Longint(trans^))), 8);
VerQueryValue(Buf, PChar('StringFileInfo\' + transtring + '\FileVersion'), Pointer(Version), bLen);
finally
FreeMem(Buf, n);
result := Version;
end;
end;
반응형