2020-03-28 08:43:16 +13:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
2020-03-30 06:26:45 +13:00
|
|
|
|
namespace SystemTrayMenu.DllImports
|
2020-03-28 08:43:16 +13:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
);
|
|
|
|
|
|
2020-03-30 00:20:18 +13:00
|
|
|
|
internal static IntPtr Shell32SHGetFileInfo(
|
2020-03-28 08:43:16 +13:00
|
|
|
|
string pszPath,
|
|
|
|
|
uint dwFileAttributes,
|
|
|
|
|
ref SHFILEINFO psfi,
|
|
|
|
|
uint cbFileInfo,
|
|
|
|
|
uint uFlags
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
return SHGetFileInfo(pszPath,
|
|
|
|
|
dwFileAttributes,
|
|
|
|
|
ref psfi,
|
|
|
|
|
cbFileInfo,
|
|
|
|
|
uFlags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2020-03-30 00:20:18 +13:00
|
|
|
|
internal struct SHFILEINFO
|
2020-03-28 08:43:16 +13:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|