Icons importing from DLL or EXE

  • Thread starter Thread starter JR
  • Start date Start date
J

JR

Hi,

I want to import Icons from DLL or exe files into a imagelist. I ave no Idee
how to do it. I know the different icons have a 0 based index

Jan
 
I have tryed but I have to many errors

i changed an old code from VB6

'Start code
Private Declare Function ExtractIconEx Lib "shell32.dll" Alias
"ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Integer,
ByVal phiconLarge As Integer, ByVal phiconSmall As Integer, ByVal nIcons As
Integer) As Integer

Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Integer, ByVal
X As Integer, ByVal Y As Integer, ByVal hIcon As Integer) As Integer

Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Integer)
As Integer


Function pfGetIconFromDLL(ByVal DLL As String, ByVal nIconNR As Integer) As
Image
Dim X, Y, Tot, Cnt As Integer
Dim mIcon As Integer
Dim img As New PictureBox
Dim sFileExtensie As String
Try
Dim fInfo As New FileInfo(DLL)
Select Case fInfo.Extension.ToLower
Case ".ico", ".bmp", ".jpg"
img.Image = Image.FromFile(DLL)
Case Else
ExtractIconEx(DLL, nIconNR, mIcon, 0%, 1%)
DrawIcon(img.Handle.ToInt64, 0%, 0%, mIcon)
img.Refresh()
DestroyIcon(mIcon)
End Select
Catch ex As Exception
MsgBox("Fout:" & ex.Message)
End Try
Return img.Image
End Function

But I cant' get it into a image
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top