ExtractAssociatedIcon的32位图标

时间:2013-07-24 10:56:47

标签: vb.net icons

当我保存提取图标时,我只有8位频道图标。我怎样才能获得32位图标? 这是我使用的代码:

Public Sub LoadIcon()
   Dim path = My.Computer.FileSystem.SpecialDirectories.Desktop + "\icon\"
   Dim filePath As String = "С:/Windows/explorer.exe"
   Dim TheIcon As Icon = IconFromFilePath(filePath)
   If TheIcon IsNot Nothing Then
      Using stream As New System.IO.FileStream(path + "programicon.ico",       IO.FileMode.CreateNew)
         TheIcon.Save(stream)
      End Using
   End If
   PictureBox1.Load(path + "programicon.ico")
End Sub

Public Function IconFromFilePath(ByVal filePath As String) As Icon
    Dim result As Icon = Nothing
    Try
        result = Icon.ExtractAssociatedIcon(filePath)
    Catch
    End Try
    Return result
End Function

它返回此图标:

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试使用shgetfileinfo查找最大的图标,也许如果您使用SHIL_LASTSHIL_JUMBO(从Windows Vista开始),您会找到32位颜色图标。有关SHIL_LASTSHIL_JUMBO的更多信息,您可以找到here