Embedding icon in .exe with py2exe, visible in Vista?

后端 未结 4 1555
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 23:55

I\'ve been trying to embed an icon (.ico) into my \"compyled\" .exe with py2exe.

Py2Exe does have a way to embed an icon:

windows=[{
    \'script\':\'MyS         


        
4条回答
  •  既然无缘
    2021-01-31 00:31

    I was having problems with embedding the icon resource with py2exe on Windows7 using a .ico file containing a 32x32 pixel image. I was using the same method as the original question.

    Once compiled the icon on the exe disappears. On investigation the icon is added at index 0, according to the Resource Hacker tool, but if I use the same tool to replace the icon it is added at index 1. Once at index 1 the icon magically appears in explorer against the exe again.

    If desperate, you could use Resource Hacker to amend the exe post-build and it can be scripted via the command line interface but I tried the method explained above and managed to get it to work after reversing the png files like so.

    png2ico.exe myico.ico myico248x248.png myico48x48.png myico32x32.png myico16x16.png
    

    By the way by adding multiple icons to the ico file you are then populating the resource at icon index 1 anyway, in this case myico248x248.png.

提交回复
热议问题