//uses ShellAPI
var
AMsg: AnsiString;
AItem: TListItem;
APsfi: TSHFileInfo;
vIcon: TIcon;
begin
vIcon := TIcon.Create;
try
SHGetFileInfo(PChar('c:\test.rar'), 0, APsfi, SizeOf(APsfi), SHGFI_SYSICONINDEX or SHGFI_ICON );
vIcon.Handle := APsfi.hIcon;
AItem := ListView1.Items.Add;
AItem.Caption := 'test';
AItem.ImageIndex := ImageList1.AddIcon(vIcon);;
//目录
SHGetFileInfo(PChar('c:\windows'), FILE_ATTRIBUTE_DIRECTORY, APsfi, SizeOf(APsfi),
SHGFI_ICON);
vIcon.Handle := APsfi.hIcon;
AItem := ListView1.Items.Add;
AItem.Caption := 'DIR';
AItem.ImageIndex := ImageList1.AddIcon(vIcon);;
finally
vIcon.Free;
end;
SHGetFileInfo获取当前计算机文件或目录图标
最新推荐文章于 2021-06-25 16:17:21 发布