Showing an App Icon for 64-bit Windows Apps

Published December 15, 2015 by
Paul Lefebvre

Update Aug 2017: Starting with Xojo 2017 Release 2 your app icons are automatically included in 64-bit Windows apps without having to do the workarounds described in this post. Upgrade today! If you are still using older versions of Xojo, then these workarounds are still necessary.

Xojo 2015 Release 3 added the ability to create 64-bit apps for OS X, Windows and Linux. This is still considered a “beta” feature because there are a few things that still need to be added. One of those things is the ability to specify the app icon for 64-bit Windows apps.

Until that is available, you can work around it by setting the app icon at run-time (so it shows correctly in the Task Bar) and by having the installer set the icon for the app shortcut so it appears in the Start menu or on the desktop.

Thanks to Jim Cramer and Michele Bujardet for putting together the Declare code to set the app icon at run-time. To use this, you need to have your app icon in ICO format. Then use a Copy Files Build Script to copy it to the Resources folder. Your app then gets a FolderItem to the app icon and call the SetApplicationIcon method to set it.

This code gets the icon file and calls the SetApplicationIcon method to set it to your icon file (replace “XojoLogo.ico” with your own file of course):

#If TargetWin32 Then
// The Icon is copied to the Resoures folder
// in a Copy Files Build Step.
// Get a Reference to it.
// The file must be an ICO file, not PNG or JPG.
Dim resourceFolderName As String
resourceFolderName = App.ExecutableFile.Name + " Resources"
resourceFolderName = resourceFolderName.Replace(".exe", "")
Dim f As FolderItem = App.ExecutableFile.Parent.Child(resourceFolderName).Child("XojoLogo.ico")
Self.SetApplicationIcon(f)
#Endif

This is the code for SetApplicationIcon, which you would add to a module since it is implemented as an extension method for the Window class:

This Declare works for both 32-bit and 64-bit apps, so you can test that everything is working properly before you build as 64-bit.

The next step is to create your installer so that it uses the app icon for the Start menu and Desktop shortcuts that it creates. With InnoSetup, you just have to add this command to the items in the [Icons] section:

IconFilename: "{app}AppIconTest ResourcesXojoLogo.ico"

Of course, you’ll need to specify the appropriate path and filename in your own InnoSetup script. Lastly, to ensure your app gets installed as a 64-bit app and placed into “Program Files” (instead of “Program Files (x86)”), then also add this setting to the [Setup] section: