Python win32api提取exe图标icon
转载地址: http://blog.csdn.net/gumanren/article/details/6129416
代码如下:
# -*- coding: utf-8 -*-
import sys
import win32ui
import win32gui
from PyQt4 import QtCore
from PyQt4 import QtGui
class testWindow(QtGui.QMainWindow):
def __init__(self):
super(testWindow, self).__init__()
self.setGeometry(180.0, 130.0, 280.0, 200.0)
self.setMouseTracking(True)
large, small = win32gui.ExtractIconEx(r"netbeans.exe", 0)
win32gui.DestroyIcon(small[0])
self.pixmap = QtGui.QPixmap.fromWinHBITMAP(self.bitmapFromHIcon(large[0]), 2) self.pixmap.save("a.ico","ico") def bitmapFromHIcon(self, hIcon):
hdc = win32ui.CreateDCFromHandle(win32gui.GetDC(0))
hbmp = win32ui.CreateBitmap()
hbmp.CreateCompatibleBitmap(hdc, 32, 32)
hdc = hdc.CreateCompatibleDC()
hdc.SelectObject(hbmp)
hdc.DrawIcon((0, 0), hIcon)
hdc.DeleteDC()
return hbmp.GetHandle()
# paintevent事件
def paintEvent(self, event):
# palette 调色板多个pix显示,
painter = QtGui.QPainter()
palette = QtGui.QPalette()
palette.setBrush(self.backgroundRole(), QtGui.QBrush(QtGui.QPixmap(self.pixmap))) # 设置背景图片
self.setPalette(palette)
#painter绘图类只显示一个
#painter.begin(self)
#painter.setRenderHint(QtGui.QPainter.Antialiasing)
#painter.setPen(QtCore.Qt.NoPen)
#painter.setBrush(QtGui.QBrush(QtGui.QColor(255.0, 255.0, 255.0, 255.0), QtCore.Qt.SolidPattern))
#painter.drawRect(QtCore.QRect(0.0, 0.0, 280.0, 400.0))
#painter.drawPixmap(QtCore.QRect(0.0, 0.0, 32.0, 32.0), self.pixmap)
#painter.end()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mainWindow = testWindow()
mainWindow.show()
app.exec_()
显示效果:



Python win32api提取exe图标icon的更多相关文章
- Delphi提取EXE,DLL文件图标
//uses ShellAPIprocedure TForm1.Button1Click(Sender: TObject);var IconIndex:Word; h:hICON;begin Icon ...
- Python 获取 exe 的 icon 并且保存
Python 获取 exe 的 icon 并且保存 参考链接:https://mail.python.org/pipermail/python-win32/2009-April/009078.html ...
- delphi编写提取exe文件的ICO图标
http://www.duote.com/tech/4/11797.html delphi编写提取exe文件的ICO图标 7.0分 出处:天下网吧 时间:2011-08-05 人气:2390 核心提示 ...
- [工具-001]C++更换EXE的ICON图标
我们都知道每个可执行文件EXE都会有自己的图标,它可以在项目生成的时候进行指认,但是有时候我们会遇到两种情况:1.没有源代码,2.我们的项目很多,一个个进行更换很耗时.本人就是因为接到这么一个需求,要 ...
- 关于python打包成exe的一点经验之谈
我经常用python写些脚本什么的,有时候脚本写完以后,每次运行都得在IDE打开在运行,很麻烦,所以经常将python编译成exe.SO...有了一点经验,在这和大家分享一下. python ...
- python:打包成exe程序
1.需要安装 py2exe 2.示例代码: #exetest.py #创建一个gui界面,只用一个标签和按钮,无功能 from Tkinter import * win = Tk() label = ...
- 使用pyinstaller将Python打包为exe文件
当我们完成一个Python项目或一个程序时,希望将Python的py文件打包成在Windows系统下直接可以运行的exe程序,那么pyInstaller就是一个很好的选择.pyInstaller可以将 ...
- Python打包成exe可执行文件
Python打包成exe可执行文件 安装pyinstaller pyinstaller打包机制 Pyinstaller打包exe 总结命令 可能会碰到的一些常见问题 我们开发的脚本一般都会用到一些第三 ...
- 强行替换exe图标的方法
说句实话,要想用普通的方法来替换图标,不是完全不可行,当然也不是完全可行.这个看似简单的问题并不是想象中那么容易解决,为什么有人修改exe的图标总是失败,其实他忽视了exe和图标的复杂性,用简单的方法 ...
随机推荐
- 百度网盘爬虫Python
": for i in range((shares["total_count"]-1)/ONESHAREPAGE): try: dbcurr.execute('INSER ...
- 51Nod 1250 排列与交换
Description 统计 \(1...n\) 的排列,恰好进行 \(k\) 次相邻交换和至多进行 \(k\) 次交换生成的不同的序列个数. Sol DP. 好妙的题啊... 首先看第一个问题. 对 ...
- linux下编译qt5.6.0静态库——configure配置
linux下编译qt5.6.0静态库 linux下编译qt5.6.0静态库 configure生成makefile 安装选项 Configure选项 第三方库: 附加选项: QNX/Blackberr ...
- git 忽略文件权限
git config --add core.filemode false 发现.git/config 中新增了一行: [core] ... filemode = false ref: http://b ...
- Oracl各个版本的下载地址
http://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/112010-win32soft-098630-z ...
- ajax调用aspx.cs中的WebMethod
前台: <script language="javascript" src="../js/jquery-1.8.2.js"></script& ...
- python to be linux daemon
所需第三方库:python-daemon[https://pypi.python.org/pypi/python-daemon/] 使用方式: python linux_service.py star ...
- hdu 5442 (ACM-ICPC2015长春网络赛F题)
题意:给出一个字符串,长度是2*10^4.将它首尾相接形成环,并在环上找一个起始点顺时针或逆时针走一圈,求字典序最大的走法,如果有多个答案则找起始点最小的,若起始点也相同则选择顺时针. 分析:后缀数组 ...
- angular.js初探
2015年7月27日 22:26:35 星期一 用在我论坛里的小栗子: 先列出来一级回帖, 点击帖子前边的"查看回复"按钮无刷新的去请求该帖子的所有回复 首先要引用js文件, 我这 ...
- springMVC配置文件位置及名称
在web.xml文件内配置springMVC的DispatcherServlet的那个servlet内添加 <servlet> <servlet-name>mvc</se ...