this post was submitted on 25 Aug 2023
19 points (88.0% liked)

No Stupid Questions (Developer Edition)

936 readers
1 users here now

This is a place where you can ask any programming / topic related to the instance questions you want!

For a more general version of this concept check out [email protected]

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

I'm aware this has been the case since Windows 3.x, you always need an external program to ensure the executable is created with the icon you want. Why?

Please no mentions of Linux and other OSs, I know it's trivial to do so for them.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 1 year ago (2 children)

I'm curious why does one need to change the icon of an existing binary.

[–] [email protected] 3 points 1 year ago (1 children)

You'll like the binary you were given or else!

[–] [email protected] 2 points 1 year ago

Well as long as it's not open source... Yes, you kinda get what you get.

[–] [email protected] 1 points 1 year ago (3 children)

Windows exporting with Godot. If you export it "wrong" once, you have to change the generated exe name, or windows will refuse to use the new icon. I also need something in case I make everything "from scratch", like just compiling something from the command line.

[–] [email protected] 6 points 1 year ago* (last edited 1 year ago)

What /u/[email protected] mentioned - that's correct. But to elaborate: The icon image isn't simply stored as an image, but kinda complex (out of scope to explain the whole concept, but you can read more about it here

What windows does the first time it comes across a new .exe, is extract the image, because this is an "expensive" process, it's optimized to not do this every time, and instead the extracted image is dumped into C:\Users\%username%\AppData\Local\Microsoft\Windows\Explorer in one of the iconcache.db files.

When you recompile an exe with the same name but will a new icon, it will actually have a new icon, it's just not shown, because the old icon is retrieved from the iconcache.db. You can get around this by deleting all your iconcache.db files

I also need something in case I make everything "from scratch", like just compiling something from the command line.

Also, even if you compile from the console, you can usually still specify an icon on compile time, and don't really have to inject it later after compiling. But of course that depends on the language / compiler on how you'd have to do that

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

If you export it “wrong” once, you have to change the generated exe name, or windows will refuse to use the new icon.

Sounds like you just need to clear the icon cache. It's been a minute since I've written Windows apps, so I don't remember that process, but I'm sure google could help you out.

[–] [email protected] 3 points 1 year ago (1 children)

Yea mate, that's a cache problem of the local system... You should've just asked that question in the first place.

Btw I don't know how this works on newer Windows (probably worse), but on older versions you just needed to view the properties of the exe to view its actual icon, and refresh the desktop or explorer window. On even older Windows 9x, my trick was to switch from 32b to 16b color bit depth and back to refresh the icons.

[–] [email protected] 1 points 1 year ago

You should’ve just asked that question in the first place.

I know a few ways to change, I just wanted to know why Windows specifically has the most asinine way to do it