// 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); }