最近在写一个媒体管理的服务器程序。里面要用到了一个获得指定文件的集成图标的。所以就写了一个用C#中调用API来获得指定文件的图标的代码,代码如下: 导入API的类: using System; using System.Runtime.InteropServices; namespace MediaClient ... { public class Win32 ...{ [DllImport("shell32.dll", EntryPoint = "ExtractIcon")] public static extern int ExtractIcon(IntPtr hInst,string lpFileName,int nIndex); [DllImport("shell32.dll", EntryPoint = "SHGetFileInfo")] public static extern IntPtr SHGetFileInfo(string pszPath,uint dwFileAttribute,ref SHFILEINFO psfi,uint cbSizeFileInfo,uint Flags); [DllImport("User32.dll", EntryPoint = "DestroyIcon")] public static extern int DestroyIcon(IntPtr hIcon);