Option Explicit
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon 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 ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phiconLarge As Long, phiconSmall As Long, ByVal nIcons As Long) As Long
Const PICTYPE_ICON As Long = 3
Private Type PICTDESC
cbSizeofstruct As Long
picType As Long '
hgdiobj As Long ' Bitmap, icon, cursor, or metafile
End Type
Const IID_IPicture = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"
Private Declare Function CLSIDFromString Lib "ole32" (ByVal OleStringCLSID As Long, myGUID As Any) As Long
Private Declare Function OleCreatePictureIndirect Lib "olepro32" _
(ByRef pPictDesc As PICTDESC, riid As Any, ByVal fOwn As Long, pPicture As IPicture) As Long
Private Sub Form_Click()
Dim mIcon As Long
Dim pi As PICTDESC, pic As IPicture, myGUID(0 To 15) As Byte, li As ListImage
ExtractIconEx "shell32.dll", 1, mIcon, ByVal 0&, 1
DrawIcon Picture1.hdc, 0, 0, mIcon
pi.cbSizeofstruct = LenB(pi)
pi.picType = PICTYPE_ICON
pi.hgdiobj = mIcon
CLSIDFromString StrPtr(IID_IPicture), myGUID(0)
OleCreatePictureIndirect pi, myGUID(0), 1, pic
Set li = ImageList1.ListImages.Add(, , pic)
Set Picture2.Picture = li.Picture
DestroyIcon mIcon
End Sub
Private Declare Function ImageList_ReplaceIcon Lib "comctl32.dll" (ByVal himl As Long, ByVal I As Long, ByVal hIcon As Long) As Long
Сейчас этот форум просматривают: SemrushBot и гости: 199