2020-07-07 07:15:45 +12:00
|
|
|
|
// <copyright file="SHGetFileInfo.cs" company="PlaceholderCompany">
|
|
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
|
|
// </copyright>
|
2020-03-28 08:43:16 +13:00
|
|
|
|
|
2020-03-30 06:26:45 +13:00
|
|
|
|
namespace SystemTrayMenu.DllImports
|
2020-03-28 08:43:16 +13:00
|
|
|
|
{
|
2020-07-07 07:15:45 +12:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// wraps the methodcalls to native windows dll's.
|
|
|
|
|
/// </summary>
|
2020-03-28 08:43:16 +13:00
|
|
|
|
public static partial class NativeMethods
|
|
|
|
|
{
|
|
|
|
|
private const int maxPath = 256;
|
|
|
|
|
|
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,
|
2020-07-07 07:15:45 +12:00
|
|
|
|
uint uFlags)
|
2020-03-28 08:43:16 +13:00
|
|
|
|
{
|
2020-07-07 07:15:45 +12:00
|
|
|
|
return SHGetFileInfo(
|
|
|
|
|
pszPath,
|
2020-03-28 08:43:16 +13:00
|
|
|
|
dwFileAttributes,
|
|
|
|
|
ref psfi,
|
|
|
|
|
cbFileInfo,
|
|
|
|
|
uFlags);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 00:11:41 +13:00
|
|
|
|
[DllImport("Shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
|
|
|
|
2020-07-07 07:15:45 +12:00
|
|
|
|
private static extern IntPtr SHGetFileInfo(
|
|
|
|
|
string pszPath,
|
|
|
|
|
uint dwFileAttributes,
|
|
|
|
|
ref SHFILEINFO psfi,
|
|
|
|
|
uint cbFileInfo,
|
|
|
|
|
uint uFlags);
|
2020-07-07 09:37:55 +12:00
|
|
|
|
|
2020-10-11 11:28:34 +13:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
2020-10-20 00:11:41 +13:00
|
|
|
|
|
2020-07-07 09:37:55 +12:00
|
|
|
|
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;
|
|
|
|
|
}
|
2020-03-28 08:43:16 +13:00
|
|
|
|
}
|
|
|
|
|
}
|