如何将文件类型与图标相关联? [英] How do I associate a filetype with an icon?

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

问题描述

我为几种自定义文件类型编写了预览处理程序.这些文件类型默认没有可打开它们的应用程序.我想将图标与文件类型相关联,以表示它们是自定义的.

I have written preview handlers for a couple custom file types. These file types don't have an application by default that can open them. I want to associate an icon with the file types as a signifier that they are custom.

我尝试在 HKCR \.< filetype> 中为 DefaultIcon 设置注册表项,但是即使重新启动后,它似乎也不起作用.我从C#进行了这些注册表修改,修改成功.

I have tried setting a registry entry for DefaultIcon in HKCR\.<filetype>, but it doesnt appear to work, even after reboots. I do these registry modifications from C#, and the modifications are successful.

图标文件只是暂时位于%APPDATA%中的ico文件.我计划添加更多图标,并将它们放在dll文件中.我只是想让它正常工作,然后再执行后续步骤.

The icon file is simply an ico file residing in %APPDATA% for the moment. I plan to add a few more icons, and put these in a dll file. I just want to get it to work before I take those next steps.

如何设置此图标?

推荐答案

这是一个简单的.REG文件,为文件扩展名.tj注册了一个图标

Here is a simple .REG file that registers a icon for the file extension .tj

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.tj]

[HKEY_CLASSES_ROOT\.tj\DefaultIcon]
@="D:\\scratch\\testy\\icons\\tj.ico"

在Win7上测试

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

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