어떤 파일(exe, dll)의 버전을 읽어 오기 위해서는
3개의 함수를 순서대로 사용해야 합니다.
1. GetFileVersionInfoSize
2. GetFileVersionInfo
3. VerQueryValue
결국 VerQueryValue함수를 호출 하고 난후 버전을 구할수 있죠...
위 3개의 API함수들은 도움말을 참조 하시고
간단한 예제를 만들어 봤습니당...
참고 하세요...
폼위에 memo와 버튼하나 놓았습니다.
도움이 되었음 하네요...
그럼 즐프...
procedure TForm1.Button1Click(Sender: TObject);
var
Size, Size2: DWord;
Pt, Pt2: Pointer;
begin
Memo1.Lines.Clear;
Size := GetFileVersionInfoSize (
PChar (ParamStr (0)), Size2);
if Size > 0 then
begin
GetMem (Pt, Size);
//Buf := AllocMem(n);
try
GetFileVersionInfo (PChar (ParamStr (0)), 0, Size, Pt);
// show the fixed information
VerQueryValue (Pt, '\', Pt2, Size2);
with TVSFixedFileInfo (Pt2^) do
begin
showmessage ('Signature (should be invariably 0xFEEFO4BD): ' + IntToHex (dwSignature, 16));
showmessage ('Major version number: ' + IntToStr (HiWord (dwFileVersionMS)));
showmessage ('Minor version number: ' + IntToStr (LoWord (dwFileVersionMS)));
showmessage ('Release version number: ' + IntToStr (HiWord (dwFileVersionLS)));
showmessage ('Build version number: ' + IntToStr (LoWord (dwFileVersionLS)));
if (dwFileFlagsMask and dwFileFlags and VS_FF_DEBUG) <> 0 then
showmessage ('Debug info included');
if (dwFileFlagsMask and dwFileFlags and VS_FF_PRERELEASE) <> 0 then
showmessage ('Pre-release (beta) version');
if (dwFileFlagsMask and dwFileFlags and VS_FF_PRIVATEBUILD) <> 0 then
showmessage ('Private Build');
if (dwFileFlagsMask and dwFileFlags and VS_FF_SPECIALBUILD) <> 0 then
showmessage ('Special Build');
end;
// show some of the strings
VerQueryValue(Pt,'\StringFileInfo\040904E4\FileDescription',Pt2, Size2);
showmessage ('File Description: ' +PChar (Pt2));
VerQueryValue(Pt,'\StringFileInfo\040904E4\FileVersion',Pt2, Size2);
showmessage ('File Version: ' + PChar (pt2));
VerQueryValue(Pt,'\StringFileInfo\040904E4\InternalName',Pt2, Size2);
showmessage ('Internal Name: ' + PChar (pt2));
VerQueryValue(Pt,'\StringFileInfo\040904E4\LegalCopyright',Pt2, Size2);
showmessage ('Legal Copyright: ' + PChar (pt2));
VerQueryValue(Pt,'\StringFileInfo\040904E4\ProductDescription',Pt2, Size2);
showmessage ('Product Name: ' + PChar (pt2));
VerQueryValue(Pt,'\StringFileInfo\040904E4\ProductVersion',Pt2, Size2);
showmessage ('Product Version: ' + PChar (pt2));
finally
FreeMem (Pt);
end;
end;
end;
출처 : 델마당
원문 : http://www.delmadang.com/community/bbs_view.asp?bbsNo=17&bbsCat=0&st=S&keyword=%uBC84%uC83C%20%uC815%uBCF4&indx=317505&keyword1=버젼&keyword2=정보&page=1