Well that turned out to be pretty simple.
If GetIconBitsPerPixel returns less than 32 then use Icon.ToBitmap
**** Code Starts ************************************
#Region " IconStructureInfo "
'Icon File Structure Info courtesy of:
'
http://www.iconolog.net/info/icoFormat.html
Private Structure ICONFILE
Dim Reserved As Short
Dim ResourceType As Short
Dim IconCount As Short
Dim IconDir() As ICONENTRY
Dim IconData() As IconData
End Structure
Private Structure ICONENTRY
Dim Width As Byte
Dim Height As Byte
Dim NumColors As Byte
Dim Reserved As Byte
Dim NumPlanes As Short
Dim BitsPerPixel As Short
Dim DataSize As Integer
Dim DataOffset As Integer
End Structure
Private Structure ICONDATA
Dim header As BITMAPINFOHEADER
Dim Palette() As PALETTEENTRY
Dim XorMap() As Byte
Dim AndMap() As Byte
End Structure
Private Structure BITMAPINFOHEADER '40 bytes
Dim biSize As Integer
Dim biWidth As Integer
Dim biHeight As Integer
Dim biPlanes As Short
Dim biBitCount As Short
Dim biCompression As Integer
Dim biSizeImage As Integer
Dim biXPelsPerMeter As Integer
Dim biYPelsPerMeter As Integer
Dim biClrUsed As Integer
Dim biClrImportant As Integer
End Structure
Private Structure PALETTEENTRY
Dim peRed As Byte
Dim peGreen As Byte
Dim peBlue As Byte
Dim peFlags As Byte
End Structure
#End Region
Private Function GetIconBitsPerPixel(ByVal iconfile As String) _
As Integer
Dim fs As New IO.FileStream(iconfile, IO.FileMode.Open)
Dim BR As New IO.BinaryReader(fs)
Dim iFile As New ICONFILE
iFile.Reserved = BR.ReadInt16
iFile.ResourceType = BR.ReadInt16
iFile.IconCount = BR.ReadInt16
ReDim iFile.IconDir(iFile.IconCount)
Dim id(iFile.IconCount) As ICONENTRY
Dim MaxColors As Integer = 0
For i As Integer = 1 To iFile.IconCount
id(i).Width = BR.ReadByte
id(i).Height = BR.ReadByte
id(i).NumColors = BR.ReadByte
id(i).Reserved = BR.ReadByte
id(i).NumPlanes = BR.ReadInt16
id(i).BitsPerPixel = BR.ReadInt16
id(i).DataSize = BR.ReadInt32
id(i).DataOffset = BR.ReadInt32
If id(i).BitsPerPixel > MaxColors Then
MaxColors = id(i).BitsPerPixel
End If
Next
fs.Close()
BR.Close()
If iFile.ResourceType = 1 Then
Return MaxColors
End If
End Function
**** Code Ends *************************************
Mick