Mega Code Archive

 
Categories / Delphi / Examples
 

Versioninfo

Subject: RE: Version information SW> I am trying to extract the version information from my SW> application's resource. I have tried using FindResource, SW> but I can't even get that to return successfully. Here after a function from one of my applications. Should do what you are looking for. procedure TRebuildForm.ExtractVersionInfo(DispProc : TDispProc); const InfoStr : array [1..10] of String = ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFilename', 'ProductName', 'ProductVersion', 'Comments'); var ExeName : String; Len, I : Integer; InfoSize : Integer; InfoBuf : PChar; Value : PChar; Charset : DWORD; Language : WORD; begin ExeName := Application.ExeName; InfoSize := GetFileVersionInfoSize(PChar(ExeName), I); if InfoSize > 0 then begin InfoBuf := AllocMem(InfoSize); GetFileVersionInfo(PChar(ExeName), 0, InfoSize, InfoBuf); if VerQueryValue(InfoBuf, '\VarFileInfo\Translation', Pointer(Value), Len) then begin Language := PWORD(Value)^; CharSet := PWORD(Value + 2)^; end else begin Language := 0; CharSet := 0; end; DispProc(Format('%-16s : ''%s''', ['Language', IntToHex(Language, 4)])); DispProc(Format('%-16s : ''%s''', ['Charset', IntToHex(Charset, 4)])); for I := Low(InfoStr) to High(InfoStr) do begin if VerQueryValue(InfoBuf, PChar('StringFileInfo\' + IntToHex(Language, 4) + IntToHex(Charset, 4) + '\'+ InfoStr[I]), Pointer(Value), Len) then DispProc(Format('%-16s : ''%s''', [InfoStr[i], Value])); end; FreeMem(InfoBuf, InfoSize); end else DispProc('No FileVersionInfo found'); end; {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} > -- > francois.piette@pophost.eunet.be > The author of the freeware Internet Component Suite > and freeware middleware MidWare > http://www.rtfm.be/fpiette/indexuk.htm