예제 #1
0
        /// <summary>
        ///     Get the Icon of a Path or file
        /// </summary>
        /// <param name="path">
        ///     The Path of Directory or File
        /// </param>
        /// <returns>
        ///     Icon Retrieved
        /// </returns>
        /// Author:         http://www.cnblogs.com/BG5SBK/articles/GetFileInfo.aspx
        /// Create Date:    2007-07-01
        public static Icon GetLargeIcon(string path)
        {
            FileInfomation info = new FileInfomation();

            FileInfo.GetFileInfo(path, 0, ref info, Marshal.SizeOf(info),
                                 (int)(GetFileInfoFlags.SHGFI_ICON | GetFileInfoFlags.SHGFI_LARGEICON));
            try
            {
                return(Icon.FromHandle(info.hIcon));
            }
            catch
            {
                return(null);
            }
        }
 public static extern int GetFileInfo(string pszPath, int dwFileAttributes,
                                      ref FileInfomation psfi, int cbFileInfo, int uFlags);