Example #1
0
        public Icon RetrieveIcon(string fName)
        {
            IntPtr hImgSmall;    //the handle to the system image list
            IntPtr hImgLarge;    //the handle to the system image list
            SHFILEINFO shinfo = new SHFILEINFO();

            hImgSmall = SHGetFileInfo(fName, 0, ref shinfo, (uint) Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON);

            //Use this to get the large Icon
            //hImgLarge = SHGetFileInfo(fName, 0,
            //ref shinfo, (uint)Marshal.SizeOf(shinfo),
            //Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON);

            //The icon is returned in the hIcon member of the shinfo
            //struct
            return Icon.FromHandle(shinfo.hIcon);
        }
Example #2
0
        public static extern IntPtr SHGetFileInfo(string pszPath,
												  uint dwFileAttributes,
												  ref SHFILEINFO psfi,
												  uint cbSizeFileInfo,
												  uint uFlags);