得到文件的版本信息程序
【打印文章】
procedure TForm1.GetVersionInfo;
const
n_Info = 10;
InfoStr : array [1..n_Info] of String =
('CompanyName', 'FileDescription', 'FileVersion', 'InternalName',
'LegalCopyright', 'LegalTradeMarks', 'OriginalFilename',
'ProductName', 'ProductVersion', 'Comments');
var
Info : String;
BuffSize,
Len, i : Integer;
Buff : PChar;
Value : PChar;
begin
Info := Application.ExeName;
BuffSize := GetFileVersionInfoSize(PChar(Info),BuffSize);
if BuffSize > 0 then
begin
Buff := AllocMem(BuffSize);
Memo1.Lines.Add('FileVersionInfoSize='+IntToStr(BuffSize));
GetFileVersionInfo(PChar(Info),0,BuffSize,Buff);
Info := Info + ':';
for i := 1 to n_Info do
if VerQueryValue(Buff,PChar('StringFileInfo\040904E4\'+
InfoStr[i]), Pointer(Value), Len) then
Info := Info + #13 + InfoStr[i] + '=' + Value;
FreeMem(Buff,BuffSize);
ShowMessage (Info);
end
else
ShowMessage ('No FileVersionInfo found');
end;
const
n_Info = 10;
InfoStr : array [1..n_Info] of String =
('CompanyName', 'FileDescription', 'FileVersion', 'InternalName',
'LegalCopyright', 'LegalTradeMarks', 'OriginalFilename',
'ProductName', 'ProductVersion', 'Comments');
var
Info : String;
BuffSize,
Len, i : Integer;
Buff : PChar;
Value : PChar;
begin
Info := Application.ExeName;
BuffSize := GetFileVersionInfoSize(PChar(Info),BuffSize);
if BuffSize > 0 then
begin
Buff := AllocMem(BuffSize);
Memo1.Lines.Add('FileVersionInfoSize='+IntToStr(BuffSize));
GetFileVersionInfo(PChar(Info),0,BuffSize,Buff);
Info := Info + ':';
for i := 1 to n_Info do
if VerQueryValue(Buff,PChar('StringFileInfo\040904E4\'+
InfoStr[i]), Pointer(Value), Len) then
Info := Info + #13 + InfoStr[i] + '=' + Value;
FreeMem(Buff,BuffSize);
ShowMessage (Info);
end
else
ShowMessage ('No FileVersionInfo found');
end;
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】