using System; using System.Runtime.InteropServices; namespace SystemTrayMenu.NativeDllImport { public static partial class NativeMethods { private const int maxPath = 256; [DllImport("Shell32.dll", CharSet = CharSet.Unicode)] private static extern IntPtr SHGetFileInfo( string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags ); internal static IntPtr Shell32SHGetFileInfo( string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags ) { return SHGetFileInfo(pszPath, dwFileAttributes, ref psfi, cbFileInfo, uFlags); } [StructLayout(LayoutKind.Sequential)] internal struct SHFILEINFO { public const int NAMESIZE = 80; public IntPtr hIcon; public int iIcon; public uint dwAttributes; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = maxPath)] public string szDisplayName; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NAMESIZE)] public string szTypeName; } } }