Как извлечь иконку из файла
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 Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Sub Command1_Click()
Dim hIcon As Long
Dim i As Long
Dim n As Long
AutoRedraw = True
' Получаем число иконок в файле
n = ExtractIcon(App.hInstance, "c:\windows\system\shell32.dll", -1)
' Рисуем каждую иконку на форме
For i = 0 To n - 1
hIcon = ExtractIcon(App.hInstance, "c:\windows\system\shell32.dll", i)
DrawIcon hdc, i * 32, 0, hIcon
Next
' Освобождаем ресурсы
DestroyIcon hIcon
Refresh
End Sub
|