我试图用win32gui从windows的.exe文件中提取图标。我找到了ExtractIconEx()和ExtractIcon()的功能。在
我只能从上述功能得到32x32或16x16大小的图标。下面的链接只回答了提取32x32图像的方法。
How to extract 32x32 icon bitmap data from EXE and convert it into a PIL Image object?
我需要提取大小为128x128或更大的图标那个。任何关于如何从exe文件中提取大尺寸图标的想法?在
Tags:
我想提取默认图标和不同的大小。基于32x32线程中Alexei的答案和Audionautics的答案,下面是代码。在
我做了一些研究,也贴出来了。如果你想看到结果代码(我希望它正是你所要求的),你可以在下面的“水平规则”之后找到它。在
首先,我尝试使用下一个代码来确定文件资源中存储的图标大小:
虽然文件只包含16x16和32x32像素的图标,但一切都会正常,下面是Windows XP calculator的输出:
^{pr2}$一旦我尝试了使用大图标的文件,我得到了一个例外:
经过一些研究,我发现大图标不是以
ico
格式存储的,而是以png
格式存储的(对于我的例子)。在当然,我不知道你的
< >从资源中读取图像,我使用了C++上的guide。这里的主要目标是获取指向图像资源真实数据的指针,并将其复制到Python缓冲区。最后一步是把它保存到文件中(我想你可以自己把它翻译成PIL)。在.exe
文件到底是什么(它的内部结构),但是在我分析了我在我的电脑里找到的几个.exe
文件后,我发现大于32x32或16x16像素的图标最有可能是通过.png
文件来表示的(你可以使用PE Explorer,试用版已经存在)。在完成读取大量资源的代码:
更新:
自动查找非图标资源并将其提取到名为“Resource_XX”的文件的代码:
相关问题 更多 >
编程相关推荐