mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 05:29:08 +02:00
+ GetFileVersion (win only)
git-svn-id: trunk@4924 -
This commit is contained in:
parent
557afed6f3
commit
b6309075a4
@ -49,20 +49,63 @@ Var
|
|||||||
Win32CSDVersion : ShortString; // CSD record is 128 bytes only?
|
Win32CSDVersion : ShortString; // CSD record is 128 bytes only?
|
||||||
|
|
||||||
{ Compatibility with Delphi }
|
{ Compatibility with Delphi }
|
||||||
function Win32Check(res:boolean):boolean;
|
function Win32Check(res:boolean):boolean;inline;
|
||||||
|
function WinCheck(res:boolean):boolean;
|
||||||
|
|
||||||
|
function GetFileVersion(const AFileName: string): Cardinal;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
sysconst;
|
sysconst;
|
||||||
|
|
||||||
function Win32Check(res:boolean):boolean;
|
function WinCheck(res:boolean):boolean;
|
||||||
begin
|
begin
|
||||||
if not res then
|
if not res then
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
result:=res;
|
result:=res;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function Win32Check(res:boolean):boolean;inline;
|
||||||
|
begin
|
||||||
|
result:=WinCheck(res);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetFileVersion(const AFileName:string):Cardinal;
|
||||||
|
var
|
||||||
|
{ usefull only as long as we don't need to touch different stack pages }
|
||||||
|
buf : array[0..3071] of byte;
|
||||||
|
bufp : pointer;
|
||||||
|
fn : string;
|
||||||
|
valsize,
|
||||||
|
size : DWORD;
|
||||||
|
h : DWORD;
|
||||||
|
valrec : PVSFixedFileInfo;
|
||||||
|
begin
|
||||||
|
result:=$fffffff;
|
||||||
|
fn:=AFileName;
|
||||||
|
UniqueString(fn);
|
||||||
|
size:=GetFileVersionInfoSize(pchar(fn),@h);
|
||||||
|
if size>sizeof(buf) then
|
||||||
|
begin
|
||||||
|
getmem(bufp,size);
|
||||||
|
try
|
||||||
|
if GetFileVersionInfo(pchar(fn),h,size,bufp) then
|
||||||
|
if VerQueryValue(bufp,'\',valrec,valsize) then
|
||||||
|
result:=valrec^.dwFileVersionMS;
|
||||||
|
finally
|
||||||
|
freemem(bufp);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if GetFileVersionInfo(pchar(fn),h,size,@buf) then
|
||||||
|
if VerQueryValue(@buf,'\',valrec,valsize) then
|
||||||
|
result:=valrec^.dwFileVersionMS;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$define HASCREATEGUID}
|
{$define HASCREATEGUID}
|
||||||
@ -418,8 +461,6 @@ var
|
|||||||
secs,bytes,
|
secs,bytes,
|
||||||
free,total : longint;
|
free,total : longint;
|
||||||
qwtotal,qwfree,qwcaller : int64;
|
qwtotal,qwfree,qwcaller : int64;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if drive=0 then
|
if drive=0 then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user