Пример #1
0
        public int GetIconIndexOf(string filename)
        {
            string fileExtension=CUtils.GetExtension(filename);

            //patch that fixes a crash on search with .mdf and .mds results if Alcohol 120% is sinstalled
            if(fileExtension==".mds" || fileExtension==".mdf")
            {
                filename+=".iso";
                fileExtension=".iso";
            }

            if (m_table[fileExtension]!=null) return (int)m_table[fileExtension];
            Win32.SHFILEINFO shinfo = new Win32.SHFILEINFO();
            IntPtr hImgSmall; //the handle to the system image list
            System.Drawing.Icon myIcon;
            try
            {
                hImgSmall = Win32.SHGetFileInfo(filename, Win32.FILE_ATTRIBUTE_NORMAL, ref shinfo,(uint)Marshal.SizeOf(shinfo),
                    Win32.SHGFI_USEFILEATTRIBUTES | Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);
                myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
            }
            catch
            {
                return -1;
            }
            list.Images.Add(myIcon);
            m_table.Add(fileExtension,list.Images.Count-1);
            return list.Images.Count-1;
        }
Пример #2
0
        public int GetIconIndexOf(string filename)
        {
            string fileExtension = CUtils.GetExtension(filename);

            //patch that fixes a crash on search with .mdf and .mds results if Alcohol 120% is sinstalled
            if (fileExtension == ".mds" || fileExtension == ".mdf")
            {
                filename     += ".iso";
                fileExtension = ".iso";
            }

            if (m_table[fileExtension] != null)
            {
                return((int)m_table[fileExtension]);
            }
            Win32.SHFILEINFO shinfo = new Win32.SHFILEINFO();
            IntPtr           hImgSmall;   //the handle to the system image list

            System.Drawing.Icon myIcon;
            try
            {
                hImgSmall = Win32.SHGetFileInfo(filename, Win32.FILE_ATTRIBUTE_NORMAL, ref shinfo, (uint)Marshal.SizeOf(shinfo),
                                                Win32.SHGFI_USEFILEATTRIBUTES | Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);
                myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
            }
            catch
            {
                return(-1);
            }
            list.Images.Add(myIcon);
            m_table.Add(fileExtension, list.Images.Count - 1);
            return(list.Images.Count - 1);
        }