关于PE图标的继续讨论

来源:互联网 发布:网络故障修复软件 编辑:程序博客网 时间:2024/05/21 10:02
关于pe中图标资源的话题,经过这几天的简单研究与思考,我想终于可以做个小结了。下面这篇文章,已经将ico在windows中的使用和在exe,dll中的储存等信息说的比较透彻了。我e文不是很好,就不翻译了。大家如果以后做到这方面相关的课题,就自己来查吧。

 

在本回复中,仅引用其中很关键的一段:

choosing an icon
when windows prepares to display an icon, a desktop shortcut for example, it must parse the .exe or .dll file and extract the appropriate icon image. this selection is a two step process starting with the selection of the appropriate rt_group_icon resource, and ending with the selection of the proper rt_icon image from that rt_group_icon.

which icon?
if an .exe or .dll file has only one rt_group_icon resource, the first step is trivial; windows simply uses that resource. however, if more than one such group resource exists in the file, windows must decide which one to use. windows nt simply chooses the first resource listed in the application's rc script. on the other hand, windows 95's algorithm is to choose the alphabetically first named group icon if one exists. if one such group resource does not exist, windows chooses the icon with the numerically lowest identifier. so, to be sure that a particular icon is used for an application, the developer should insure that both of the following criteria are met:

the icon is placed before all other icons in the rc file.
if the icon is named, its name is alphabetically before any other named icon, otherwise its resource identifier is numerically smaller than any other icon.
which image?
once an rt_group_icon is chosen, the individual icon image, or rt_icon resource, must be selected and extracted. again, if there exists only one rt_icon resource for the group in question, the choice is trivial. however, if multiple images are present in the group, the following selection rules are applied:

the image closest in size to the requested size is chosen.
if two or more images of that size are present, the one that matches the color depth of the display is chosen.
if none exactly match the color depth of the display, windows chooses the image with the greatest color depth without exceeding the color depth of the display.
if all the size-matched images exceed the color depth of the display, the one with the lowest color depth is chosen.
windows treats all color depths of 8 or more bpp as equal. for example, it is pointless to have a 16x16 256 color image and a 16x16 16bpp image in the same resource--windows will simply choose the first one it encounters.
when the display is in 8bpp mode, windows will prefer a 16 color icon over a 256 color icon, and will display all icons using the system default palette.


原创粉丝点击