Results 1 to 3 of 3

Thread: extracting the icon assosiated with a particular file extension ...

  1. #1

    Thread Starter
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    extracting the icon assosiated with a particular file extension ...

    Hi all

    I need the .Net variant of the code by aaron found in this thread :

    http://www.vbforums.com/showthread.p...con+assosiated

    It shows how to extract the icon assosiated with a particular file extension.

    anyone done this using vb .net ?

    want to share it with the rest of us ?
    -= a peet post =-

  2. #2

    Thread Starter
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    the code

    VB Code:
    1. Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
    2. 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
    3.  
    4. Private Sub Command1_Click()
    5.     Dim lIcon As Long
    6.     On Error GoTo User_Cancelled
    7.     With CommonDialog1
    8.         .Flags = cdlOFNNoValidate
    9.         .CancelError = True
    10.         .DialogTitle = "Select a File.."
    11.         .Filter = "All Files (*.*)|*.*"
    12.         .ShowOpen
    13.         Picture1.Cls
    14.         lIcon = ExtractAssociatedIcon(App.hInstance, .FileName, -1)
    15.         Call DrawIconEx(Picture1.hdc, 0, 0, lIcon, 32, 32, 0, 0, 3)
    16.     End With
    17. User_Cancelled:
    18. End Sub
    -= a peet post =-

  3. #3
    Lively Member
    Join Date
    Jul 2001
    Posts
    81
    Should be pretty much the same code. Just adjust the declarations a bit.

    All Longs should be Integers. Except any hDc's or hWnd's. They should be IntPtr's.

    Also, instead of Picture1.hdc, it should be Picture1.CreateGraphics.GetHdc
    Rate my posts for a chance to win cash and prizes

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