CSharp08Form.SysIconHelper.GetIconHandle C# (CSharp) Метод

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

public static GetIconHandle ( string path ) : IntPtr
path string
Результат System.IntPtr
        public static IntPtr GetIconHandle(string path)
        {
            SHFILEINFO info;
            SHGetFileInfo(path, 0, out info, (uint)Marshal.SizeOf(typeof(SHFILEINFO)), 0x101u);
            return info.hIcon;
        }

Usage Example

Пример #1
0
        private string GetImageKey(string path)
        {
            IntPtr h   = SysIconHelper.GetIconHandle(path);
            string key = h.ToString();

            if (treeView1.ImageList == null)
            {
                treeView1.ImageList            = new ImageList();
                treeView1.ImageList.ColorDepth = ColorDepth.Depth32Bit;
            }
            if (!treeView1.ImageList.Images.ContainsKey(key))
            {
                treeView1.ImageList.Images.Add(key, Icon.FromHandle(h));
            }
            return(key);
        }