提取与文件关联的图标 [英] Extract Icon Associated with a File

查看:65
本文介绍了提取与文件关联的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我正在使用 MSDN [

Hello!

Im using the code from MSDN[^] to extract icons from file.

I am creating an app launcher with listview, imagelist.

The problem is that only the first icon associated with respective file gets extracted.

So if i have 5 applications with 5 different icon, all 5 gets the icon from the first app.

Since the files in my listview will change over time, i cant specify icons either.

All tips are welcome.

推荐答案

您引用的MSDN示例使用文件扩展名作为图像键将图像添加到ImageList中. 一次只能将一个图像与一个键相关联,因此,如果您没有更改此行为,则可能必须修改该行代码
The MSDN sample you referenced add images to the ImageList using the file extension as image key.
Only an image at a time can be associated to a key, thus if you didn''t changed this behavior, maybe you have to modify that line of code
imageList1.Images.Add(file.Extension, iconForFile);


应该更改为


should be changed into

imageList1.Images.Add(file.FullName, iconForFile);


或更方便的东西.

同样适用于


or something more convenient.

the same applies to

item.ImageKey = file.Extension;


应该更改为


that should be changed into

item.ImageKey = file.FullName;



问候,
Daniele.



Regards,
Daniele.


这篇关于提取与文件关联的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆