로컬 파일의 파일 정보 가져오기
function GetFileVersion(filename: string = ''): string;
var
iBufferSize: DWORD;
iDummy: DWORD;
pBuffer: Pointer;
pFileInfo: Pointer;
iVer: array[1..4] of word;
begin
if filename = '' then
FileName := Application.ExeName;
Result := '';
iBufferSize := GetFileVersionInfoSize(PChar(filename), iDummy);
if (iBufferSize > 0) then
begin
Getmem(pBuffer, iBufferSize);
try
GetFileVersionInfo(PChar(filename), 0, iBufferSize, pBuffer);
VerQueryValue(pBuffer, '\', pFileInfo, iDummy);
iVer[1] := HiWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionMS);
iVer[2] := LoWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionMS);
iVer[3] := HiWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionLS);
iVer[4] := LoWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionLS);
finally
Freemem(pBuffer);
end;
Result := Format('%d.%d.%d.%d', [iVer[1], iVer[2], iVer[3], iVer[4]]);
end;
end;