mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
Adds a parameter to `Toolkit.ThumbnailHelper.GetThumbnail` to retrieve the largest possible icon from the file. For most use cases, the normal icon size will be good for list items and page icons. But for details, you'll want to use the JUMBO icons, and to retrieve them, we need to get the icon from a different API. As a drive-by, I also have us fetching the highest-res app icon for UWP's rather than the lowest-res icon. Solves #38238 Screenshots: | before | after | | ------ | ----- | |  |  | |  |  |
37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
internal sealed class NativeMethods
|
|
{
|
|
[DllImport("shell32.dll", CharSet = CharSet.Unicode)]
|
|
internal static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags);
|
|
|
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
internal struct SHFILEINFO
|
|
{
|
|
#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
|
|
public IntPtr hIcon;
|
|
public int iIcon;
|
|
public uint dwAttributes;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
|
public string szDisplayName;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
|
|
public string szTypeName;
|
|
#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter
|
|
}
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
|
internal static extern bool DestroyIcon(IntPtr hIcon);
|
|
|
|
[DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
|
|
internal static extern int SHGetImageList(int iImageList, ref Guid riid, out IntPtr ppv);
|
|
|
|
[DllImport("comctl32.dll", SetLastError = true)]
|
|
internal static extern int ImageList_GetIcon(IntPtr himl, int i, int flags);
|
|
}
|