开发者

How can I add a custome icon to executables created with IronPython pyc.py?

Is there a way to add a custom icon to an .exe file generated from IronP开发者_如何学运维ython using pyc.py or programmaticly?


There appears to be several ways to accomplish this, however none are as easy as having a commandline switch like for C# code.

  • Generate the exe using pyc.py. Modify the generated exe with an icon editor

  • Modify pyc.py to add a call to DefineUnmanagedResource (insert at line 83, just before ab.save)

ab.DefineUnmanagedResource(r"D:\tmp\app.res")

Now you have to convert your .ico file into a .res file using RC. From [The SharpDevelop Forums][1]

Create a Resource file (.rc) containing the icons you want to embed as resources, for example:

#define ICO_APP        128
#define ICO_DVD        129
#define ICO_SVR        130
#define ICO_SIM        131

ICO_APP  ICON "App.ico"
ICO_DVD  ICON "dvd-database.ico"
ICO_SVR  ICON "ScreenSaver.ico"
ICO_SIM  ICON "SimpSvr.ico"

Compile the .rc file into a .res file using Microsoft's Resource Compiler Rc.exe, which is part of Microsoft's Platform SDK. Note that the lowest icon ID number in the .rc file (e.g. 128 above) will automatically become the application's icon.

  • Follow the steps outlined in this [C# question][2] which makes use of BeginUpdateResource(), UpdateResource() and EndUpdateResource() calls in kernel32.dll.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜