public ExtractIconWrapper(IExtractIconW ExtractW)
 {
     if (ExtractW == null)
     {
         throw new ArgumentNullException("ExtractW");
     }
     this.ExtractW = ExtractW;
 }
 public void Dispose()
 {
     if (this.ExtractW != null)
     {
         Marshal.ReleaseComObject(this.ExtractW);
         this.ExtractW = null;
     }
 }
Example #3
0
            /// <summary>Gets the icon for the item using the specified characteristics.</summary>
            /// <param name="iei">The IExtractIconW from which to retrieve the icon.</param>
            /// <param name="imgSz">The width, in pixels, of the icon.</param>
            /// <param name="hico">The resulting icon handle, on success, or <c>null</c> on failure.</param>
            /// <returns>The result of function.</returns>
            public static HRESULT LoadIconFromExtractIcon(IExtractIconW iei, ref uint imgSz, out SafeHICON hico)
            {
                var szIconFile = new StringBuilder(Kernel32.MAX_PATH);
                var hr         = iei.GetIconLocation(GetIconLocationFlags.GIL_FORSHELL, szIconFile, szIconFile.Capacity, out var iIdx, out _);

                if (hr.Succeeded)
                {
                    if (szIconFile.ToString() != "*")
                    {
                        hr = iei.Extract(szIconFile.ToString(), (uint)iIdx, (ushort)imgSz, out hico);
                    }
                    else
                    {
                        hr = LoadIconFromSystemImageList(iIdx, ref imgSz, out hico);
                    }
                }
                else
                {
                    hico = null;
                }
                return(hr);
            }