Where is a .net Application Icon Stored?

前端 未结 3 1738
庸人自扰
庸人自扰 2021-01-14 08:43

I\'m trying to figure out where my application\'s icon is stored in VS 2008. On the startup project\'s application properties, I added an icon with the setting \"Embed manif

3条回答
  •  粉色の甜心
    2021-01-14 08:47

    It is stored in the unmanaged resource section of an executable. You can see that section with File + Open + File and selecting the DLL or EXE. Open the Icon node. The lowest numbered resource is the one that Windows picks as the application icon.

    There's spotty support in the .NET framework for accessing the unmanaged resources of a binary. Your best bet here is to use Icon.ExtractAssociatedIcon() but you cannot control which of the images in the icon you'll get. The pinvoke fallback is LoadImage() but it is difficult to use. By far the best approach is to also make the icon available in your managed resources.

提交回复
热议问题