Vista 如何为与我的应用程序关联的文档生成图标?
我可以影响这个过程吗?
我有一个在 .NET 3.5 / VS2008 中构建的应用程序。 我已使用 win32 .res 文件将多个图标嵌入到应用程序中。 这是在 VS2008 中项目的“属性”框中完成的 - 不指定 .ico 文件,而是勾选该框以指定 .res 文件。 在 .res 文件中,您可以有多个图标。 请参阅此处了解我的意思。
每个图标都包含一个 256x256xRGB (PNG Cmopressed)“Vista 级”图像、一个 256x256x32 位图像以及各种颜色组合的常见级联 48x48、32x32 和 16x16 图像。 如果我在资源管理器中查看生成的 exe,我会看到美丽的 256x256 Vista 图像。
然后,我可以使用右键单击 > 将文件扩展名关联到我的应用程序。 “打开方式...”> 在 Vista 的资源管理器中设置默认程序点击流。 但文档旁边显示的图标是应用程序图标的小版本,覆盖在看起来像一张折角的白纸上。
结果是,当以“小图标”版本显示时,原始图像太小而无法看见。 看起来很糟糕。
我知道可以完全省略折叠的纸,或者至少可以在其上叠加更大的图像。 例如,C# 文件的图标有一张折叠的纸,但 C# 标志很大且可见。 我怎样才能得到这个? 安装 WinZip 12 后,.zip 文件的图标很大且可见,并且没有折叠纸。
文档图标与应用程序图标不同吗? 我的应用程序中是否需要执行某些操作才能注册 Vista 将用于与我的应用程序关联的文档的图标?
Can I affect the process?
I have an application built in .NET 3.5 / VS2008. I have embedded multiple icons into the app with a win32 .res file. This is done in the Properties box for the Project in VS2008 - instead of specifying an .ico file, tick the box to specify a .res file. In the .res file you can have multiple icons. See here for what I mean.
Each icon includes a 256x256xRGB (PNG Cmopressed) "Vista grade" image, a 256x256x32bit image, and the usual cascade of 48x48, 32x32, and 16x16 images in various color combos.
If I view the resulting exe in Explorer, I see the big beautiful 256x256 Vista images.
I can then associate a file extension to my app, using the right click > "Open With..." > Set Default Program clickstream in Vista's Explorer. But the icon displayed next to the document is then a small version of the app icon, overlayed on top of what looks like a white sheet of paper with a folded corner.
The result is that the original image is waaaay to small to be visible, when it is shown in "small icon" version. It looks terrible.
I know it is possible to completely omit the folded piece of paper, or at least to get a much larger image overlayed on it. The icon for a C# file, for example, has a folded sheet of paper, but the C# emblem is large and visible. How can I get this? The icon for .zip files when WinZip 12 is installed, is large and visible, and has no folded sheet of paper.
Is the icon-for-documents different than the icon-for-the-application? Is there something in my app that I have to do in order to register an Icon that Vista will use for documents associated to my app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件扩展名的图标和文件关联在注册表中列出。 更具体地说,
HKEY_CLASSES_ROOT\.ext
条目包含内容类型、感知类型,而(Default)
值是实际关联。 例如,.cs 文件的默认值为VisualStudio.cs.9.0
(我有 VS 2008)。 您可以检查HKEY_CLASSES_ROOT\VisualStudio.cs.9.0
以查看与此文件类型关联的实际图标、程序和命令。 特别是,HKEY_CLASSES_ROOT\VisualStudio.cs.9.0\DefaultIcon
是告诉资源管理器对该类型的文件显示哪个图标的条目。 它指向一个二进制文件和该二进制文件中的资源 ID。当您通过右键单击->将文件类型与程序关联起来时 打开方式...,您没有指定默认图标,因此资源管理器会采用您的应用程序的图标并将其覆盖在通用文档图标上。
正确的方法是在设置中包含适当的注册表项,以将文件类型与应用程序和图标相关联。 您需要包含的确切注册表值取决于您想要添加到该文件类型的上下文菜单中的命令,但至少您需要“打开”命令。 对于 .cs 文件,您可以看到有一个条目
HKEY_CLASSES_ROOT\VisualStudio.cs.9.0\Shell\Commands\Open
,其(Default)
值包含当调用 Open 命令时启动应用程序。 (您现在可以忽略ddeexec
部分)请记住,
HKEY_CLASSES_ROOT
是两个注册表分支的映射视图:HKEY_CURRENT_USER\Software\Classes
> 和HKEY_LOCAL_MACHINE\Software\Classes
。 如果您希望文件关联适用于所有用户,则需要写入HKEY_LOCAL_MACHINE
。 您的设置需要以管理员身份运行才能执行此操作。 否则,尝试写入HKEY_CLASSES_ROOT
将失败并拒绝访问,或者写入HKEY_CURRENT_USER
并仅对当前用户进行关联。 (这两者中的哪一个到底会发生取决于几个因素,例如操作系统是什么,用户是否是管理员但未提升权限等等)您可以在 自定义文件类型(文件关联) MSDN 上的部分。 特别是,文件类型和向客户端程序注册程序将为您提供有关如何准确地进行操作的基础知识做这个。
The icons and file associations for file extensions are listed in the registry. More specifically,
HKEY_CLASSES_ROOT\.ext
entries contain the content type, perceived type and in the(Default)
value is the actual association. For example, .cs files have default value ofVisualStudio.cs.9.0
(I've got VS 2008). You can check theHKEY_CLASSES_ROOT\VisualStudio.cs.9.0
to see the actual icon, program and commands associated with this file type. In particular, theHKEY_CLASSES_ROOT\VisualStudio.cs.9.0\DefaultIcon
is the entry that tells Explorer which icon to show for files of this type. It points to a binary and a resource ID in that binary.When you associate a file type with a program through the right click -> Open With..., you don't specify a default icon, so Explorer takes the icon of your app and overlays it over a generic document icon.
The right approach would be to include as part of your setup the appropriate registry entries to associate the file type with your application and your icon. The exact registry values you need to include depend on the commands you want added to the context menu for that file type, but at the very least you want the Open command. In the case of .cs files, you can see that there is an entry
HKEY_CLASSES_ROOT\VisualStudio.cs.9.0\Shell\Commands\Open
with(Default)
value containing the application to start when the Open command is invoked. (You can ignore theddeexec
part for now)Keep in mind that the
HKEY_CLASSES_ROOT
is a mapped view of two registry branches:HKEY_CURRENT_USER\Software\Classes
andHKEY_LOCAL_MACHINE\Software\Classes
. If you want your file association to be for all users, you need to write toHKEY_LOCAL_MACHINE
. Your setup needs to run as admin to do that. Otherwise, attempting to write toHKEY_CLASSES_ROOT
will either fail with access denied or write toHKEY_CURRENT_USER
and do the association only for the current user. (Which of the two exactly will happen depends on several things, like what the OS is, whether the user is admin but not elevated and so on)You can read about all this in Customizing File Types (Files Associations) section on MSDN. In particular, File Types and Registering Programs with Client Programs would give you the basics of how exactly to do this.