每个文件实例的自定义图标
某些 Windows 程序可以对具有相同扩展名的不同文件使用不同的图标。
示例
- .sln 可以显示不同的图标,具体取决于解决方案所用的 Visual Studio 版本(实际上,由 .sln 顶行中的版本号确定)
- Photoshop .psd 文件的图标带有图像
- A 的缩略图如果在 Internet Explorer 中打开或保存,.url 快捷方式文件包含页面的图标,
我猜测它必须仅针对该计算机进行自定义。 在未安装 Visual Studio 的机器上,.sln 文件仅具有默认的“我不知道该程序”图标。 注册表中是否有需要更改的内容?
我怎样才能做到这一点? 我希望能够选择将自定义图标与文件关联到我自己的程序。
[编辑] 我真的可以在托管代码中做到这一点。 这是可能的(
Some Windows programs can use different icons for different files with the same extension.
Example
- .sln can show a different icon depending on what version of Visual Studio the solution was made in (actually, determined by the version number in the top line in the .sln)
- Photoshop .psd files have icons with a thumbnail of the image
- A .url shortcut file has the page's favicon if opened in, or saved from, Internet Explorer
I'm guessing it must be custom to that computer only. On a box without Visual Studio installed, .sln files just have the default 'I don't know this program' icon. Is there something that needs to be changed in the registry?
How can I do this? I'd like to have the option of associating custom icons with files to my own programs.
[Edit] I really with I could do this in managed code. It's possible (<SDK v1.1>\Samples\Technologies\Interop\Applications\ShellCmd) but it also appears to be potentially dangerous and the wrong tool for the job in practice: http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/1428326d-7950-42b4-ad94-8e962124043e/. I really hoped MS would have a good managed API for this kind of stuff by now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看CodeProject 上的 C++ 代码:本质上,您编写一个 COM 处理程序并为您的扩展程序注册它。 请注意,如果您泄漏图标处理程序或 shell 扩展中的资源,您可能会严重搞乱资源管理器进程... C++ 可能是一个挑战,但出于内存消耗的原因,我不建议在 C# 或 Java 中执行此操作(每个扩展/处理程序的框架代码的单独副本!)。
Check out this C++ code on CodeProject: essentially, you write a COM handler and register it for your extension. Be aware that you can mess up the Explorer process pretty badly if you leak resources in icon handlers or shell extensions... C++ may be a challenge, but I wouldn't recommend doing this in C# or Java for reasons of memory consumption (a separate copy of the framework code for each extension/handler!).