Пример, как заполнить ListBox информацией о версии запускаемого файла:
{ Добавляет или усекает String и
выравнивает по левому краю, если StrJustify = True}
function StringPad(
InputStr,
FillChar: string;
StrLen: integer;
StrJustify: boolean): string;
var
TempFill: string;
Counter : integer;
begin
if not (Length(InputStr) = StrLen) then
begin
if Length(InputStr) > StrLen then
begin
InputStr := Copy(InputStr, 1, StrLen) ;
end
else
begin
TempFill := '';
for Counter := 1 to StrLen - Length(InputStr) do
begin
TempFill := TempFill + FillChar;
end;
if StrJustify then
begin
{ Выравнивание по левому краю }
InputStr := InputStr + TempFill;
end
else
begin
{ Выравнивание по правому краю }
InputStr := TempFill + InputStr ;
end;
end;
end;
result := InputStr;
end;
function VersionInformation(
ListBox : TListBox): boolean;
const
InfoNum = 11;
InfoStr : array [1..InfoNum] of string =
('CompanyName', 'FileDescription', 'FileVersion',
'InternalName', 'LegalCopyright', 'LegalTradeMarks',
'OriginalFilename', 'ProductName', 'ProductVersion',
'Comments', 'Author') ;
LabelStr : array [1..InfoNum] of string =
('Company Name', 'Description', 'File Version',
'Internal Name', 'Copyright', 'TradeMarks',
'Original File Name', 'Product Name',
'Product Version', 'Comments', 'Author') ;
var
S : string;
j : integer;
n, Len : cardinal;
Buf : PChar;
Value : PChar;
begin
try
S := Application.ExeName;
ListBox.Items.Clear;
ListBox.Sorted := true;
ListBox.Font.Name := 'Courier New';
n := GetFileVersionInfoSize(PChar(S), n) ;
if n > 0 then begin
Buf := AllocMem(n) ;
ListBox.Items.Add
(StringPad('Size', ' ', 20, true) + ' = ' + IntToStr(n)) ;
GetFileVersionInfo(PChar(S), 0, n, Buf) ;
for j := 1 to InfoNum do begin
if VerQueryValue(Buf, PChar('StringFileInfo\040904E4\'+
InfoStr[j]), Pointer(Value), Len) then
begin
Value := PChar(Trim(Value)) ;
if Length(Value) > 0 then
begin
ListBox.Items.Add
(StringPad(labelStr[j], ' ', 20, true) + ' = ' + Value) ;
end;
end;
end;
FreeMem(Buf, n) ;
end
else begin
ListBox.Items.Add
('Не найдено FileVersionInfo') ;
end;
result := true;
except
result := false;
end;
end;
Использование:
VersionInformation(ListBox1)
|
Комментарии
I've loaded your blog in 3 completely different web browsers and I must say this
blog loads a lot faster then most. Can you suggest a good web hosting
provider at a honest price? Kudos, I appreciate
it!
will certainly digg it and individually suggest to my friends.
I'm sure they will be benefited from this website.
RSS лента комментариев этой записи