From 952f5b11ef4cec829e046a446216529670e774ad Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Wed, 28 Oct 2020 03:31:45 -0700 Subject: [PATCH] Shell extension: Use WT's icon as our icon (#8068) This is cheaper than storing another icon in another resource fork. Eventually, we could support high contrast just by varying the icon ID. Fixes #6246. Looks pretty good, too. ![image](https://user-images.githubusercontent.com/189190/97379930-38f08000-1883-11eb-8d37-a7741ea55b29.png) (cherry picked from commit e21f9f5ac62f33421e88d46e83bb7731efd24c8b) --- src/cascadia/ShellExtension/OpenTerminalHere.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cascadia/ShellExtension/OpenTerminalHere.cpp b/src/cascadia/ShellExtension/OpenTerminalHere.cpp index 8091754832c..d5669e21f63 100644 --- a/src/cascadia/ShellExtension/OpenTerminalHere.cpp +++ b/src/cascadia/ShellExtension/OpenTerminalHere.cpp @@ -185,12 +185,17 @@ HRESULT OpenTerminalHere::GetState(IShellItemArray* /*psiItemArray*/, HRESULT OpenTerminalHere::GetIcon(IShellItemArray* /*psiItemArray*/, LPWSTR* ppszIcon) +try { - // the icon ref ("dll,-") is provided here, in this case none is provided - *ppszIcon = nullptr; - // TODO GH#6111: Return the Terminal icon here - return E_NOTIMPL; + std::filesystem::path modulePath{ wil::GetModuleFileNameW(wil::GetModuleInstanceHandle()) }; + modulePath.replace_filename(WindowsTerminalExe); + // WindowsTerminal.exe,-101 will be the first icon group in WT + // We're using WindowsTerminal here explicitly, and not wt (from _getExePath), because + // WindowsTerminal is the only one built with the right icons. + const auto resource{ modulePath.wstring() + L",-101" }; + return SHStrDupW(resource.c_str(), ppszIcon); } +CATCH_RETURN(); HRESULT OpenTerminalHere::GetFlags(EXPCMDFLAGS* pFlags) {