it didn't work, but Cerpin pointed out that Str should be AStr, so here's code that works (for V1 and V2):
Code: Select all
Loop %A_Programs%\*.*
{
FileName := A_LoopFileFullPath
hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, AStr, FileName, UShortP, iIndex)
if hIcon
{
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
IconNumber := DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon) + 1
DllCall("DestroyIcon", Uint, hIcon)
}
else
IconNumber := 1
LV_Add("Icon" . IconNumber, A_LoopFileName)
}
Code: Select all
Gui, Margin, 0, 0
Gui, Add, ListView, r20 w500, Name
ImageListID1 := IL_Create(10)
LV_SetImageList(ImageListID1)
Loop %A_Programs%\*.*
{
FileName := A_LoopFileFullPath
hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, AStr, FileName, UShortP, iIndex)
if hIcon
{
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
IconNumber := DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon) + 1
DllCall("DestroyIcon", Uint, hIcon)
}
else
IconNumber := 1
LV_Add("Icon" . IconNumber, A_LoopFileName)
}
Gui, Show
Code: Select all
Gui := GuiCreate()
Gui.MarginX := 0
Gui.MarginY := 0
LV := Gui.Add("ListView", "r20 w500", "Name")
ImageListID1 := IL_Create(10)
LV.SetImageList(ImageListID1)
Loop Files A_Programs "\*.*"
{
FileName := A_LoopFileFullPath
hIcon := DllCall("Shell32\ExtractAssociatedIconA", UInt, 0, AStr, FileName, UShortP, iIndex)
if hIcon
{
DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon)
IconNumber := DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, hIcon) + 1
DllCall("DestroyIcon", Uint, hIcon)
}
else
IconNumber := 1
LV.Add("Icon" . IconNumber, A_LoopFileName)
}
Gui.Show()