Good day!

I would like to learn how to change the program icon depending on the operating system ...
By type as a folder, I threw it onto a USB flash drive, and displayed under different OS in my own way ...
No idea how to program it before starting the program?

  • 6
    It did not occur to you that the folders are displayed in different ways, not because the manufacturer of the flash drive programmed them so, but because ... different OS icons have different folder icons?) - Nofate

3 answers 3

Of course, there is no simple solution, since your application when opening the folder with the explorer should automatically provide it with some icon that it will draw.

Accordingly, a simple way is to store any icon before the first launch, and after the first start patch your fragment .exe , where the icon resource is sewn up, replacing it with the necessary one.

A difficult way is to hang the global hook on the corresponding call to get the icon (ready to admit that it may have to be sniffed at the Native API level) and again, on the fly, patch the resource, demonstrating the icon you need. In this way, even for the first time, the icon will be displayed correctly.

In general, the task is interesting, but, naturally, no one in their right mind would be engaged in this :)

  • Yes, in his right mind would not be =) An interesting point about the resources ... Mat. some did not read about them, it was not possible. Perhaps you can send the OS for resources to another file? Maybe there is such a loophole in the PE (Portable Executable) model ... - mike_live
  • one
    >> The hard way is to hang the global hook on the corresponding call for getting the icon. How do you hang the global hook (and generally execute some code) before launching your application? Topikstarter should indicate that the appearance of files and folders depends only on the icons in the system libraries. The focus described below with a large 256x256 icon will work only when the Extra large icons folder view is selected. In other cases, a smaller icon will be substituted. - nitrocaster
  • one
    >> I'm wrong? You're wrong. Explorer does not ask your application what icon to take. - nitrocaster
  • one
    > A difficult way is to hang the global hook on the corresponding call to get the icon (I’m ready to assume that you may have to peek it at the Native API level) and again, on the fly, patch the resource, showing the icon you need. In this way, even for the first time, the icon will be displayed correctly. Govnokode numer 2. Should melkosoft release a patch, then everything using the Native API will break. On the other hand, experience shows that the Native API is actually quite stable. But still use it very dumb in the application software. - gecube
  • one
    > Many security packages (and rootkits :) rely on the stability of the Native API behavior. There, I think, damage will be more serious than an incorrectly displayed icon. Probably yes. > In general, if you solve such a problem in production, then the logic of choosing the icon should be sewn into the installer. I think the question itself is incorrect. We do not need to change the exe icon. And for practical tasks, you usually need to change the shortcut icon, which is in the start menu or on the desktop. But this problem is already solved much easier, because The icon for the label can always be set separately. - gecube

You can use the fact that the icon is looking for an explorer in the application resources. And for Vista / 7, large icons of 256 large by 256 are supported. And XP does not support them yet. Of course, this is a dirty hack, but on the other - just patch the conductor. But the user can log in with TotalCommander or another program and sailed ...

But the pictures of folders are displayed differently, because pictures for folders are not stored on a flash drive, but in system directories.

    I did not understand the question a bit, do I need to programmatically change icons like folder icons?

    If off the top, then I'm sorry.

    Application has a kind of Icon property - it’s kind of necessary to change it ...

    It has long been engaged in just ....

    • Of course. In the project properties, Application -> Icon. - Nofate