// Get the file type
if SHGetFileInfo(PWideChar(aFilename), 0, rSHFI, SizeOf(rSHFI), SHGFI_TYPENAME) <> 0 then
begin
aInfo.FileType := rSHFI.szTypeName;
end;
iRet := SHGetFileInfo(PWideChar(aFilename), 0, rSHFI, SizeOf(rSHFI), SHGFI_EXETYPE);
if iRet <> 0 then
begin
// determine whether the
OS can obtain version information
VerSize := GetFileVersionInfoSize(PChar(aFilename), VerHandle);
if VerSize > 0 then
begin
VerBuf := AllocMem(VerSize);
try
with aInfo do
begin
CompanyName := QueryValue('CompanyName');
FileDescription := QueryValue('FileDescription');
FileVersion := QueryValue('FileVersion');
InternalName := QueryValue('InternalName');
LegalCopyRight := QueryValue('LegalCopyRight');
LegalTradeMarks := QueryValue('LegalTradeMarks');
OriginalFileName := QueryValue('OriginalFileName');
ProductName := QueryValue('ProductName');
ProductVersion := QueryValue('ProductVersion');
Comments := QueryValue('Comments');
SpecialBuildStr := QueryValue('SpecialBuild');
PrivateBuildStr := QueryValue('PrivateBuild');
// Fill the VS_FIXEDFILEINFO structure
FixedFileInfo := GetFixedFileInfo;
DebugBuild := HasdwFileFlags(FixedFileInfo,VS_FF_DEBUG);
PreRelease := HasdwFileFlags(FixedFileInfo,VS_FF_PRERELEASE);
PrivateBuild := HasdwFileFlags(FixedFileInfo,VS_FF_PRIVATEBUILD);
SpecialBuild := HasdwFileFlags(FixedFileInfo,VS_FF_SPECIALBUILD);
Patched := HasdwFileFlags(FixedFileInfo,VS_FF_PATCHED);
InfoInferred := HasdwFileFlags(FixedFileInfo,VS_FF_INFOINFERRED);
FileFunction := GetFileSubType(FixedFileInfo);
end;
finally
FreeMem(VerBuf, VerSize);
end;
GetFileInfo(aFilename,aInfo.FileInfoVersion);
result := True;
end;
end