|

楼主 |
发表于 2009-8-18 18:50:27
|
显示全部楼层
这个是你们系统库的函数:
function TDocImageListProvider.GetImageIndexByExtName(const AExtName: string): Integer;
var
lIndex: Integer;
lSmallIcon, lLargeIcon: TIcon;
begin
if FFileExtNameAndImageIndexList.IndexOfName(AExtName) >= 0 then
Result := SysUtils.StrToInt(FFileExtNameAndImageIndexList.Values[AExtName])
else
begin
lLargeIcon := TIcon.Create;
lSmallIcon := TIcon.Create;
try
jsGraph.GetFileIcon(AExtName, lLargeIcon, lSmallIcon);
lIndex := 0;
if FLargeImageList <> nil then
begin
lIndex := FLargeImageList.AddIcon(lLargeIcon);
FLargeImageList.AddIcon(lLargeIcon);
end;
if FSmallImageList <> nil then
begin
lIndex := FSmallImageList.AddIcon(lSmallIcon);
FSmallImageList.AddIcon(lSmallIcon);
end;
Assert(lIndex <> 0, '');
FFileExtNameAndImageIndexList.Add(SysUtils.Format('%s=%d', [AExtName, lIndex]));
Result := lIndex;
finally
lSmallIcon.Free;
lLargeIcon.Free;
end;
end;
end; |
|