D
delhpi
Unregistered / Unconfirmed
GUEST, unregistred user!
ou can use the Windows GetFileVersionInfo and VerQueryValue API functions to obtain version information that is compiled with your application. The following code illustrates how to do this by writing the version information to a memo control named Memo1:
procedure TForm1.Button1Click(Sender: TObject);
const
InfoNum = 10;
InfoStr: array[1..InfoNum] of string = ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFileName', 'ProductName', 'ProductVersion', 'Comments');
var
S: string;
n, Len, i: DWORD;
Buf: PChar;
Value: PChar;
begin
S := Application.ExeName;
n := GetFileVersionInfoSize(PChar(S), n);
if n > 0 then
begin
Buf := AllocMem;
Memo1.Lines.Add('VersionInfoSize = ' + IntToStr);
GetFileVersionInfo(PChar(S), 0, n, Buf);
for i := 1 to InfoNum do
if VerQueryValue(Buf, PChar('StringFileInfo/040904E4/' + InfoStr), Pointer(Value), Len) then //这句话,不明白,是否要修改一下?
Memo1.Lines.Add(InfoStr + ' = ' + Value);
FreeMem(Buf, n);
end
else
Memo1.Lines.Add('No version information found');
end;
procedure TForm1.Button1Click(Sender: TObject);
const
InfoNum = 10;
InfoStr: array[1..InfoNum] of string = ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFileName', 'ProductName', 'ProductVersion', 'Comments');
var
S: string;
n, Len, i: DWORD;
Buf: PChar;
Value: PChar;
begin
S := Application.ExeName;
n := GetFileVersionInfoSize(PChar(S), n);
if n > 0 then
begin
Buf := AllocMem;
Memo1.Lines.Add('VersionInfoSize = ' + IntToStr);
GetFileVersionInfo(PChar(S), 0, n, Buf);
for i := 1 to InfoNum do
if VerQueryValue(Buf, PChar('StringFileInfo/040904E4/' + InfoStr), Pointer(Value), Len) then //这句话,不明白,是否要修改一下?
Memo1.Lines.Add(InfoStr + ' = ' + Value);
FreeMem(Buf, n);
end
else
Memo1.Lines.Add('No version information found');
end;