BrowserSelect.IconExtractor.fromFile C# (CSharp) Метод

fromFile() публичный статический Метод

public static fromFile ( string filename ) : Icon
filename string
Результат System.Drawing.Icon
        public static Icon fromFile(string filename)
        {
            IntPtr[] phicon = new IntPtr[] { IntPtr.Zero };
            IntPtr[] piconid = new IntPtr[] { IntPtr.Zero };

            PrivateExtractIcons(filename, 0, 128, 128, phicon, piconid, 1, 0);

            if (phicon[0] != IntPtr.Zero)
                return System.Drawing.Icon.FromHandle(phicon[0]);
            return null;
        }

Usage Example

Пример #1
0
        private static void AddChromeProfiles(List <Browser> browsers, string BrowserName, string VendorDataFolder, string IconFilename)
        {
            Browser BrowserChrome = browsers.FirstOrDefault(x => x.name == BrowserName);

            if (BrowserChrome != null)
            {
                string        ChromeUserDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), VendorDataFolder);
                List <string> ChromeProfiles    = FindChromeProfiles(ChromeUserDataDir, IconFilename);

                if (ChromeProfiles.Count > 1)
                {
                    //add the Chrome instances and remove the default one
                    foreach (string Profile in ChromeProfiles)
                    {
                        browsers.Add(new Browser()
                        {
                            name           = BrowserName + " (" + GetChromeProfileName(ChromeUserDataDir + "\\" + Profile) + ")",
                            exec           = BrowserChrome.exec,
                            icon           = icon2String(IconExtractor.fromFile(ChromeUserDataDir + "\\" + Profile + "\\" + IconFilename)),
                            additionalArgs = String.Format("--profile-directory={0}", Profile)
                        });
                    }
                    browsers.Remove(BrowserChrome);
                    browsers = browsers.OrderBy(x => x.name).ToList();
                }
            }
        }
All Usage Examples Of BrowserSelect.IconExtractor::fromFile