Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey all,

 

OK I've figured out extracting an icon from Shell32 using the ExtractIcon API like this:

 

   <DllImport("shell32.dll", CallingConvention:=CallingConvention.Cdecl)> _
       Private Shared Function ExtractIcon _
       (ByVal hIcon As IntPtr, _
       ByVal lpszExeFileName As String, _
       ByVal nIconIndex As Integer) As IntPtr
   End Function

   Private m_Icon as Icon

   Private Sub GetIcon()
       hIcon = ExtractIcon(IntPtr.Zero, "shell32.dll", 4)
       m_Icon = Icon.FromHandle(hIcon).Clone
       DestroyIcon(hIcon)
   End Sub

   Private Sub picIcon_Paint(ByVal sender As Object, _
       ByVal e As System.Windows.Forms.PaintEventArgs) Handles picIcon.Paint

       e.Graphics.DrawIcon(m_Icon, 0, 0)

   End Sub

 

OK this isn't my exact code however it demonstates what is going on. I would like to know how to extract the 48x48 (with alpha) icon from Shell32.dll. ExtractIcon doesn't seem to have any parameters for what format icon you need. ExtractIconEx is no better.

 

Thanks in advance for any input, Tom

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...