How to recover VB6 ImageList images

Visual Studio conversion wizard doesn't upgrade VB6 ImageList to the .NET ImageList. You may want to extract the images as files so that you can create a new .NET ImageList with same images.

    Sub ExtractVB6ImageListImages()
        Dim nCount As Integer
        Dim nIndex As Integer
        Dim sKey As String

        nCount = Me.lstTreeViewIcon.ListImages.Count()
        For nIndex = 1 To nCount
            sKey = Me.lstTreeViewIcon.ListImages(nIndex).Key

            Dim oPictureDisp As stdole.IPictureDisp = Me.lstTreeViewIcon.ListImages(nIndex).ExtractIcon
            Dim oIntPtr As IntPtr = New IntPtr(oPictureDisp.Handle)
            Dim oIcon As Icon
            oIcon = System.Drawing.Icon.FromHandle(oIntPtr)

            Dim oBitmap As Bitmap
            oBitmap = oIcon.ToBitmap()
            oBitmap.Save("C:\Icons\" & sKey & ".jpg")

            '' The following code will get "unknown image type" exception
            'Dim oImage As Image
            'oImage = Support.IPictureDispToImage(oPictureDisp)
            'oImage.Save("C:\Icons\" & nIndex & ".jpg")
        Next

    End Sub