Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: David Vans en 30 Abril 2007, 17:15 pm



Título: Extraer Iconos
Publicado por: David Vans en 30 Abril 2007, 17:15 pm
Hola amigos tengo un prblema con vb net extraigo los icons de los ficheros
Código:
    Public Shared Function GetIcon(ByVal path As String, ByVal tipo As TipoIcon) As System.Drawing.Icon
        Dim hImgSmall As IntPtr  'The handle to the system image list.
        Dim myIcon As System.Drawing.Icon
        Dim hImgLarge As IntPtr  'The handle to the system image list.
        Dim fName As String      'The file name to get the icon from.
        Dim shinfo As SHFILEINFO
        shinfo = New SHFILEINFO()
        shinfo.szDisplayName = New String(Chr(0), 260)
        shinfo.szTypeName = New String(Chr(0), 80)
        fName = path
        'Use this to get the small icon.
        Select Case tipo
            Case TipoIcon.Small
                hImgSmall = SHGetFileInfo(fName, 0, shinfo, Marshal.SizeOf(shinfo), _
                SHGFI_ICON Or SHGFI_SMALLICON)
            Case TipoIcon.Large
                hImgLarge = SHGetFileInfo(fName, 0, shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON Or SHGFI_LARGEICON)
        End Select
        ' Try
        myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon)
        ' Catch ex As Exception
        ' 'Erorr
        'End Try
        Return myIcon
    End Function

La funcion funcina correctamente

Luego ago esto
Código:
Dim ImageL As New ImageList
        Dim dirsF() As FileInfo = New DirectoryInfo("C:\").GetFiles
        ListI.LargeImageList = ImageL
        For Each Dir As FileInfo In dirsF
            Dim Nod As New ListViewItem
            Nod.Text = Dir.Name
            ImageL.Images.Add(InformacíonSecurity.GetIcon(Dir.FullName, InformacíonSecurity.TipoIcon.Small))
            Nod.ImageIndex = ImageL.Images.Count - 1
            ListI.Items.Add(Nod)
        Next

Eso tambine funciona pero los iconos me parecen muy pequeños y si cambio el tamaño del imagelist se ve el icono con muy mala calidad y quero verlos grandes corectamente como pasa con explorer .

Gracias por vuestro tiempo


Título: Re: Extraer Iconos
Publicado por: bitarray en 22 Febrero 2009, 23:36 pm
Mirate:

http://www.bitarray.info/2008/12/vb-c-net-obtener-el-icono-asociado-de-un-fichero/

a ver si te vale de algo...