Here is a function from one of my apps (a file browser) that lists a folder and get's icons for all items.
It checks if a file is a .desktop file and uses it's Icon= field anf if not it uses methods to get defaults.
Maybe it will help.
(Ps, the AppIcon class is the class i posted in the previous posts)
Public Sub LoadPath(Directory As String)
$iIconSize = Me.IconSize
If Not pDirIcon Then pDirIcon = Picture["icon:/128/directory"]
If Directory Then $sPath = Directory Else Return ' Directory = User.Home
$sItems = Dir(Directory).Sort(gb.Ascent + gb.IgnoreCase + gb.Natural)
Dim sDirs As New String[]
Dim sFiles As New String[]
Dim ic As Picture, df As MyDesktopFile, sVar As String, icA As New Collection
For Each sVar In $sItems
df = Null
ic = Null
If IsDir($sPath &/ sVar) Then
ic = pDirIcon.Image.Stretch($iIconSize, $iIconSize).Picture
sDirs.Add(sVar)
Else
Select LCase(File.Ext(sVar))
Case "zip", "tar", "gz", "bzip", "rar", "ace"
ic = Picture["icon:/" & $iIconSize & "/archive"]
Case "desktop"
df = New MyDesktopFile($sPath &/ sVar)
If Not df Then Continue
If (Not Exist(df.Icon)) Or If (Not InStr(df.Icon, "/")) Then
Dim sIcon As String = AppIcon.SearchIcons(df.Icon, Style.Name)
If sIcon And Exist(sIcon) Then df.Icon = sIcon
Endif
Try ic = Image.Load(df.Icon).Stretch($iIconSize, $iIconSize).Picture
sFiles.Add(sVar)
Case "png", "jpg", "bmp", "jpeg"
Try ic = Image.Load($sPath &/ sVar).Stretch($iIconSize, $iIconSize).Picture
sFiles.Add(sVar)
Case Else
Dim mt As DesktopMime
mt = DesktopMime.FromFile($sPath &/ sVar)
If mt.Type Like "*x-compressed*" Then
ic = Picture["icon:/" & $iIconSize & "/archive"]
Else
ic = Desktop.GetFileIcon($sPath &/ sVar, $iIconSize)
Endif
sFiles.Add(sVar)
End Select
Endif
If Not ic Then ic = Desktop.GetFileIcon($sPath &/ sVar, $iIconSize)
If Not ic Then ic = Stock["128/file"].Image.Stretch($iIconSize, $iIconSize).Picture
' add the icon picture to the collection under it's file name
icA.Add(ic, sVar)
Next
' create icons either naturally or dir's first
Object.Lock($hView)
If $bDirsFirst Then
For Each s As String In sDirs
mf = New MyIcon($hView, Directory &/ s, icA[s]) As "Icon"
mf.Visible = If(Left(s) = ".", $bShowHidden, True)
AddToGrid(mf)
mf.Menu = "mnuEdit"
Next
For Each s As String In sFiles
mf = New MyIcon($hView, Directory &/ s, icA[s]) As "Icon"
mf.Visible = If(Left(s) = ".", $bShowHidden, True)
mf.Menu = "mnuEdit"
AddToGrid(mf)
Next
Else
For Each s As String In $sItems
mf = New MyIcon($hView, Directory &/ s, icA[s]) As "Icon"
mf.Visible = If(Left(s) = ".", $bShowHidden, True)
mf.Menu = "mnuEdit"
AddToGrid(mf)
Next
Endif
$hView.Refresh
$hView.Scroll(iScroll[0], iScroll[1])
Raise Loaded
Catch
Debug Error.Text & gb.Lf & Error.Backtrace.Join("\n") & "'''"
End