PDA

View Full Version : بدست آوردن ورژن برنامه



Saeid59_m
سه شنبه 09 مرداد 1386, 12:40 عصر
سلام دوستان
چطور میشه بوسیله کد ورژنی را که در قسمت Projet->Option مشخص می کنیم بدست آورد ؟

vcldeveloper
چهارشنبه 10 مرداد 1386, 09:17 صبح
function GetFileVersion(const FileName: TFileName): WideString;
var
lpdwHandle,
puLen,
VersionInfoSize : Cardinal;
lpData,
lplpBuffer : pointer;
begin
Result := '';
if not FileExists(FileName) then
raise Exception.Create('File not found');
//Get version information size
VersionInfoSize := GetFileVersionInfoSize(PAnsiChar(FileName),lpdwHan dle);
if VersionInfoSize <= 0 then
raise Exception.Create('Could not retreive file version info');
//Get memory for the version information
GetMem(lpData,VersionInfoSize);
try
//Retrieve version information
if GetFileVersionInfo(PAnsiChar(FileName),0,VersionIn foSize,lpData) = False then
RaiseLastOSError;
//Extract file version from the buffer
if VerQueryValue(lpData,'\\StringFileInfo\\040904E4\\ FileVersion',lplpBuffer,puLen) = False then
RaiseLastOSError;
finally
FreeMem(lpData);
end;
//If any file version info is retrieved then return it as the function result.
if puLen > 0 then
Result := Trim(PAnsiChar(lplpBuffer));
end;