Extracting Icons from exe or dll files in VB.NET

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

how can I extract an icon from a fil
for example this sentence

"F:\WINDOWS\System32\shell32.dll,3"

how can I extract icon nr 3 from the shell32.dll??


I found some code for VB6 that might have worked in VB6, but it's been
changed in VB.NET, it was some API-calls, and drawing on compononts using
the hDC property, but the hDC property has been deleted in the PictureBox,
and I haven't found it in other components neither.
But it's got to be possible to do in VB.NET

Please help, I can't seem to figure it out.
regards Richard
 
how can I extract an icon from a fil
for example this sentence

"F:\WINDOWS\System32\shell32.dll,3"

how can I extract icon nr 3 from the shell32.dll??


I found some code for VB6 that might have worked in VB6, but it's been
changed in VB.NET, it was some API-calls, and drawing on compononts using
the hDC property, but the hDC property has been deleted in the PictureBox,
and I haven't found it in other components neither.
But it's got to be possible to do in VB.NET

Please help, I can't seem to figure it out.
regards Richard

What was the API-Call? ExtractIcon?

Public Declare Auto Function ExtractIcon Lib "shell32" ( _
ByVal hInstance As IntPtr,
ByVal lpszExeFileName As String,
ByVal nIconIndex As Integer) As IntPtr


Dim hInstance As IntPtr = Marshal.GetHINSTANCE( _
System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0))


Dim hIcon As IntPtr = ExtractIcon ( _
System.Runtime.InteropServices.Marshal.GetHINSTANCE(),
"f:\windows\system32\shell32.dll", _
2) ' this is a zero based index... so this will be the 3rd icon

If Not hIcon.Equals(IntPtr.Zero) Then
pb.Image = Bitmap.FromHicon(hIcon)
End If

Anyway, something along those lines...
 
I tried a lot, and actually i was very close, the onlything i needed was
apperently

Bitmap.FromHicon(hIcon



Thanks I'm grateful



regards Richard
 
Back
Top