Support exe/dll paths in the 'icon' setting #2039

Closed
opened 2026-01-30 22:45:14 +00:00 by claunia · 9 comments
Owner

Originally created by @fpintos on GitHub (Jun 24, 2019).

Originally assigned to: @zadjii-msft on GitHub.

Support exe/icon paths in the 'icon' setting of a profile

The icon setting of a profile should allow the path to an EXE or DLL to be specified, along with an optional ID for an icon resource in the file.

For example, I should be able to create a profile using icons from SHELL32:

    ...
    "icon": "c:\Windows\System32\SHELL32.dll,210",
    ...

Optionally, if the icon is missing and the executable from the command line has icons, pick the default icon, much like how the shell does.

Originally created by @fpintos on GitHub (Jun 24, 2019). Originally assigned to: @zadjii-msft on GitHub. # Support exe/icon paths in the 'icon' setting of a profile The icon setting of a profile should allow the path to an EXE or DLL to be specified, along with an optional ID for an icon resource in the file. For example, I should be able to create a profile using icons from SHELL32: ``` ... "icon": "c:\Windows\System32\SHELL32.dll,210", ... ``` Optionally, if the icon is missing and the executable from the command line has icons, pick the default icon, much like how the shell does.
Author
Owner

@Karl-WE commented on GitHub (Jun 25, 2019):

I agree. or things like "icon": "C:\Program Files\PowerShell\6-preview\pwsh.exe",

@Karl-WE commented on GitHub (Jun 25, 2019): I agree. or things like "icon": "C:\Program Files\PowerShell\6-preview\pwsh.exe",
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 27, 2019):

Yeah, it would be pretty cool if we did this.

@DHowett-MSFT commented on GitHub (Jun 27, 2019): Yeah, it would be pretty cool if we did this.
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 27, 2019):

Notes: Right now we're using the XAML resource loader to get at our icons. If we want to support EXE/other PE resources we'll need to fall back to a more win32-like resource loader. There are real benefits to the XAML one, such as it choosing the right icon scale and supporting vector graphics and stuff like that. I've tagged it help-wanted.

@DHowett-MSFT commented on GitHub (Jun 27, 2019): Notes: Right now we're using the XAML resource loader to get at our icons. If we want to support EXE/other PE resources we'll need to fall back to a more win32-like resource loader. There are real benefits to the XAML one, such as _it choosing the right icon scale_ and supporting vector graphics and stuff like that. I've tagged it `help-wanted`.
Author
Owner

@Karl-WE commented on GitHub (Jun 29, 2019):

@DHowett-MSFT afaik not even the settings app in Windows uses SVG graphics but PNGs. I stumbled across them once. I see the point of having this more modern and getting rid of old ico restrictions.

@Karl-WE commented on GitHub (Jun 29, 2019): @DHowett-MSFT afaik not even the settings app in Windows uses SVG graphics but PNGs. I stumbled across them once. I see the point of having this more modern and getting rid of old ico restrictions.
Author
Owner

@zadjii-msft commented on GitHub (Feb 12, 2021):

This is highly related to #705 (but definitely different)

@zadjii-msft commented on GitHub (Feb 12, 2021): This is highly related to #705 (but definitely different)
Author
Owner

@gim913 commented on GitHub (Apr 20, 2021):

Notes: (…) There are real benefits to the XAML one, such as it choosing the right icon scale and supporting vector graphics and stuff like that. I've tagged it help-wanted.

Just FYI: technically single icon inside PE resources can contain multiple icons (with various color depths, sizes - up to 256x256 etc.), that is how you could have same but actually different icon for title bar and for application itself. (that is, smaller one was used for title bar).

ofc, afaik vector graphics is/was not an option.

@gim913 commented on GitHub (Apr 20, 2021): > Notes: (…) There are real benefits to the XAML one, such as _it choosing the right icon scale_ and supporting vector graphics and stuff like that. I've tagged it `help-wanted`. Just FYI: technically single icon inside PE resources can contain multiple icons (with various color depths, sizes - up to 256x256 etc.), that is how you could have same but actually different icon for title bar and for application itself. (that is, smaller one was used for title bar). ofc, afaik vector graphics is/was not an option.
Author
Owner

@zadjii-msft commented on GitHub (May 24, 2022):

Notes from some tabs I had open for the last few weeks:

Still not sure if that connects up to a BitmapImage. Maybe I should look in the BitmapImage source itself - it can apparently read from .ico files, so there's probably some overlap between reading an .ico and reading an HICON.

More notes:

  • Window::s_RegisterWindowClass is where we set the HICON for the console window.
  • This is unpacked in Icon::GetIcons, after a call to:
  • Icon::LoadIconsFromPath, in win32/SystemConfigurationProvider::GetSettingsFromLink (see also #11759)
    • first check: ShortcutSerialization::s_GetLinkValues
      • ShortcutSerialization::s_GetLoadedShellLinkForShortcut to load the IShellLink for the lnk
      • psl->GetIconLocation to load the icon from the IShellLink.
    • Then, we fall back to the title?
    • SystemConfigurationProvider::GetSettingsFromLink sets the icon GLOBALLY. It probably initializes other state. If we want to reuse that to pull the icon out of an lnk before handoff, the we should be SURE it's not setting any other magic global state. We can use a dummy console Settings to hold data if need be.
  • see 1dd6e9934
@zadjii-msft commented on GitHub (May 24, 2022): Notes from some tabs I had open for the last few weeks: * dotnet uses `System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon`, which obv we can't use. * https://github.com/dotnet/wpf/blob/89d172db0b7a192de720c6cfba5e28a1e7d46123/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/Imaging.cs#L77 * https://github.com/dotnet/wpf/blob/89d172db0b7a192de720c6cfba5e28a1e7d46123/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/InteropBitmapSource.cs#L91-L96 * [`IWICImagingFactory_CreateBitmapFromHICON_Proxy`](https://docs.microsoft.com/en-us/windows/win32/wic/-wic-codec-iwicimagingfactory-createbitmapfromhicon-proxy) * Data from that is accessed as in [`IWICBitmapLock::GetDataPointer`](https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicbitmaplock-getdatapointer) Still not sure if that connects up to a `BitmapImage`. Maybe I should look in the BitmapImage source itself - it can apparently read from `.ico` files, so there's probably some overlap between reading an `.ico` and reading an `HICON`. More notes: * `Window::s_RegisterWindowClass` is where we set the HICON for the console window. * This is unpacked in `Icon::GetIcons`, after a call to: * `Icon::LoadIconsFromPath`, in `win32/SystemConfigurationProvider::GetSettingsFromLink` (see also #11759) * first check: `ShortcutSerialization::s_GetLinkValues` * `ShortcutSerialization::s_GetLoadedShellLinkForShortcut` to load the `IShellLink` for the lnk * `psl->GetIconLocation` to load the icon from the `IShellLink`. * Then, we fall back to the title? * `SystemConfigurationProvider::GetSettingsFromLink` sets the icon GLOBALLY. It probably initializes other state. If we want to reuse that to pull the icon out of an lnk before handoff, the we should be SURE it's not setting any other magic global state. We can use a dummy console `Settings` to hold data if need be. * see 1dd6e9934
Author
Owner

@zadjii-msft commented on GitHub (Sep 9, 2022):

Note to self: dev/migrie/1504-prototype-2

@zadjii-msft commented on GitHub (Sep 9, 2022): Note to self: [`dev/migrie/1504-prototype-2`](https://github.com/microsoft/terminal/compare/dev/migrie/1504-prototype-2)
Author
Owner

@ghost commented on GitHub (Jan 24, 2023):

:tada:This issue was addressed in #14107, which has now been successfully released as Windows Terminal Preview v1.17.1023.🎉

Handy links:

@ghost commented on GitHub (Jan 24, 2023): :tada:This issue was addressed in #14107, which has now been successfully released as `Windows Terminal Preview v1.17.1023`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.17.1023) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2039