With an eye toward extracting all of the sizes of an icon (ICO file) as PNG images from an EXE file, I noticed that Wine appears to do this automatically.

After the installation of foobar2000, Wine (I presume) had created a Desktop Entry at ~/.local/share/applications/wine/Programs/foobar2000.desktop, containing the following content:

[Desktop Entry]
Exec=env WINEPREFIX="$HOME/.wine" wine C:\\\\windows\\\\command\\\\start.exe /Unix "$HOME/.wine/dosdevices/c:/users/Public/Start\\ Menu/Programs/foobar2000.lnk"
Comment=Play, organize and tag your music.
Path=$HOME/.wine/dosdevices/c:/Program Files (x86)/foobar2000

Eventually, the Icon key caught my eye, and I discovered that it resolved according to the Icon Theme Specification. Hunting around, I found the directories ~/local/share/icons/hicolor/*/apps/ which contained the files for these icons (each folder containing 3C17_foobar2000.0.png), again which I presume Wine created.

My question is how did Wine generate these image files from the application (or shortcut file)?


1 Answer 1


Wine includes a winemenubuilder program which takes care of this: it takes a Windows shortcut, and creates a matching FDO (FreeDesktop.Org) .desktop file. Icon extraction is part of this, handled by the open_module_icon and related functions. To extract icons, winemenubuilder finds the executable corresponding to the shortcut (optionally waiting for it to be created, if necessary), and loads the resources it contains using Wine’s LoadResource function, finds the icons, and converts them to an appropriate image format.

wine winemenubuilder /path/to/link.lnk

will convert the link to a .desktop file, in ~/.local/share/applications/wine/Programs, and extract the available icons, convert them, and store them in the appropriate subdirectories of ~/.local/share/icons. (I think /path/to/link.lnk has to be accessible using Wine’s drive mappings; it works well with .lnk files which have been installed in Wine.)

wine winemenubuilder -t /path/to/link.lnk /path/to/icon.png

will extract the first icon in the executable pointed at by link.lnk to icon.png.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.