Results 1 to 2 of 2

Thread: Help with File Registry

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    64

    Post

    I was just wondering if there is any code (and i'm sure there is) that would call the registry, and return a filetypes icon. If so, i could really use some help. Thanx.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    If you're after the Icon associated with a File Extension, take a look at the ExtractAssociatedIcon API, eg.

    Add a Picturebox, Command Button and CommonDialog Control to a Form..
    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()
        Dim lIcon As Long
        On Error GoTo User_Cancelled
        With CommonDialog1
            .Flags = cdlOFNNoValidate
            .CancelError = True
            .DialogTitle = "Select a File.."
            .Filter = "All Files (*.*)|*.*"
            .ShowOpen
            Picture1.Cls
            lIcon = ExtractAssociatedIcon(App.hInstance, .FileName, -1)
            Call DrawIconEx(Picture1.hdc, 0, 0, lIcon, 32, 32, 0, 0, 3)
        End With
    User_Cancelled:
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

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