如何获得与文件类型关联的图标? [英] How do I get the icon associated with a file type?

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

问题描述

我在一个TabControl显示文件信息的形式,我想要的页面在其选项卡中的文件的图标。如何获得与文件类型关联的图标?

I have a form that displays file information in a TabControl, and I'd like the pages to have the file's icon in their tab. How do I get the icon associated with a file type?

我preFER的解决方案,不涉及望着东西在注册表中,但如果这是唯一的办法那就这样吧。

I'd prefer solutions that don't involve looking things up in the registry, but if that's the only way then so be it.

推荐答案

$ C $的CProject 有一些课程,你可以下载。

CodeProject has some classes you can download.

首先得到FileAssociationInfo,并从获得ProgramAssociationInfo。该PAI对象可以给你的图标。

First get the FileAssociationInfo, and from that get the ProgramAssociationInfo. The PAI object can give you the icon.

FileAssociationInfo fai = new FileAssociationInfo(".bob");
ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
ProgramIcon icon = pai.DefaultIcon;

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

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