Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/02/2008, 11:51
opermty
Usuario no validado
 
Fecha de Ingreso: mayo-2006
Mensajes: 42
Antigüedad: 18 años
Puntos: 0
Pregunta Re: Como obtener el icono de un ejecutable en Visual Basic .net

Cita:
Iniciado por ea192000 Ver Mensaje
Hola a todos... bueno, quiero obtener el icono de un ejecutable en Visual Basic .net 2002 para poder usarlo en un boton o en algun otro control dentro de mi programa, pero como mi framework es 1.1, la clase “Icon” no posee el método “ExtractAssociatedIcon”, por ende quería saber si hay otra forma de obtenerlo, desde ya gracias por sus sugerencias...
con API te funciona?


Create a new project, and add this code to Form1

Const DI_MASK = &H1
Const DI_IMAGE = &H2
Const DI_NORMAL = DI_MASK Or DI_IMAGE
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Sub Form_Paint()
Dim mIcon As Long
'Extract the associated icon
mIcon = ExtractAssociatedIcon(App.hInstance, "C:\Autoexec.bat", 2)
'Draw the icon on the form
DrawIconEx Me.hdc, 0, 0, mIcon, 0, 0, 0, 0, DI_NORMAL
'remove the icon from the memory
DestroyIcon mIcon
End Sub