使用 VB.NET 更改程序图标
我正在 VB.NET 中创建一个文件管理器。我在应用程序的项目资源中包含了一些图标。我怎样才能让我的用户使用我包含在 VB.NET 中的图标来更改桌面上的文件、文档等的图标?
I'm creating a file manager in VB.NET. I included some icons in the project resources of my application. How can I make it possible for my users to change the icons of files on their desktop, documents, etc. with the icons I have included in VB.NET?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“有了上述基础设施,并支持所有资源中最复杂的版本资源结构,就可以将库扩展到其他两打已知资源类型之一。我们从图标开始。
扩展库支持图标意味着实现图标存储的数据结构并连接 ResourceInfo 回调。当 ResourceInfo 遇到类型 14 (RT_GROUP_ICON) 的资源时,它会创建一个 IconDirectoryResource 类型的对象,后者会加载一个 IconResource。 DeviceIndependentBitmap。
• IconDirectoryResource 代表RT_GROUP_ICON,图标资源的集合。
一个或多个图像的单个RT_ICON 图标。
• IconResource 代表带有 资源并表示 .bmp 格式的单个图标位图
为了将 .ico 文件中的现有图标嵌入到可执行文件(.exe 或 .dll)中。加载 .ico 文件并将其转换为 IconDirectoryResource。 .ico 文件中的结构与可执行文件中图标的结构类似。唯一的区别是可执行标头存储图标 ID,而 .ico 标头包含图标数据的偏移量。有关实现详细信息,请参阅 IconFile 和 IconFileIcon 类。将 IconDirectoryResource 写入目标文件,然后单独写入每个图标资源。请注意,当前的实现将替换可执行文件中具有相同 ID 的图标,但如果您存储的图标图像少于以前的数量,则不会删除旧图标 - 可能应该这样做,因为这些图标会成为孤立的。
将库扩展到图标的轻松性验证了我们最初的设计模型。”
摘自 Ranhiru Cooray 的链接,以便于查看。归功于他。
"With the above infrastructure in place and with support for the most complicated of all resources, version resource structures, it is possible to extend the library to one of the two dozen other known resource types. We've started with icons.
Extending the library to support icons means implementing the data structures for icon storage and hooking up ResourceInfo callbacks. When ResourceInfo encounters a resource of type 14 (RT_GROUP_ICON), it creates an object of type IconDirectoryResource. The latter creates an IconResource, which loads an DeviceIndependentBitmap.
•An IconDirectoryResource represents RT_GROUP_ICON, a collection of icon resources.
•An IconResource represents a single RT_ICON icon with one or more images.
•An DeviceIndependentBitmap is not a resource, but raw data embedded in the file at an offset defined by the icon resource and represents a single icon bitmap in a .bmp format.
In order to embed an existing icon from a .ico file into an executable (.exe or .dll), we load the .ico file and convert it to a IconDirectoryResource. The structure in a .ico file is similar to the structure of the icon in an executable. The only difference is that the executable headers store the icon ID, while a .ico header contains the offset of icon data. See IconFile and IconFileIcon classes for implementation details. The IconDirectoryResource is written to the target file, then each icon resource is written separately. Note that the current implementation would replace icons with the same Id in the executable, but doesn't delete old icons if you're storing less icon images than the previous number - it probably should since these icons become orphaned.
The ease of extending the library to icons validated our initial design model."
Taken from Ranhiru Cooray's link, for easier viewing purposes. Credit goes to him.