VB中如何获得其它exe文件的图标
怎样可以获得一个可执行文件的图标?例如已知有一个可执行文件的地址“d:\a.exe”,用什么代码可得到它的图标?...
怎样可以获得一个可执行文件的图标?例如已知有一个可执行文件的地址“d:\a.exe”,用什么代码可得到它的图标?
展开
1个回答
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询