Vas
Vas

Reputation: 85

c++ retrieve executable`s icon for use in windows registry icon path?

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

Upvotes: 0

Views: 1032

Answers (1)

Barmak Shemirani
Barmak Shemirani

Reputation: 31599

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"

Upvotes: 1

Related Questions