System Delphi

Title: How to extract exe/dll/ocx ... file information
Question: If you want to check a file version or product name of an existing system dll, or you are creating an install program that only installs newer versions of dll or exe.
* Works with all Delphi versions
Answer:
Its a simple function that retuns the iformation requested. You can use a VersionInfo array element to pass as the parameter:
Label1.Caption := GetFileInfo('c:\windows\explorer.exe', VersionInfo[3]);
or
Label1.Caption := GetFileInfo('c:\windows\explorer.exe', 'FileVersion');
===============================================
unit lFilever;
interface
uses
WinTypes, WinProcs, SysUtils {$IFNDEF WIN32} ,Ver {$ENDIF};
const
VersionInfo: array [1..8] of string = (
'CompanyName', 'FileDescription', 'FileVersion', 'InternalName',
'LegalCopyRight', 'OriginalFileName', 'ProductName', 'ProductVersion');
function GetFileInfo(FName, InfoType: string): string;
implementation
function GetFileInfo(FName, InfoType: string): string;
var
Info : Pointer;
InfoData : Pointer;
InfoSize : LongInt;
InfoLen : {$IFDEF WIN32} DWORD;{$ELSE} LongInt; {$ENDIF}
DataLen : {$IFDEF WIN32} UInt; {$ELSE} word; {$ENDIF}
LangPtr : Pointer;
begin
result:=''; DataLen:=255;
if Length(FName) FName:=FName+#0;
InfoSize:=GetFileVersionInfoSize(@Fname[1], InfoLen);
if (InfoSize 0) then
begin
GetMem(Info, InfoSize);
try
if GetFileVersionInfo(@FName[1], InfoLen, InfoSize, Info) then
begin
if VerQueryValue(Info,'\VarFileInfo\Translation',LangPtr, DataLen) then
InfoType:=Format('\StringFileInfo\%0.4x%0.4x\%s'#0,[LoWord(LongInt(LangPtr^)),
HiWord(LongInt(LangPtr^)), InfoType]);
if VerQueryValue(Info,@InfoType[1],InfoData,Datalen) then
Result := strPas(InfoData);
end;
finally
FreeMem(Info, InfoSize);
end;
end;
end;
end.