示例#1
0
 /// <summary>
 /// Convert into an icon resource that can be written into a .dll or .exe.
 /// </summary>
 public IconResource ConvertToIconResource(UInt16 id)
 {
     IconResource iconResource = new IconResource();
     Kernel32.GRPICONDIRENTRY header = new Kernel32.GRPICONDIRENTRY();
     header.bColors = _header.bColors;
     header.bHeight = _header.bHeight;
     header.bReserved = _header.bReserved;
     header.bWidth = _header.bWidth;
     header.dwImageSize = _header.dwImageSize;
     header.wBitsPerPixel = _header.wBitsPerPixel;
     header.wPlanes = _header.wPlanes;
     header.nID = id;
     iconResource.Header = header;
     iconResource.Image = _image;
     return iconResource;
 }
        public override IntPtr Read(IntPtr hModule, IntPtr lpRes)
        {
            _icons.Clear();

            _header = (Kernel32.GRPICONDIR) Marshal.PtrToStructure(
                lpRes, typeof(Kernel32.GRPICONDIR));

            IntPtr pEntry = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_header));

            for (int i = 0; i < _header.wImageCount; i++)
            {
                IconResource iconResource = new IconResource();
                pEntry = iconResource.Read(hModule, pEntry);
                _icons.Add(iconResource);
            }

            return pEntry;
        }