コード例 #1
0
        public static Icon ExtractIconByIndex(string fileName, int index)
        {
            using (IconExtractor extractor = IconExtractor.Open(fileName))
            {
                if (index < 0)
                {
                    throw new ArgumentOutOfRangeException("index");
                }

                if (index >= extractor.IconNames.Count)
                {
                    return(null);
                }

                return(extractor.GetIconByIndex(index));
            }
        }
コード例 #2
0
        public static Icon ExtractIconById(string fileName, int id)
        {
            using (IconExtractor extractor = IconExtractor.Open(fileName))
            {
                if (id < 0)
                {
                    throw new ArgumentOutOfRangeException("index");
                }

                int count = extractor.IconNames.Count;
                for (int i = 0; i < count; i++)
                {
                    ResourceName name = extractor.IconNames[i];
                    if (name.Id != null && name.Id == id)
                    {
                        return(extractor.GetIconByIndex(i));
                    }
                }
            }

            return(null);
        }