示例#1
0
        public static Icon GetIcon(string Extension)
        {
            try
            {
                Icon TempIcon;
                //temp struct for getting file shell info
                SHFILEINFO TempFileInfo = new SHFILEINFO();

                SHGetFileInfo(Extension, 0, ref TempFileInfo, (uint)Marshal.SizeOf(TempFileInfo), 0x100 | 0x10 | 0x0);

                TempIcon = (Icon)Icon.FromHandle(TempFileInfo.hIcon);
                return TempIcon;
            }
            catch
            {
                return null;
            }
        }
示例#2
0
 static extern IntPtr SHGetFileInfo(
     string pszPath,				//path
     uint dwFileAttributes,		//attributes
     ref SHFILEINFO psfi,		//struct pointer
     uint cbSizeFileInfo,		//size
     uint uFlags);