Results 1 to 5 of 5

Thread: File API

  1. #1

    Thread Starter
    Member davethebrat's Avatar
    Join Date
    Jul 2001
    Location
    Buffalo, NY
    Posts
    51

    Cool File API

    I am using a API that lets me scan a folder and add the files in the directory (folder) to a list box. But I want to take this to the next level and add the files to a ListView control, then have windows find the icon that goes with the file, and display it in the listview control along w/ the file. How do I accomplish this????

  2. #2
    Megatron
    Guest
    Yuo could use the ExtractAssociatedIcon API.

  3. #3

    Thread Starter
    Member davethebrat's Avatar
    Join Date
    Jul 2001
    Location
    Buffalo, NY
    Posts
    51
    How do I use ExtractAssociatedIcon???

    This is what i have been using::::


    (in one of my modules)
    ___________________

    Declare Function ExtractAssociatedIconA Lib "shell32.dll" _
    ( _
    ByVal hInst As Long, _
    ByVal lpIconPath As String, _
    lpiIcon As Long _
    ) As Long

    Declare Function DrawIcon Lib "user32" _
    ( _
    ByVal hdc As Long, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal hIcon As Long _
    ) As Long
    Declare Function DestroyIcon Lib "user32" _
    ( _
    ByVal hIcon As Long _
    ) As Long


    _______________________________

    (IN MY FORM)

    _______________________________

    Dim icn as long
    Dim hInstance as long
    Dim Path as string
    icn = 0
    Path = listview1.selectedItem.Tag
    icn = ExtractAssociatedIconA(hInstance, Path, 0)
    >>>> DrawIcon <<<< What do I draw it to?
    DestroyIcon icn

    ______________________________
    How do I add this to my ListView?????

  4. #4
    Megatron
    Guest
    Try this.
    VB Code:
    1. Dim icn as long Dim Path as string
    2. Picture1.AutoRedraw=True
    3. Path = listview1.selectedItem.Tag
    4. icn = ExtractAssociatedIconA(App.hInstance, Path, 0)
    5. If icn Then
    6.     DrawIcon Picture1.hDC, 0, 0, icn
    7.     Picture1.Picture = Picture1.Image
    8.     Set ImageList1.ListImages(index).Picture = Picture1
    9.     Set Picture1 = Nothing
    10.     DestroyIcon icn
    11. End If

  5. #5
    Megatron
    Guest
    Hmmm..I just tested this out, and the results are somewhat skewed. You might be better of using SHGetFileInfo instead.

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