public static Icon GetSmallIcon(string pFilePath) { FileInfoStruct _info = new FileInfoStruct(); try { Win32.GetFileInfo(pFilePath, 0, ref _info, Marshal.SizeOf(_info), (int)(FileInfoFlags.SHGFI_ICON | FileInfoFlags.SHGFI_SMALLICON)); Icon myicon = Icon.FromHandle(_info.hIcon); return myicon; } catch (System.Exception) { return null; } }
public static extern int GetFileInfo(string pszPath, int dwFileAttributes, ref FileInfoStruct psfi, int cbFileInfo, int uFlags);