1个回答
展开全部
这个不是提取EXE图标的,这个只是调用livtview显示文件列表而已,你想addhis.ini是ini怎么可能会有图标呢
你要自己把这些图标先加进去,然后显示对应的图标:
Option Explicit
Private Sub Form_Load()
File1.Visible = False
File1.Path = "c:\windows"
Dim i As Long, sFile As String
sFile = IIf(Right$(File1.Path, 1) = "\", File1.Path, File1.Path & "\")
For i = 0 To File1.ListCount - 1
ListView1.ListItems.Add i + 1, , sFile & File1.List(i)
Next
End Sub
但是如果要加入图像,你必须自己添加一个ImageList控件,然后修改这句为:
ListView1.ListItems.Add i + 1, , sFile & File1.List(i), ImageList1.ListImages(1)
'ImageList里面需要自己插入图片到位置1
获取EXE图标代码如下:
Option Explicit
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Sub Command1_Click()
Static total As Long, p(50) As Long, i As Integer, filename As String
filename = "d:\a.exe"
total = ExtractIcon(App.hInstance, filename, -1)
'取得总图标数
For i = 0 To total - 1
p(i) = ExtractIcon(App.hInstance, filename, i) '读取每个图标
Next i
For i = 0 To total - 1 '依次显示每个图标
DrawIcon Picture1.hdc, 34 * i, 0, p(i)
Next i
DrawIcon Picture2.hdc, 0, 0, p(0) '这个是显示exe本身图标的··
End Sub
你要自己把这些图标先加进去,然后显示对应的图标:
Option Explicit
Private Sub Form_Load()
File1.Visible = False
File1.Path = "c:\windows"
Dim i As Long, sFile As String
sFile = IIf(Right$(File1.Path, 1) = "\", File1.Path, File1.Path & "\")
For i = 0 To File1.ListCount - 1
ListView1.ListItems.Add i + 1, , sFile & File1.List(i)
Next
End Sub
但是如果要加入图像,你必须自己添加一个ImageList控件,然后修改这句为:
ListView1.ListItems.Add i + 1, , sFile & File1.List(i), ImageList1.ListImages(1)
'ImageList里面需要自己插入图片到位置1
获取EXE图标代码如下:
Option Explicit
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Sub Command1_Click()
Static total As Long, p(50) As Long, i As Integer, filename As String
filename = "d:\a.exe"
total = ExtractIcon(App.hInstance, filename, -1)
'取得总图标数
For i = 0 To total - 1
p(i) = ExtractIcon(App.hInstance, filename, i) '读取每个图标
Next i
For i = 0 To total - 1 '依次显示每个图标
DrawIcon Picture1.hdc, 34 * i, 0, p(i)
Next i
DrawIcon Picture2.hdc, 0, 0, p(0) '这个是显示exe本身图标的··
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询