BExplorer.Shell.Win32Api.DestroyIcon C# (CSharp) Method

DestroyIcon() private method

private DestroyIcon ( IntPtr hIcon ) : bool
hIcon System.IntPtr
return bool
		public static extern bool DestroyIcon(IntPtr hIcon);

Usage Example

Example #1
0
        public int GetIconIndex(IntPtr path)
        {
            var    options  = SHGetFileInfoOptions.SysIconIndex | SHGetFileInfoOptions.Icon | SHGetFileInfoOptions.Pidl;
            var    shfi     = new SHFILEINFO();
            var    shfiSize = Marshal.SizeOf(shfi.GetType());
            IntPtr retVal   = Win32Api.SHGetFileInfo(path, FileAttributes.None, ref shfi, shfiSize, options);

            if (shfi.hIcon != IntPtr.Zero)
            {
                Win32Api.DestroyIcon(shfi.hIcon);
            }

            if (retVal.Equals(IntPtr.Zero))
            {
                //throw new Win32Exception(Marshal.GetLastWin32Error());

                return(0);
            }
            else
            {
                /* brakes stack on optimized build
                 * int idx = shfi.iIcon & 0xFFFFFF;
                 * int iOverlay = shfi.iIcon >> 24;
                 * overlayIndex = iOverlay;
                 * return idx;
                 */

                return(shfi.iIcon & 0xFFFFFF);
            }
        }
All Usage Examples Of BExplorer.Shell.Win32Api::DestroyIcon