0

I am trying to set a value in windows registry of my application. The executable path works fine by just adding the path but when i load it the icon of this application cannot be seen in windows programs. How can i retrieve correctly the icon from my application and use it as icon path in the registry ?

Do i need to set something inside my application so the registry can see the icon ?

key reg for shell-open-command "C:\myapp\test.exe" "%1" but for the key reg Default Icon "" do i need to use a regural .ico file near the exe or could i get also from the executable`s .exe file the ico i use from inside the application ?

I would like to avoid using .ico file so if it can be done by taking the executable`s file icon would be nice.

A good example to understand cause its not a duplicate is the torrent magnet links.

Check magnet->shell->open->command

and magnet->DefaultIcon

in system registry

Any help is much appreciated

Vas
  • 75
  • 9
  • You can retrieve the exe icon handle by utilizing the [ExtractIcon](https://msdn.microsoft.com/en-us/library/windows/desktop/ms648068(v=vs.85).aspx) function. Not sure what you are trying to achieve. Icons are part of the exe. The icon can be changed via project's resource section prior to compiling. It's all array of bytes once the executable is produced. See the `CreateWindow` function. – Ron Feb 17 '18 at 14:19
  • Possible duplicate of [Set an exe icon for my program](https://stackoverflow.com/questions/2393863/set-an-exe-icon-for-my-program) – Ivan Aksamentov - Drop Feb 17 '18 at 14:22
  • Which registry key are you trying to set? Different keys expect icon location in different formats. For example setting executable path as `DisplayIcon` value in `Uninstall` section will make main application icon be displayed in the list of installed applications. – user7860670 Feb 17 '18 at 14:25
  • My applicaiton`s icon is ok ... it can be seen in taskbar or tray or anything i like.I want to be able to use the same icon as the executable has to system that uses to open the application from path like for example a magnet torrent link. When it pops up the windows dialog, the path to the executable and the name of the application is showing and running ok, but the icon of the application is not showing at all. – Vas Feb 17 '18 at 14:46

1 Answers1

1

The key value should be full path, followed by icon index.

For example DefaultIcon -> path.exe,-123 Here path.exe is expected to have an icon whose resource ID is 123

HKEY_CURRENT_USER\Software\Classes\.txt -> myapp

Create myapp and add subkey DefaultIcon

HKEY_CURRENT_USER\Software\Classes\myapp\DefaultIcon -> path.exe,-123
HKEY_CURRENT_USER\Software\Classes\myapp\shell\open\command -> "path.exe" /open "%1"
Barmak Shemirani
  • 30,904
  • 6
  • 40
  • 77
  • Thank you for the reply, i am on my way to test it. – Vas Feb 17 '18 at 21:36
  • Yes indeed Barmak, it took me a while though cause i had some issues with the registry but all good. Thank you – Vas Feb 18 '18 at 00:24