📄 impsfiletype.cs
字号:
namespace Imps.Client.Resource
{
using System;
using System.Drawing;
using System.Runtime.InteropServices;
public class ImpsFileType
{
private const int SHGFI_ICON = 0x100;
private const int SHGFI_LARGEICON = 0;
private const int SHGFI_SMALLICON = 1;
private const int SHGFI_TYPENAME = 0x400;
public static Icon GetIcon(string sFileName)
{
SHFILEINFO structure = new SHFILEINFO();
int cbFileInfo = Marshal.SizeOf(structure);
int uFlags = 0x100;
SHGetFileInfo(sFileName, 0, ref structure, cbFileInfo, uFlags);
return Icon.FromHandle(structure.hIcon);
}
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO info, int cbFileInfo, int uFlags);
[StructLayout(LayoutKind.Sequential)]
public struct SHFILEINFO
{
public IntPtr hIcon;
public uint iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=260)]
public char[] szDisplayName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=80)]
public char[] szTypeName;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -