zoukankan      html  css  js  c++  java
  • 通过winApi 由文件名,获取文件图标

     1         [DllImport("Shell32.dll")]
    2 static extern int SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags);
    3
    4 struct SHFILEINFO
    5 {
    6 public IntPtr hIcon;
    7 public int iIcon;
    8 public uint dwAttributes;
    9 public char szDisplayName;
    10 public char szTypeName;
    11 }
    12
    13 /// <summary>
    14      /// 从文件扩展名得到文件关联图标
    15      /// </summary>
    16      /// <param name="fileName">文件名或文件扩展名</param>
    17      /// <param name="smallIcon">是否是获取小图标,否则是大图标</param>
    18      /// <returns>图标</returns>
    19 static public Icon GetFileIcon(string fileName, bool smallIcon)
    20 {
    21 SHFILEINFO fi = new SHFILEINFO();
    22 Icon ic = null;
    224 int iTotal = (int)SHGetFileInfo(fileName, 100, ref fi, 0, (uint)(smallIcon ? 273 : 272));
    25 if (iTotal > 0)
    26 {
    27 ic = Icon.FromHandle(fi.hIcon);
    28 }
    29 return ic;
    30 }
  • 相关阅读:
    ubuntu 开启ssh
    ubuntu 电源管理
    吸血鬼数
    java泛型
    分布式数据库主键id生成策略
    使用SSH工具连接到MySQL
    MySQL命令行基本命令操作
    bootstrap图片轮播
    java设计模式----工厂模式
    java设计模式----享元模式
  • 原文地址:https://www.cnblogs.com/xtdhb/p/2431021.html
Copyright © 2011-2022 走看看