In .NET its very easy to load icons from any dll or exe files, we can use the simple API
ExtractIcon(). Paste the following code into a new form and press F5.
GeSHi (vbnet):
Public Class Form1
Private Declare Auto Function ExtractIcon Lib "shell32.dll" ( _
ByVal hIcon As IntPtr, _
ByVal lpszExeFileName As String, _
ByVal nIconIndex As Integer) As IntPtr
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Icon = LoadIconFromDLL("c:\windows\explorer.exe", 1)
End Sub
Private Function LoadIconFromDLL(ByVal sFile As String, ByVal Index As Integer) As Icon
Dim iHandle As IntPtr = ExtractIcon(IntPtr.Zero, sFile, Index)
Select Case iHandle
Case 0
Return Nothing
Case Else
Return Icon.FromHandle(iHandle)
End Select
End Function
End Class
Created by GeSHI 1.0.7.20