Getting File & Folder Icons

q1w2e3r4t7

Freshman
Joined
Nov 15, 2005
Messages
30
Trying to get the icon of a system files, searched the and the function that everyone is using is :

Code:
 Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" ( _
    ByVal pszPath As String, _
    ByVal dwFileAttributes As Integer, _
    ByRef psfi As SHFILEINFO, _
    ByVal cbFileInfo As Integer, _
    ByVal uFlags As Integer) As Integer

However, this function does not return icons for folders, and doesn't show the transparencies of icons.

Can anyone please help me with returning a correct icon from file / folders.

(p.s. i'm trying to fill a listview control with files & thier icons)

Thanks
 
Have you tried...
Visual Basic:
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" _
  Alias "ExtractAssociatedIconA"
  (hInst As IntPtr, lpIconPath As String, lpiIcon As Integer) As IntPtr
You can use System.Drawing.Icon.FromHandle to convert the return value into a .Net Icon.
 
Back
Top