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.

    • I Cast Fist@programming.devOP
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      2
      ·
      1 year ago

      I don’t want a shortcut, I want the binary with a different icon. Programs compiled “from scratch” don’t have an icon and a shortcut is useless when a separate person downloads the binary in “the wrong folder”.

      • FishInABarrel@kbin.social
        link
        fedilink
        arrow-up
        10
        ·
        1 year ago

        Programs compiled “from scratch” don’t have an icon…

        As someone that wrote Windows applications for a living, that’s wrong. You just have to add a resource file and your icon.

      • Lmaydev@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        You add the icon to resource file when compiling don’t you?

        I don’t remember it being much of a chore. But it’s been a while since I created a desktop app.

        I’m fairly sure Linux requires a separate file to specify the icon as well doesn’t it?

  • YaBoyMax@programming.dev
    link
    fedilink
    English
    arrow-up
    12
    ·
    1 year ago

    The PE format used by Windows stores icons in the binary itself, so modifying them is extremely nontrivial. Compare that to Linux environments, where the icon is typically specified within a .desktop file which is literally just a text file and points to an executable and a separate image file somewhere else on the disk.

    As the other commmenter mentioned though, you can do something similar to this on Windows by just adding a shortcut as a level of indirection to the actual program in much the same way as a .desktop file.

  • Muddybulldog@mylemmy.win
    link
    fedilink
    English
    arrow-up
    9
    ·
    1 year ago

    It’s not that they make it hard, it’s that it’s inherently hard because of the way resources are stored and managed within the binary.

    • I Cast Fist@programming.devOP
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      1 year ago

      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.

      • RonSijm@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        edit-2
        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

      • FishInABarrel@kbin.social
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        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.

      • WhoRoger@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 year ago

        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.

        • I Cast Fist@programming.devOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          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

  • o11c@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    There’s probably a way to do “specify icon as part of the linker call” which should be easier.