Results 1 to 2 of 2

Thread: Getting a Icon of the file (like a .jpg)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Hi,

    All common files are linked to
    programs and the programs have
    icons. Now when you look at a
    file and its linked to a program...

    pic121.jpg --OpenIn-> Ie5

    the picture will have the IE5
    icon. Now my question is, I
    need to know how to get that icon!

    Thanks!

  2. #2
    Guest
    You can use the ExtractAssociatedIcon and DrawIconEx api functions.

    Code:
    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 Sub Command1_Click()
    
            lIcon = ExtractAssociatedIcon(App.hInstance, "C:\Myfile.exe", -1) 'extract icon
            Call DrawIconEx(Picture1.hdc, 0, 0, lIcon, 32, 32, 0, 0, 3) 'draw icon
            
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width