试试下面的函数,需要添加相应的api函数、常量和类型的声明
这里得到的图标需要根据namespace而不是文件名来访问
Dim ImageList As Long
Dim FileInfo As SHFILEINFO
Sub SetImageList()
ImageList = SHGetFileInfo("c:\", 0, FileInfo, _
LenB(TSHFileInfo), SHGFI_SYSICONINDEX Or SHGFI_SMALLICON)
If ImageList <> 0 Then
ImageListSmall.hImageList = ImageList
End If
ImageList = SHGetFileInfo("c:\", 0, FileInfo, _
LenB(TSHFileInfo), SHGFI_SYSICONINDEX Or SHGFI_LARGEICON)
If ImageList <> 0 Then '大图标.
ImageListLarge.hImageList = ImageList
End If
End Sub